/** * */ public function testCreateInstance() { Yii::$app->set('parserA', ['class' => DefaultArrayParser::className(), 'validate' => false]); verify('validate is assigned', Yii::$app->parserA->validate)->false(); Yii::$app->set('parserB', ['class' => DefaultArrayParser::className()]); verify('validate default value is true', Yii::$app->parserB->validate)->true(); }
/** * Initialize the parser component to use. */ public function init() { parent::init(); if ($this->parser === null) { $this->_p = Yii::createObject(['class' => DefaultArrayParser::className()]); } elseif ($this->parser === false) { $this->_p = null; } elseif (is_array($this->parser)) { $this->_p = Yii::createObject($this->parser); } elseif (is_string($this->parser)) { $this->_p = Yii::$app->get($this->parser); } elseif (is_object($this->parser)) { $this->_p = $this->parser; } else { throw new InvalidConfigException('invalid "parser" attribute : string or array expected'); } if ($this->_p !== null && !$this->_p instanceof WorkflowArrayParser) { throw new InvalidConfigException('the parser component must implement the WorkflowArrayParser interface'); } }