public function __construct(&$code, $poll_id = null) { // here i must get the valid attributes which can be set through the poll questions // and define the attributes and maybe set the default values. if ($code) { $this->_code = $code; if (!$this->getPoll()) { throw new Exception("Poll selection failed", 1); } if (!$this->getOptions()) { throw new Exception("Option selection failed", 1); } $this->header = $this->_poll->title; $this->question = $this->_poll->question; // set the min and max options to be selected $this->_min_options = $this->_poll->select_min; $this->_max_options = $this->_poll->select_max; $this->defineAttribute('options', $value = null); $this->defineAttribute('vote_submitted', $value = 1); $this->setOptionRules(); } elseif (isset($poll_id)) { $this->setPreviewMode($poll_id); } $attributes = []; $config = []; parent::__construct($attributes, $config); }
/** * @param \yii\db\ActiveRecord $baseModel * @param array $config */ public function __construct($baseModel, $propertyGroups, $config = []) { $this->baseModel = $baseModel; $this->propertyGroups = $propertyGroups; $attributes = $this->baseModel->activeAttributes(); foreach ($this->propertyGroups as $groupId => $properties) { $attributes = ArrayHelper::merge($attributes, array_keys($properties)); } parent::__construct($attributes, $config); $this->addRule($attributes, 'safe'); }
/** * BaseConfigurationModel constructor. * There are a building of rules, a building of attributeLabels and attributes definition here. * @param array $config */ public function __construct(array $config = []) { $attributes = []; foreach ($this->rules() as $rules) { $attributes = ArrayHelper::merge($attributes, (array) $rules[0]); } $attributes = array_unique($attributes); parent::__construct($attributes, $config); $module = call_user_func([$this->getModuleClassName(), 'module']); foreach ($attributes as $name) { $this->{$name} = $module->{$name}; } }
/** * @inheritdoc */ public function __construct($name, $attributes = [], $config = []) { $this->_name = $name; $definition = isset(static::$defintions[$name]) ? static::$defintions[$name] : ['attrs' => $attributes]; $attributes = array_merge(ArrayHelper::getValue($definition, 'attrs', []), $attributes); foreach (['formName', 'rules', 'behaviors', 'methods'] as $attr) { if (array_key_exists($attr, $config)) { $definition[$name][$attr] = $config[$attr]; unset($config[$attr]); } } if (!isset(static::$defintions[$name])) { static::$defintions[$name] = $definition; } $this->_formName = ArrayHelper::getValue($definition, 'formName'); $this->_rules = ArrayHelper::getValue($definition, 'rules', []); $this->_behaviors = ArrayHelper::getValue($definition, 'behaviors', []); $this->_methods = ArrayHelper::getValue($definition, 'methods', []); parent::__construct($attributes, $config); }
/** * @inheritDoc */ public function __construct(array $config = []) { $this->_model = new Tasks(); parent::__construct($this->_model->attributes(), $config); }
/** * @inheritDoc */ public function __construct($config = []) { $this->_model = new Deploy(); parent::__construct(array_merge($this->_model->attributes(), ['tasks_id']), $config); }
/** * LoginForm constructor. * * @param array $config Object config */ public function __construct($config = []) { $attributes = UsersModule::module()->authorizationScenario()->attributes(); parent::__construct($attributes, $config); }
public function __construct(AbstractPermitionEntity $permition) { parent::__construct($permition->getAttributes()); $this->permition = $permition; $this->attachBehaviors($permition->behaviours()); }
/** * @inheritDoc */ public function __construct(array $config = []) { $this->_model = new Websites(); parent::__construct(['name', 'user_id', 'deploy_script', 'deploy_project', 'website'], $config); }
/** * 构造函数 */ public function __construct(array $attributes = [], array $attributeLabels = [], $config = []) { parent::__construct($attributes, $config); $this->_attributeLabels = $attributeLabels; }