import {IFactory} from '../interfaces/commands/IFactory';
import {IFactory as IAppFactory} from '../interfaces/IFactory';
import {IFilesBrowserCommands} from '../interfaces/commands/IFilesBrowserCommands';
import {FilesBrowserCommands} from './FilesBrowserCommands';
import {Helpers} from '../../admin/Helpers';

export class Factory implements IFactory {

    protected conf:any;
    
    protected appFactory:IAppFactory;

    protected filesBrowserCommands:IFilesBrowserCommands = null;

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

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

    public getFilesBrowserCommands():IFilesBrowserCommands
    {
        if(this.filesBrowserCommands === null){
            this.filesBrowserCommands = this.conf.fileBrowserCommands || new FilesBrowserCommands();
        }
        return this.filesBrowserCommands;
    }

}