本文整理汇总了PHP中yii\base\Model::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Model::__construct方法的具体用法?PHP Model::__construct怎么用?PHP Model::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yii\base\Model
的用法示例。
在下文中一共展示了Model::__construct方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @inheritdoc
*/
public function __construct($config = [])
{
parent::__construct($config);
if (is_null($this->columns)) {
$this->columns = [new Column()];
}
}
示例2: __construct
public function __construct($config = [])
{
if ($this->getUserSecurityQusetions() != null) {
$this->setAttributes(['question_one' => $this->getUserSecurityQusetions()->security_question_one_id, 'question_one_answer' => $this->getUserSecurityQusetions()->security_question_one_answer, 'question_two' => $this->getUserSecurityQusetions()->security_question_two_id, 'question_two_answer' => $this->getUserSecurityQusetions()->security_question_two_answer], false);
}
parent::__construct($config);
}
示例3: __construct
/**
* CategoryForm constructor
* @param integer|null $item_id
*/
public function __construct($item_id = null)
{
parent::__construct();
if ($item_id) {
/** @var $category Category*/
$category = Category::findOne($item_id);
$this->item_id = $category->id;
$this->language_id = $category->language_id;
$this->title = $category->title;
$this->description = $category->description;
$this->category_type = $category->category_type;
if ($category->main) {
$this->boxes[] = self::PROPERTY_MAIN;
}
if ($category->public) {
$this->boxes[] = self::PROPERTY_PUBLIC;
}
if ($category->active) {
$this->boxes[] = self::PROPERTY_ACTIVE;
}
} else {
$session = Yii::$app->session;
if (!$session['language_id']) {
$session['language_id'] = LanguageRecord::getMainLanguageId();
}
$this->language_id = $session['language_id'];
$this->boxes[] = self::PROPERTY_PUBLIC;
$this->boxes[] = self::PROPERTY_ACTIVE;
}
}
示例4: __construct
public function __construct($user, $config = [])
{
parent::__construct($config);
$this->_user = $user;
$this->username = $user->username;
$this->email = $user->email;
}
示例5: __construct
/**
* Find profession categories with professions links
* @param array $config
*/
public function __construct($config = [])
{
$this->categorias = Categorias::find()->with(['articulos' => function ($query) {
$query->andWhere(['in', 'estado', [Articulos::NUEVO, Articulos::USADO, Articulos::OFERTA, Articulos::RESERVADO]])->orderBy(['idarticulo' => SORT_DESC]);
}])->activas()->all();
parent::__construct($config);
}
示例6: __construct
/**
* @param Mailer $mailer
* @param Finder $finder
* @param array $config
*/
public function __construct(Mailer $mailer, Finder $finder, $config = [])
{
$this->module = \Yii::$app->getModule('user');
$this->mailer = $mailer;
$this->finder = $finder;
parent::__construct($config);
}
示例7: __construct
/**
* @param integer|null $item_id
*/
public function __construct($item_id = null)
{
parent::__construct();
if ($item_id) {
/** @var $poll PollRecord */
$poll = PollRecord::findOne($item_id);
$this->item_id = $poll->id;
$this->language_id = $poll->language_id;
$this->question = $poll->question;
$this->end_date = $poll->end_date ? Yii::$app->formatter->asDate($poll->end_date, 'dd.MM.y') : null;
if ($poll->active) {
$this->boxes[] = self::PROPERTY_ACTIVE;
}
if ($poll->main) {
$this->boxes[] = self::PROPERTY_MAIN;
}
foreach ($poll->answers as $pollAnswer) {
$this->answers[] = $pollAnswer->answer;
}
$voices = PollAnswerRecord::find()->where(['poll_id' => $poll->id])->andWhere('voices>0')->count();
$this->isAnswersEditable = !$voices;
} else {
$session = Yii::$app->session;
if (!$session['language_id']) {
$session['language_id'] = LanguageRecord::getMainLanguageId();
}
$this->language_id = $session['language_id'];
$this->boxes[] = self::PROPERTY_ACTIVE;
$this->answers[1] = $this->answers[0] = '';
$this->isAnswersEditable = true;
}
}
示例8: __construct
/**
* @param array $config
* @param bool $item
*/
public function __construct($config = [], $item = false)
{
parent::__construct($config);
if ($item) {
$this->attributes = $item;
}
}
示例9: __construct
/** @inheritdoc */
public function __construct(Mailer $mailer, $config = [])
{
$this->mailer = $mailer;
$this->module = \Yii::$app->getModule('user');
$this->setAttributes(['username' => $this->user->username, 'email' => $this->user->email, 'tagline' => $this->user->tagline, 'display_name' => $this->user->display_name], false);
parent::__construct($config);
}
示例10: __construct
/** @inheritdoc */
public function __construct(Mailer $mailer, $config = [])
{
$this->mailer = $mailer;
$this->module = Yii::$app->getModule('user');
$this->setAttributes(['username' => $this->user->username, 'email' => $this->user->unconfirmed_email ?: $this->user->email], false);
parent::__construct($config);
}
示例11: __construct
/**
* Creates a form model given a token.
*
* @param int $id The user ID.
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public function __construct($id, $config = [])
{
// Volunteer can be new or have an existing entry.
$this->_volunteer = Volunteer::findOne($id);
if (!$this->_volunteer) {
$this->_volunteer = new Volunteer();
$this->_volunteer->accountID = $id;
} else {
// Initialise form values.
foreach ($this::$interestBits as $key => $value) {
if ($key & $this->_volunteer->interests) {
$this->interests[] = $key;
}
}
foreach ($this::$availabilityBits as $key => $value) {
if ($key & $this->_volunteer->availability) {
$this->availability[] = $key;
}
if ($key & $this->_volunteer->experience) {
$this->experience[] = $key;
}
}
$this->daysAvailable = $this->_volunteer->daysAvailable;
$this->skills = $this->_volunteer->skills;
$this->mobile = User::findOne($id)->details->mobile;
}
parent::__construct($config);
}
示例12: __construct
/**
* @inheritdoc
*/
public function __construct(Posts $postModel, $config = [])
{
$this->postModel = $postModel;
$this->setAttributes($this->postModel->getAttributes(['title', 'description', 'file', 'category_id', 'author_id', 'create_date']));
$this->tags = ArrayHelper::map($postModel->tagPost, 'name', 'name');
parent::__construct($config);
}
示例13: __construct
/**
* PageForm constructor
* @param integer|null $item_id
*/
public function __construct($item_id = null)
{
parent::__construct();
if ($item_id) {
/** @var $page Page */
$page = Page::findOne($item_id);
$this->item_id = $page->id;
$this->language_id = $page->language_id;
if ($page->image) {
$this->imageFilename = $page->image->filename;
}
$this->perex = $page->perex;
$this->title = $page->title;
$this->description = $page->description;
if ($page->active) {
$this->boxes[] = self::PROPERTY_ACTIVE;
}
if ($page->public) {
$this->boxes[] = self::PROPERTY_PUBLIC;
}
$this->tagValues = $page->tagValues;
} else {
$session = Yii::$app->session;
if (!$session['language_id']) {
$session['language_id'] = LanguageRecord::getMainLanguageId();
}
$this->language_id = $session['language_id'];
$this->boxes[] = self::PROPERTY_ACTIVE;
$this->boxes[] = self::PROPERTY_PUBLIC;
}
}
示例14: __construct
public function __construct(ActionsRecord $model, $config = [])
{
$this->_model = $model;
if ($this->objects !== false && isset($config['objects']) && is_string($config['objects'])) {
$config['objects'] = preg_split('/,\\s*/', $config['objects']);
}
parent::__construct($config);
}
示例15: __construct
/**
* Creates a form model given a token.
*
* @param array $config name-value pairs that will be used to initialize the object properties
* @throws \yii\base\InvalidParamException if token is empty or not valid
*/
public function __construct($config = [])
{
$this->_user = User::thisUser();
if (!$this->_user) {
throw new InvalidParamException('Wrong password reset token.');
}
parent::__construct($config);
}