protected function _init()
{
parent::_init();
foreach ($this->_initializers as $key) {
if (($value = $this->_config[$key]) !== null) {
$this->_config[$key] = is_array($value) ? array() : null;
$this->{$key}($value);
}
}
if ($list = $this->_config['whitelist']) {
$this->_config['whitelist'] = array_combine($list, $list);
}
if ($this->_entity && !$this->_config['model']) {
$this->model($this->_entity->model());
}
if ($this->_config['with']) {
if (!($model = $this->model())) {
throw new ConfigException("The `'with'` option needs a valid binded model.");
}
$this->_config['with'] = Set::normalize($this->_config['with']);
}
if ($model = $this->model()) {
$this->alias($this->_config['alias'] ?: $model::meta('name'));
}
$this->fields($this->_config['fields']);
unset($this->_config['entity'], $this->_config['init']);
}