Initializes the options for the object

Called from {@link __construct()} as a first step of object instantiation.

@param  KObjectConfig $config A ObjectConfig object with configuration options
@return void
550661
protected function _initialize(KObjectConfig $config)
    {
        $config->append(array(
            'cookie_name' => 'referrer',
            'cookie_path' => $this->getObject('request')->getBaseUrl()->toString(KHttpUrl::PATH)
        ));

        parent::_initialize($config);
    }
373994
public function initialize(array $config): void
    {
        // Set default translations
        $this->config('translations', [
            'id' => __d('model_history', 'field.id'),
            'comment' => __d('model_history', 'field.comment'),
            'created' => __d('model_history', 'field.created'),
            'modified' => __d('model_history', 'field.modified')
        ]);

        $this->ModelHistory = TableRegistry::get('ModelHistory.ModelHistory');
        // Dynamically attach the hasMany relationship
        $this->_table->hasMany('ModelHistory.ModelHistory', [
            'conditions' => [
                'ModelHistory.model' => $this->_table->registryAlias()
            ],
            'order' => ['ModelHistory.revision DESC'],
            'foreignKey' => 'foreign_key',
            'dependent' => false
        ]);

        if (isset($config['ignoreFields'])) {
            $this->setConfig('ignoreFields', $config['ignoreFields'], false);
        }

        $singularUnderscoredTableName = Inflector::singularize(Inflector::underscore($this->_table->getAlias()));
        $allColumns = $this->_table->getSchema()->columns();

        foreach ($allColumns as $columnName) {
            if (in_array($columnName, $this->getConfig('ignoreFields'))) {
                continue;
            }

            $obfuscated = false;
            $searchable = true;
            $type = 'string';

            if (substr($columnName, -3) === '_id') {
                $singular = substr($columnName, 0, -3);
                $associationName = str_replace('_', '', Inflector::pluralize($singular));
                $association = $this->_table->association($associationName);
                if (!is_null($association)) {
                    switch ($association->type()) {
                        case $association::MANY_TO_MANY:
                            $type = 'association';
                            break;

                        case $association::ONE_TO_MANY:
                        case $association::MANY_TO_ONE:
                            $type = 'relation';
                            break;
                    }
                }
            } elseif (strpos($columnName, 'password') !== false) {
                $obfuscated = true;
                $searchable = false;
            } else {
                switch ($this->_table->getSchema()->columnType($columnName)) {
                    case 'boolean':
                        $type = 'bool';
                        break;
                    case 'json':
                        $type = 'hash';
                        break;
                    case 'integer':
                        $type = 'number';
                        break;
                    case 'datetime':
                        $type = 'date';
                        break;
                }
            }
            $translationIdentifier = $singularUnderscoredTableName . '.' . $columnName;

            $manualConfig = isset($config['fields'][$columnName]) ? $config['fields'][$columnName] : [];
            $columnConfig = Hash::merge([
                'name' => $columnName,
                'translation' => function () use ($translationIdentifier) {
                    return __($translationIdentifier);
                },
                'searchable' => $searchable,
                'saveable' => true,
                'obfuscated' => $obfuscated,
                'type' => $type
            ], $manualConfig);

            $this->setConfig('fields.' . $columnName, $columnConfig, false);
        }

        // fill the config array of fields not in the table schema with default values
        if (!empty($config['fields'])) {
            foreach ($config['fields'] as $columnName => $manualConfig) {
                if (!in_array($columnName, $allColumns)) {
                    if (empty($manualConfig['type'])) {
                        throw new Exception(
                            sprintf('ModelHistory config for field %s is missing a type.', $columnName)
                        );
                    }

                    $translationIdentifier = $singularUnderscoredTableName . '.' . $columnName;

                    $columnConfig = Hash::merge([
                        'name' => $columnName,
                        'translation' => function () use ($translationIdentifier) {
                            return __($translationIdentifier);
                        },
                        'searchable' => true,
                        'saveable' => true,
                        'obfuscated' => false,
                    ], $manualConfig);

                    $this->setConfig('fields.' . $columnName, $columnConfig, false);
                }
            }
        }

        parent::initialize($config);
    }
527926
protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'cookie_name'   => md5($this->getObject('request')->getBasePath()),
            'cookie_path'   => (string) $this->getObject('request')->getBaseUrl()->getPath() ?: '/',
            'cookie_domain' => (string) $this->getObject('request')->getBaseUrl()->getHost()
        ));

        parent::_initialize($config);
    }
561552
protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'formats' => array(
                'php'  => __NAMESPACE__.'\ObjectConfigPhp',
                'ini'  => __NAMESPACE__.'\ObjectConfigIni',
                'json' => __NAMESPACE__.'\ObjectConfigJson',
                'xml'  => __NAMESPACE__.'\ObjectConfigXml',
                'yml'  => __NAMESPACE__.'\ObjectConfigYaml',
                'yaml' => __NAMESPACE__.'\ObjectConfigYaml'
            )
        ));

        parent::_initialize($config);
    }
479338
protected function _initialize(KObjectConfig $config)
    {
        $db = JFactory::getDbo();

        //Set the table prefix
        $config->append(array(
            'table_prefix' => $db->getPrefix(),
        ));

        //Set the database connection
        if ($db instanceof JDatabaseDriverMysqli && $db->getConnection() instanceof mysqli)
        {
            $config->append(array(
                'connection'   => $db->getConnection(),
            ));
        }
        else
        {
            $conf = JFactory::getConfig();
            $host = $conf->get('host');

            /*
             * Unlike mysql_connect(), mysqli_connect() takes the port and socket as separate arguments. Therefore, we
             * have to extract them from the host string.
             */
            $tmp = substr(strstr($host, ':'), 1);
            if (!empty($tmp))
            {
                // Get the port number or socket name
                if (is_numeric($tmp))
                {
                    $config->append(array(
                        'port' => $tmp
                    ));
                }
                else
                {
                    $config->append(array(
                        'socket' => $tmp
                    ));
                }

                // Extract the host name only
                $host = substr($host, 0, strlen($host) - (strlen($tmp) + 1));

                // This will take care of the following notation: ":3306"
                if ($host == '') {
                    $host = 'localhost';
                }
            }

            $config->append(array(
                'auto_connect' => true,
                'host'         => $host,
                'username'     => $conf->get('user'),
                'password'     => $conf->get('password'),
                'database'     => $conf->get('db'),
            ));
        }

        parent::_initialize($config);
    }
435367
protected function _initialize(KObjectConfig $config)
    {
        $path       = rtrim($this->getObject('request')->getSiteUrl()->getPath(), '/');
        $nooku_path = $path.'/media/koowa/framework';
        $schemes    = array(
            'assets://js'  => $nooku_path.'/js',
            'assets://css' => $nooku_path.'/css',
            'assets://img' => $nooku_path.'/img',
            'assets://koowa' => $path.'/media/koowa/com_koowa',
            'media://'     => $path.'/media/',
            'root://'      => $path.'/',
            'base://'      => rtrim($this->getObject('request')->getBaseUrl()->getPath(), '/').'/'
        );

        if (empty(static::$_component_assets))
        {
            $components = $this->getObject('object.bootstrapper')->getComponents();

            foreach($components as $component)
            {
                $identifier = $this->getIdentifier($component);

                // Only register reusable components such as files and koowa
                if ($identifier->domain === 'koowa')
                {
                    $key         = 'assets://'.$identifier->package;
                    $destination = $path.'/media/koowa/com_'.$identifier->package;

                    static::$_component_assets[$key] = $destination;
                }
            }
        }

        $schemes = array_merge($schemes, static::$_component_assets);

        // Override default scheme with the media/ folder
        $schemes['assets://'] = $path.'/media/';

        $config->append(array(
            'schemes' => $schemes,
        ));

        parent::_initialize($config);
    }
920688
protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'query'    => array(),
            'data'     => array(),
            'format'   => 'html',
            'user'     => array(),
            'language' => locale_get_default(),
            'timezone' => date_default_timezone_get(),
        ));

        parent::_initialize($config);
    }
1063511
protected function _initialize(KObjectConfig $config)
    {
        $config->append(array(
            'strict_callables' => false,
            'pragmas'          => array(Mustache_Engine::PRAGMA_FILTERS),
        ));

        parent::_initialize($config);
    }
510153
public function initialize(array $config)
    {
        $this->_controller = $this->_registry->getController();
        $this->_request    = $this->_controller->request;

        parent::initialize($config);
    }
140262
protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'toolbars' => array($this->getIdentifier()->name),
            'model'    => $this->getIdentifier()->name,
        ));

        parent::_initialize($config);
    }
133970
protected function _initialize(KObjectConfig $config)
    {
        $self = $this;

        $config->append(array(
            'autoescape'       => true,
            'strict_variables' => false,
            'optimizations'    => -1,
            'functions'        => array(
                'import' => function($url, $data) use($self) {
                    return $self->_import($url, $data);
                }
            ),
        ));

        parent::_initialize($config);
    }
399369
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->table('users');
        $this->displayField('username');
        $this->primaryKey('id');

        $this->addBehavior('Timestamp');
        $this->addBehavior('Muffin/Trash.Trash');
        $this->addBehavior('Muffin/Tokenize.Tokenize');

        if (Plugin::loaded('Search')) {
            $this->addBehavior('Search.Search');
        }
    }
1197394
protected function _objectConfig(KObjectConfig $config)
    {
        $config->append(array(
            'id'         => $this->row,
            'objectName' => $this->title,
            'type'       => array('objectName' => $this->name, 'object' => true),
            'url'        => 'option=com_' . $this->package . '&view=' . $this->name . '&id=' . $this->row,
            'attributes' => array('class' => array('object')),
            'find'       => 'object',
            'translate'  => false
        ));
    }
672065
protected function _initialize(KObjectConfig $config)
    {
        $config->append(array(
            'base_url'  => '/',
            'base_path' => null,
            'url'       => null,
            'method'   => null,
            'query'   => $_GET,
            'data'    => $_POST,
            'cookies' => $_COOKIE,
            'files'   => $_FILES,
            'proxies' => array(),
            'format'  => null,
        ));

        parent::_initialize($config);
    }
766819
protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'language'          => locale_get_default(),
            'language_fallback' => 'en-GB',
            'cache'             =>  \Kodekit::getInstance()->isCache(),
            'cache_namespace'   => 'kodekit',
            'catalogue'         => 'default',
        ));

        parent::_initialize($config);
    }
1064747
protected function _initialize(ObjectConfig $config)
    {
        $config->append(array(
            'users' => array($this->getObject('user')),
        ));

        parent::_initialize($config);
    }
74793
protected function _initialize(KObjectConfig $config)
    {
        if(!defined('JOOMLATOOLS_PLATFORM'))
        {
            $query = $this->getObject('lib:database.query.select')
                ->table('template_styles')
                ->columns('template')
                ->where('client_id = :client_id AND home = :home')
                ->bind(array(
                    'client_id' => JFactory::getApplication()->getClientId(), 'home' => 1
                ));

            $template = $this->getObject('lib:database.adapter.mysqli')->select($query, KDatabase::FETCH_FIELD);
        }
        else $template = JFactory::getApplication()->getTemplate();

        $config->append([
            'override_paths' => [
                JPATH_THEMES.'/'.$template.'/html',
                JPATH_THEMES.'/system/html'         // #117: For backwards compatibility purposes
            ]
        ]);

        parent::_initialize($config);
    }