@inheritdoc

@throws InvalidConfigException
356912
public function init()
    {
        if ($this->dataProvider === null) {
            throw new InvalidConfigException('The "dataProvider" property must be set');
        }
        $this->channelAttributes = $this->getAttributes($this->channel);
        foreach ($this->requiredChannelElements as $channelElement) {
            if (!in_array($channelElement, $this->channelAttributes)) {
                throw new InvalidConfigException('Required channel attribute "' . $channelElement . '" must be set');
            }
        }
        $this->itemAttributes = $this->getAttributes($this->items);
        foreach ($this->requiredItemElements as $itemElement) {
            if (!in_array($itemElement, $this->itemAttributes)) {
                throw new InvalidConfigException('Required item attribute "' . $itemElement . '" must be set');
            }
        }
        $this->feed = new Feed;
    }
109510
public function init()
    {
        if ($this->dataProvider === null) {
            throw new InvalidConfigException('The "dataProvider" property must be set.');
        }
        if ($this->emptyText === null) {
            $this->emptyText = Yii::t('yii', 'No results found.');
        }
        if (!isset($this->options['id'])) {
            $this->options['id'] = $this->getId();
        }

        if ($this->formatter == null) {
            $this->formatter = Yii::$app->getFormatter();
        } elseif (is_array($this->formatter)) {
            $this->formatter = Yii::createObject($this->formatter);
        }
        if (!$this->formatter instanceof Formatter) {
            throw new InvalidConfigException('The "formatter" property must be either a Format object or a configuration array.');
        }

        if (!$this->keyColumnName) {
            throw new InvalidConfigException('The "keyColumnName" property must be specified"');
        }
        if (!$this->parentColumnName) {
            throw new InvalidConfigException('The "parentColumnName" property must be specified"');
        }

        $this->initColumns();
    }
1084323
protected function validate($config): void
    {
        // Check that $config is an array
        if (! Validator::arrayType()->validate($config)) {
            throw new InvalidConfigException('The config must be an array.');
        }

        // Check boolean parameters
        if (! Validator::key('interface', Validator::boolType())->validate($config)) {
            throw new InvalidConfigException('"interface" parameter must be set as a boolean.');
        }
        if (! Validator::key('private', Validator::boolType())->validate($config)) {
            throw new InvalidConfigException('"private" parameter must be set as a boolean.');
        }
        if (! Validator::key('auto', Validator::boolType())->validate($config)) {
            throw new InvalidConfigException('"auto" parameter must be set as a boolean.');
        }

        $this->validatePhpdoc($config);
    }
937624
public function init()
	{
		if ($this->model === null) {
            throw new InvalidConfigException('Please specify the "model" property.');
        }
        if ($this->formatter == null) {
            $this->formatter = Yii::$app->getFormatter();
        } elseif (is_array($this->formatter)) {
            $this->formatter = Yii::createObject($this->formatter);
        }
        if (!$this->formatter instanceof Formatter) {
            throw new InvalidConfigException('The "formatter" property must be either a Format object or a configuration array.');
        }
		
		if($this->nullDisplay === null)
			$this->nullDisplay='<span class="null">'.Yii::t('app','Not set').'</span>';
			$this->options['id'] = $this->getId();

		//$this->normalizeAttributes();
	}
714283
protected function initConfig() {
		$config = Xml::read($this->file);

		if ($config->getName() !== 'container') {
			throw new InvalidConfig('Root element of a config must be a "container"', null, null, $config);
		}

		$this->override = ($config->override === 'true');
		
		$this->includes     = [];
		$this->parameters   = new stdClass();
		$this->services     = new stdClass();
		$this->initializers = new stdClass();
		
		foreach ($config->getContent() as $element) {
			$name = $element->getName();
			
			if ($name === 'includes') {
				$this->includes = array_merge($this->includes, $this->processIncludes($element));
				continue;
			}
			
			if ($name === 'parameters') {
				$this->parameters = Std::objectMerge($this->parameters, $this->processParameters($element));
				continue;
			}
			
			if ($name === 'services') {
				$this->services = Std::objectMerge($this->services, $this->processServices($element));
				continue;
			}
			
			if ($name === 'initializers') {
				$this->initializers = Std::objectMerge($this->initializers, $this->processInitializers($element));
				continue;
			}
			
			throw new InvalidConfig('Unknown element "' . $element->getName() . '" in container', null, null, $element->getName());
		}
	}
822831
public function init()
    {
        foreach (static::defaultConfig() as $key => $value) {
            if (!isset($this->{$key})) {
                $this->{$key} = $value;
            }
        }
        foreach (static::requiredConfig() as $key) {
            if (!isset($this->{$key})) {
                throw new InvalidConfigException(get_class($this) . " key provider requires '{$key}' config key");
            }
        }
        KeyProviderCollector::internalRegisterProvider($this);
    }
227561
protected function validateConfig()
    {
        $defaults = [
            'tpl_folder',
            'cache_folder',
            'tpl_file_format',
            //'compress',
            //'event_emitter',
        ];

        foreach ($defaults as $key) {
            if (! isset($this->config[$key])) {
                throw new InvalidConfigException(sprintf("Missing a configuration key (%s)", $key));
            }
        }
    }
667138
protected function prepareModels() {
		if(!$this->query instanceof QueryInterface) {
			throw new InvalidConfigException(
				'The "query" property must be an instance of a class that implements the '.
				'chsergey\rest\QueryInterface or its subclasses.'
			);
		}

		$query = clone $this->query;

		$this->setPagination([
			'pageSizeLimit' => [1, 1000]
		]);

		if (($pagination = $this->getPagination()) !== false) {
			$pagination->totalCount = $this->getTotalCount();
			$query->limit($pagination->getLimit())
				->offset($pagination->getOffset());
		}

		return $query->all();
	}
530705
public function configure(Closure $callback)
    {
        if ( ! is_array($configuration = $callback($this->configuration))) {
            throw new Exceptions\InvalidConfigurationException($configuration);
        }

        $this->configuration = array_merge($this->defaultConfiguration, $configuration);
    }
1005463
public function run()
    {
        Yii::$app->response->format = Response::FORMAT_JSON;
        $param = Yii::$app->request->get($this->clientIdGetParamName);
        if (mb_strlen($param) < 2) {
            if (YII_DEBUG) {
                throw new InvalidConfigException ("Operator '{$this->clientIdGetParamName}' requires two operands.");
            } else {
                return [];
            }
        } else {
            $query = Tag::find();
            $rows = $query->select(['id', 'name', 'name as text', 'frequency'])
                ->where(['like', 'name', $param])
                ->orderBy(['frequency' => SORT_DESC])
                ->limit(Yii::$app->request->get($this->clientLimitGetParamName, 20))
                ->asArray()
                ->all();
            return $rows;
        }
    }
708916
public function init()
    {
        parent::init();

        if (empty($this->id)) {
            $this->id = $this->getId();
        }

        if ($this->modelClass == null) {
            throw new InvalidConfigException('Param "modelClass" must be contain model name');
        }

        if (null == $this->behaviorName) {
            throw new InvalidConfigException("No 'behaviorName' supplied on action initialization.");
        }

        if (null == $this->advancedUpdateRoute && ($controller = Yii::$app->controller)) {
            $this->advancedUpdateRoute = "{$controller->id}/update";
        }

        if ($this->formFieldsCallable == null) {
            $this->formFieldsCallable = function ($form, $model) {
                /** @var ActiveForm $form */
                echo $form->field($model, $this->nameAttribute);
            };
        }

        /** @var ActiveRecord|TreeInterface $model */
        $model = $this->modelClass;

        /** @var ActiveRecord[]|TreeInterface[] $rootNodes */
        $rootNodes = $model::find()->roots()->all();

        if (!empty($rootNodes[0])) {
            /** @var ActiveRecord|TreeInterface $items */
            $items = $rootNodes[0]->populateTree();
            $this->_items = $this->prepareItems($items);
        }
    }
21560
public function init()
    {
        parent::init();

        if (empty($this->id)) {
            $this->id = $this->getId();
        }

        if ($this->modelClass == null) {
            throw new InvalidConfigException('Param "modelClass" must be contain model name');
        }

        if (null == $this->behaviorName) {
            throw new InvalidConfigException("No 'behaviorName' supplied on action initialization.");
        }

        if (null == $this->advancedUpdateRoute && ($controller = Yii::$app->controller)) {
            $this->advancedUpdateRoute = "{$controller->id}/update";
        }

        if ($this->formFieldsCallable == null) {
            $this->formFieldsCallable = function ($form, $model) {
                /** @var ActiveForm $form */
                echo $form->field($model, $this->nameAttribute);
            };
        }

        /** @var ActiveRecord $model */
        $model = new $this->modelClass;
        /** @var NestedSetsBehavior $behavior */
        $behavior = $model->getBehavior($this->behaviorName);

        $this->_leftAttribute = $behavior->leftAttribute;
        $this->_rightAttribute = $behavior->rightAttribute;

        $items = $model::find()
            ->orderBy([$this->_leftAttribute => SORT_ASC])
            ->all();
        $this->_items = $this->prepareItems($items);
    }
791298
protected function initComputed()
    {
        if (empty($this->computed)) {
            return;
        }

        if (!is_array($this->computed)) {
            throw new InvalidConfigException('The "computed" option are not an array');
        }

        foreach ($this->computed as $key => $callback) {
            if (is_array($callback)) {
                if (isset($callback['get'])) {
                    $function = $callback['get'] instanceof JsExpression ? $callback['get'] : new JsExpression($callback['get']);
                    $this->clientOptions['computed'][$key]['get'] = $function;
                }
                if (isset($callback['set'])) {
                    $function = $callback['set'] instanceof JsExpression ? $callback['set'] : new JsExpression($callback['set']);
                    $this->clientOptions['computed'][$key]['set'] = $function;
                }
            } else {
                $function = $callback instanceof JsExpression ? $callback : new JsExpression($callback);
                $this->clientOptions['computed'][$key] = $function;
            }
        }
    }
855541
protected function initOptions()
    {
        if (!($this->model instanceof Model)) {
            throw new InvalidConfigException('Model is required');
        }

        if (!($this->model->getPrimaryKey())) {
            throw new InvalidConfigException('Model has empty primary key');
        }

        if ($this->button !== false) {
            $this->button['position'] = isset($this->button['position']) ? $this->button['position'] : static::BUTTON_OUTSIDE;
        }

        if (empty($this->scenario)) {
            $this->scenario = $this->model->scenario;
        } else {
            $this->_oldScenario = $this->model->scenario;
            $this->model->scenario = $this->scenario;
        }

        if ($this->form !== false) {
            $formConfig = [
                'method' => 'POST',
                'action' => $this->scenario,
                'options' => [
                    'class' => 'inline',
                    'data' => [
                        'modal-form' => true,
                    ],
                ],
            ];
            if ($this->submit === static::SUBMIT_PJAX) {
                $formConfig['options'] = ArrayHelper::merge($formConfig['options'], [
                    'data' => ['pjax' => 1, 'pjax-push' => 0],
                ]);
            } elseif ($this->submit === static::SUBMIT_AJAX) {
                $formConfig['options'] = ArrayHelper::merge($formConfig['options'], [
                    'data' => ['ajax-submit' => 1],
                ]);

                $this->registerAjaxSubmit();
            }

            $this->form = ArrayHelper::merge($formConfig, $this->form);
        }

        if (is_array($footer = $this->modal['footer'])) {
            $tag = ArrayHelper::remove($footer, 'tag', 'input');
            $label = ArrayHelper::remove($footer, 'label', 'OK');
            $footer = ArrayHelper::merge([
                'data-modal-submit' => true,
                'data-loading-text' => '<i class="fa fa-circle-o-notch fa-spin"></i> ' . Yii::t('hipanel', 'loading'),
            ], $footer);

            if ($tag === 'input') {
                $footer['type']  = 'submit';
                $footer['value'] = $label;
            }

            $this->modal['footer'] = Html::tag($tag, $label, $footer);
            $this->registerFooterButtonScript();
        }

        $this->modal = ArrayHelper::merge([
            'id' => $this->getModalId(),
            'toggleButton' => ($this->button['position'] === static::BUTTON_IN_MODAL) ? $this->button : false,
        ], $this->modal);
    }
191634
protected function loadOptions(): void
    {
        $options = [];

        if ($this->preset == 'custom') {
            $optionsFile = null;
        } else {
            $optionsFile = __DIR__ . '/presets/' . $this->preset . '.php';
        }

        if ($optionsFile !== null) {
            if (!is_file($optionsFile)) {
                throw new InvalidConfigException('The CKEditor options file can not be loaded.');
            }
            $options = require($optionsFile);
        }

        $this->clientOptions = ArrayHelper::merge(
            $options,
            $this->clientOptions
        );
    }
159515
public function setMatch($value)
    {
        switch (gettype($value)) {
            case 'array':
                $this->match = $value;
                break;
            case 'string':
                $this->match = [$value];
                break;
            case 'boolean':
                if ($value === false) {
                    $this->match = false;
                    break;
                }
                // Match could not be true.
            default:
                throw new InvalidConfigException("Invalid configuration. Wrong march type '{$value}'.");
        }
    }
600372
public function init(): void
    {
        parent::init();

        if ($this->name === null || !\is_string($this->name) || $this->name === '') {
            throw new InvalidConfigException('Formatter name must be defined');
        }
        if ($this->path === null) {
            throw new InvalidConfigException('File path property must be defined and be not empty');
        }
        foreach ($this->formatAdapterArray as $i => $formatAdapter) {
            $this->formatAdapterArray[$i] = Container::createObject($formatAdapter);

            if (!($this->formatAdapterArray[$i] instanceof IFormatAdapter)) {
                throw new InvalidConfigException(sprintf('Format adapter must be instance of %s.', IFormatAdapter::class));
            }
        }
    }