import {IFactory} from '../interfaces/commands/IFactory';
import {IFactory as IAppFactory} from '../interfaces/IFactory';
import {IAppCommands} from '../interfaces/commands/IAppCommands';
import {AppCommands} from './AppCommands';
import {Helpers} from '@common/admin/Helpers';

export class Factory implements IFactory {

    protected conf:any;
    
    protected appFactory:IAppFactory;

    protected appCommands:IAppCommands = null;

    public init(conf:any): void
    {
        this.conf = {
            appCommands: null,
        };
        Helpers.objectReplaceRecursive(this.conf, conf);
    }

    public setAppFactory(factory:IAppFactory)
    {
        this.appFactory = factory;
    }

    public getAppCommands():IAppCommands
    {
        if(this.appCommands === null){
            this.appCommands = this.conf.appCommands || new AppCommands();
        }
        return this.appCommands;
    }

}