src/ClientFactory.php
public function createLocalClient(array $options)
    {
        $this->container = $container = new Container();

        $options = ArrayUtils::defaults($this->defaultConfig, $options);
        $container->set('config', new Config($options));

        $dbConfig = ArrayUtils::get($options, 'database', []);

        $config = ArrayUtils::omit($options, 'database');
        // match the actual directus status mapping config key
        $config['statusMapping'] = $config['status']['mapping'];
        unset($config['status']['mapping']);

        if (!defined('STATUS_DELETED_NUM')) {
            define('STATUS_DELETED_NUM', ArrayUtils::get($config, 'status.deleted_value', 0));
        }

        if (!defined('STATUS_ACTIVE_NUM')) {
            define('STATUS_ACTIVE_NUM', ArrayUtils::get($config, 'status.active_value', 1));
        }

        if (!defined('STATUS_DRAFT_NUM')) {
            define('STATUS_DRAFT_NUM', ArrayUtils::get($config, 'status.draft_value', 2));
        }

        if (!defined('STATUS_COLUMN_NAME')) {
            define('STATUS_COLUMN_NAME', ArrayUtils::get($config, 'status.column_name', 'status'));
        }

        if (!defined('DIRECTUS_ENV')) {
            define('DIRECTUS_ENV', ArrayUtils::get($config, 'environment', 'development'));
        }

        $connection = new Connection($dbConfig);
        $connection->connect();
        $container->set('connection', $connection);
        $container->set('zendDb', $connection);

        $acl = new \Directus\Permissions\Acl();
        $acl->setUserId(1);
        $acl->setGroupId(1);
        $acl->setGroupPrivileges([
            '*' => [
                'id' => 1,
                'table_name' => '*',
                'group_id' => 1,
                'read_field_blacklist' => [],
                'write_field_blacklist' => [],
                'nav_listed' => 1,
                'status_id' => 0,
                'allow_view' => 2,
                'allow_add' => 1,
                'allow_edit' => 2,
                'allow_delete' => 2,
                'allow_alter' => 1
            ]
        ]);
        $container->set('acl', $acl);

        $schema = new \Directus\Database\Schemas\Sources\MySQLSchema($connection);
        $container->set('schemaSource', $schema);
        $schema = new \Directus\Database\SchemaManager($schema);
        $container->set('schemaManager', $schema);
        TableSchema::setSchemaManagerInstance($schema);
        TableSchema::setAclInstance($acl);
        TableSchema::setConnectionInstance($connection);
        TableSchema::setConfig(new Config($config));

        $container->singleton('emitter', function() {
            return $this->getEmitter();
        });
        $container->set('files_settings', function(Container $container) {
            $adapter = $container->get('connection');
            $acl = $container->get('acl');
            $Settings = new DirectusSettingsTableGateway($adapter, $acl);

            return $Settings->fetchCollection('files', [
                'thumbnail_size', 'thumbnail_quality', 'thumbnail_crop_enabled'
            ]);
        });
        $container->set('app.settings', function (Container $container) {
            $DirectusSettingsTableGateway = new \Zend\Db\TableGateway\TableGateway('directus_settings', $container->get('zendDb'));
            $rowSet = $DirectusSettingsTableGateway->select();

            $settings = [];
            foreach ($rowSet as $setting) {
                $settings[$setting['collection']][$setting['name']] = $setting['value'];
            }

            return $settings;
        });

        $container->singleton('hashManager', function () {
            return new HashManager();
        });

        $container->singleton('files', function() {
            return $this->getFiles();
        });

        BaseTableGateway::setHookEmitter($container->get('emitter'));
        BaseTableGateway::setContainer($container);

        $client = new ClientLocal($connection);
        $client->setContainer($container);

        return $client;
    }
public function createLocalClient(array $options)
    {
        $this->container = $container = new Container();

        $options = ArrayUtils::defaults($this->defaultConfig, $options);
        $container->set('config', new Config($options));

        $dbConfig = ArrayUtils::get($options, 'database', []);

        $config = ArrayUtils::omit($options, 'database');
        // match the actual directus status mapping config key
        $config['statusMapping'] = $config['status']['mapping'];
        unset($config['status']['mapping']);

        if (!defined('STATUS_DELETED_NUM')) {
            define('STATUS_DELETED_NUM', ArrayUtils::get($config, 'status.deleted_value', 0));
        }

        if (!defined('STATUS_ACTIVE_NUM')) {
            define('STATUS_ACTIVE_NUM', ArrayUtils::get($config, 'status.active_value', 1));
        }

        if (!defined('STATUS_DRAFT_NUM')) {
            define('STATUS_DRAFT_NUM', ArrayUtils::get($config, 'status.draft_value', 2));
        }

        if (!defined('STATUS_COLUMN_NAME')) {
            define('STATUS_COLUMN_NAME', ArrayUtils::get($config, 'status.column_name', 'status'));
        }

        if (!defined('DIRECTUS_ENV')) {
            define('DIRECTUS_ENV', ArrayUtils::get($config, 'environment', 'development'));
        }

        $connection = new Connection($dbConfig);
        $connection->connect();
        $container->set('connection', $connection);
        $container->set('zendDb', $connection);

        $acl = new \Directus\Permissions\Acl();
        $acl->setUserId(1);
        $acl->setGroupId(1);
        $acl->setGroupPrivileges([
            '*' => [
                'id' => 1,
                'table_name' => '*',
                'group_id' => 1,
                'read_field_blacklist' => [],
                'write_field_blacklist' => [],
                'nav_listed' => 1,
                'status_id' => 0,
                'allow_view' => 2,
                'allow_add' => 1,
                'allow_edit' => 2,
                'allow_delete' => 2,
                'allow_alter' => 1
            ]
        ]);
        $container->set('acl', $acl);

        $schema = new \Directus\Database\Schemas\Sources\MySQLSchema($connection);
        $container->set('schemaSource', $schema);
        $schema = new \Directus\Database\SchemaManager($schema);
        $container->set('schemaManager', $schema);
        TableSchema::setSchemaManagerInstance($schema);
        TableSchema::setAclInstance($acl);
        TableSchema::setConnectionInstance($connection);
        TableSchema::setConfig(new Config($config));

        $container->singleton('emitter', function() {
            return $this->getEmitter();
        });
        $container->set('files_settings', function(Container $container) {
            $adapter = $container->get('connection');
            $acl = $container->get('acl');
            $Settings = new DirectusSettingsTableGateway($adapter, $acl);

            return $Settings->fetchCollection('files', [
                'thumbnail_size', 'thumbnail_quality', 'thumbnail_crop_enabled'
            ]);
        });
        $container->set('app.settings', function (Container $container) {
            $DirectusSettingsTableGateway = new \Zend\Db\TableGateway\TableGateway('directus_settings', $container->get('zendDb'));
            $rowSet = $DirectusSettingsTableGateway->select();

            $settings = [];
            foreach ($rowSet as $setting) {
                $settings[$setting['collection']][$setting['name']] = $setting['value'];
            }

            return $settings;
        });

        $container->singleton('hashManager', function () {
            return new HashManager();
        });

        $container->singleton('files', function() {
            return $this->getFiles();
        });

        BaseTableGateway::setHookEmitter($container->get('emitter'));
        BaseTableGateway::setContainer($container);

        $client = new ClientLocal($connection);
        $client->setContainer($container);

        return $client;
    }
public function createLocalClient ( array $ options ) { $ this -> container = $ container = new Container ( ) ; $ options = ArrayUtils :: defaults ( $ this -> defaultConfig , $ options ) ; $ container -> set ( 'config' , new Config ( $ options ) ) ; $ dbConfig = ArrayUtils :: get ( $ options , 'database' , [ ] ) ; $ config = ArrayUtils :: omit ( $ options , 'database' ) ; // match the actual directus status mapping config key $ config [ 'statusMapping' ] = $ config [ 'status' ] [ 'mapping' ] ; unset ( $ config [ 'status' ] [ 'mapping' ] ) ; if ( ! defined ( 'STATUS_DELETED_NUM' ) ) { define ( 'STATUS_DELETED_NUM' , ArrayUtils :: get ( $ config , 'status.deleted_value' , 0 ) ) ; } if ( ! defined ( 'STATUS_ACTIVE_NUM' ) ) { define ( 'STATUS_ACTIVE_NUM' , ArrayUtils :: get ( $ config , 'status.active_value' , 1 ) ) ; } if ( ! defined ( 'STATUS_DRAFT_NUM' ) ) { define ( 'STATUS_DRAFT_NUM' , ArrayUtils :: get ( $ config , 'status.draft_value' , 2 ) ) ; } if ( ! defined ( 'STATUS_COLUMN_NAME' ) ) { define ( 'STATUS_COLUMN_NAME' , ArrayUtils :: get ( $ config , 'status.column_name' , 'status' ) ) ; } if ( ! defined ( 'DIRECTUS_ENV' ) ) { define ( 'DIRECTUS_ENV' , ArrayUtils :: get ( $ config , 'environment' , 'development' ) ) ; } $ connection = new Connection ( $ dbConfig ) ; $ connection -> connect ( ) ; $ container -> set ( 'connection' , $ connection ) ; $ container -> set ( 'zendDb' , $ connection ) ; $ acl = new \ Directus \ Permissions \ Acl ( ) ; $ acl -> setUserId ( 1 ) ; $ acl -> setGroupId ( 1 ) ; $ acl -> setGroupPrivileges ( [ '*' => [ 'id' => 1 , 'table_name' => '*' , 'group_id' => 1 , 'read_field_blacklist' => [ ] , 'write_field_blacklist' => [ ] , 'nav_listed' => 1 , 'status_id' => 0 , 'allow_view' => 2 , 'allow_add' => 1 , 'allow_edit' => 2 , 'allow_delete' => 2 , 'allow_alter' => 1 ] ] ) ; $ container -> set ( 'acl' , $ acl ) ; $ schema = new \ Directus \ Database \ Schemas \ Sources \ MySQLSchema ( $ connection ) ; $ container -> set ( 'schemaSource' , $ schema ) ; $ schema = new \ Directus \ Database \ SchemaManager ( $ schema ) ; $ container -> set ( 'schemaManager' , $ schema ) ; TableSchema :: setSchemaManagerInstance ( $ schema ) ; TableSchema :: setAclInstance ( $ acl ) ; TableSchema :: setConnectionInstance ( $ connection ) ; TableSchema :: setConfig ( new Config ( $ config ) ) ; $ container -> singleton ( 'emitter' , function ( ) { return $ this -> getEmitter ( ) ; } ) ; $ container -> set ( 'files_settings' , function ( Container $ container ) { $ adapter = $ container -> get ( 'connection' ) ; $ acl = $ container -> get ( 'acl' ) ; $ Settings = new DirectusSettingsTableGateway ( $ adapter , $ acl ) ; return $ Settings -> fetchCollection ( 'files' , [ 'thumbnail_size' , 'thumbnail_quality' , 'thumbnail_crop_enabled' ] ) ; } ) ; $ container -> set ( 'app.settings' , function ( Container $ container ) { $ DirectusSettingsTableGateway = new \ Zend \ Db \ TableGateway \ TableGateway ( 'directus_settings' , $ container -> get ( 'zendDb' ) ) ; $ rowSet = $ DirectusSettingsTableGateway -> select ( ) ; $ settings = [ ] ; foreach ( $ rowSet as $ setting ) { $ settings [ $ setting [ 'collection' ] ] [ $ setting [ 'name' ] ] = $ setting [ 'value' ] ; } return $ settings ; } ) ; $ container -> singleton ( 'hashManager' , function ( ) { return new HashManager ( ) ; } ) ; $ container -> singleton ( 'files' , function ( ) { return $ this -> getFiles ( ) ; } ) ; BaseTableGateway :: setHookEmitter ( $ container -> get ( 'emitter' ) ) ; BaseTableGateway :: setContainer ( $ container ) ; $ client = new ClientLocal ( $ connection ) ; $ client -> setContainer ( $ container ) ; return $ client ; }
Creates a new local client instance

@param array $options

@return ClientLocal
Creates a new local client instance