当前位置: 首页>>代码示例>>PHP>>正文


PHP ActiveRecord::afterSave方法代码示例

本文整理汇总了PHP中yii\db\ActiveRecord::afterSave方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecord::afterSave方法的具体用法?PHP ActiveRecord::afterSave怎么用?PHP ActiveRecord::afterSave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yii\db\ActiveRecord的用法示例。


在下文中一共展示了ActiveRecord::afterSave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     $this->preview_input = UploadedFile::getInstance($this, 'preview_input');
     if (!empty($this->preview_input)) {
         $this->preview_input->saveAs($this->preview_picture);
     }
     parent::afterSave($insert, $changedAttributes);
 }
开发者ID:amarchenkov,项目名称:myCMS,代码行数:8,代码来源:Article.php

示例2: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     if ($insert === true) {
         Siteinfo::updateCounterInfo('addNode');
     }
     return parent::afterSave($insert, $changedAttributes);
 }
开发者ID:feijilei,项目名称:simpleforum,代码行数:7,代码来源:Node.php

示例3: afterSave

 /**
  * —охран¤ем данные в кеш
  * @param bool $insert
  * @param array $changedAttributes
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     //$command = new SaveInCache();
     //$command->setData($this->attributes)
     //    ->execute();
 }
开发者ID:axiles89,项目名称:amop,代码行数:12,代码来源:ListProfiler.php

示例4: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     //  die;
     /* $priority range low =1 normal =2 high=3*/
     //background($name, $data = null, $priority = self::NORMAL, $unique = null)
     Yii::$app->gearman->getDispatcher()->background('mailJob', new JobWorkload(['params' => ['data' => $this->id]]), $this->priority);
 }
开发者ID:hokunor,项目名称:simple-yii-rest-mail,代码行数:8,代码来源:MailGearman.php

示例5: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     //$oldCategorias = array("0"=>1);
     $actualAssignments = [];
     if (($actualAssignments = AuthAssignment::find()->andWhere("user_id = {$this->id}")->asArray()->all()) !== null) {
         $actualAssignments = ArrayHelper::getColumn($actualAssignments, 'item_name');
     }
     //verifica se é um array
     $this->assignmentIds = is_array($this->assignmentIds) ? $this->assignmentIds : [$this->assignmentIds];
     $inserirAssignments = array_diff($this->assignmentIds, $actualAssignments);
     if (!empty($inserirAssignments)) {
         //save the relations
         foreach ($inserirAssignments as $id) {
             $r = new AuthAssignment();
             $r->user_id = $this->id;
             $r->item_name = $id;
             $r->save();
         }
     }
     $delAssignments = array_diff($actualAssignments, $this->assignmentIds);
     if (!empty($delAssignments)) {
         foreach ($delAssignments as $remove) {
             $r = AuthAssignment::findOne(['item_name' => $remove, 'user_id' => $this->id]);
             $r->delete();
         }
     }
     parent::afterSave($insert, $changedAttributes);
     //don't forget this
 }
开发者ID:bemficagama,项目名称:supletivo,代码行数:29,代码来源:User.php

示例6: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($insert) {
         $this->getProvince();
     }
 }
开发者ID:noikiy,项目名称:wowewe,代码行数:7,代码来源:OpenidBindMobile.php

示例7: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     //$oldCategorias = array("0"=>1);
     $actualItens = [];
     if (($actualItens = AuthItemChild::find()->andWhere("parent = '{$this->name}'")->asArray()->all()) !== null) {
         $actualItens = ArrayHelper::getColumn($actualItens, 'child');
     }
     //verifica se é um array
     $this->itemIds = is_array($this->itemIds) ? $this->itemIds : [$this->itemIds];
     $inserirItens = array_diff($this->itemIds, $actualItens);
     if (!empty($inserirItens)) {
         //save the relations
         foreach ($inserirItens as $id) {
             $r = new AuthItemChild();
             $r->parent = $this->name;
             $r->child = $id;
             $r->save();
         }
     }
     $delItens = array_diff($actualItens, $this->itemIds);
     if (!empty($delItens)) {
         foreach ($delItens as $remove) {
             $r = AuthItemChild::findOne(['child' => $remove, 'parent' => $this->name]);
             $r->delete();
         }
     }
     parent::afterSave($insert, $changedAttributes);
     //don't forget this
 }
开发者ID:bemficagama,项目名称:supletivo,代码行数:29,代码来源:AuthItem.php

示例8: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if ($this->value == '') {
         $this->delete();
     }
 }
开发者ID:devbrom,项目名称:yii2-releases,代码行数:7,代码来源:ExtraField.php

示例9: afterSave

 /**
  * @inheritdoc
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     $domain = preg_split("/\r\n/isU", trim($this->domain_txt));
     $site_id = $this->getPrimaryKey();
     $domains = Domain::find()->where(['site_id' => $site_id])->all();
     foreach ($domain as $key => $dm) {
         $dm = trim($dm);
         if (empty($dm)) {
             continue;
         }
         $domain_model = $this->findModelByDomain($domains, $dm);
         if (!isset($domain_model)) {
             $domain_model = new Domain();
         }
         if ($key === 0) {
             $domain_model->main = 1;
         } else {
             $domain_model->main = 0;
         }
         $domain_model->domain = $dm;
         $domain_model->site_id = $this->id;
         $domain_model->save();
     }
 }
开发者ID:jackieit,项目名称:aimocms,代码行数:28,代码来源:Site.php

示例10: afterSave

 /**
  * @inheritdoc
  */
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     // if onSite was changed in the form
     if ($this->onSite == empty($this->travel)) {
         if ($this->onSite) {
             $this->link('travel', new Travel());
         } else {
             $this->unlink('travel', $this->travel, true);
         }
     }
     // compile an array with [note_id => ticket_id] for each ticket currently attached
     $note_to_ticket = ArrayHelper::map($this->notes, 'id', 'ticket_id');
     // are we updating an existing event?
     if (!$insert) {
         // get a list of all tickets that need to be removed from event
         $removeNotes = array_keys(array_diff($note_to_ticket, $this->ticketIds));
         Note::deleteAll(['id' => $removeNotes, 'author_id' => null]);
         Labor::deleteAll(['schedule_id' => $this->id, 'note_id' => $removeNotes, 'hours' => null]);
     }
     // get a list of all the tickets to add and attach them to the event
     foreach (array_diff($this->ticketIds, $note_to_ticket) as $ticket_id) {
         $note = new Note(['scenario' => Note::SCENARIO_SCHEDULE, 'ticket_id' => $ticket_id]);
         $note->save(false);
         $this->link('notes', $note);
         // update the ticket status if still submitted
         if ($note->ticket->status_id == Ticket::STATUS_SUBMITTED) {
             $note->ticket->status_id = Ticket::STATUS_IN_PROGRESS;
             $note->ticket->save(false);
         }
     }
 }
开发者ID:jslight,项目名称:helpdesk,代码行数:35,代码来源:Schedule.php

示例11: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     if ($insert) {
         AttachmentFile::updateAll(['status_id' => AttachmentFile::STATUS_PERMANENT], ['id' => $this->attachment_id]);
     }
     parent::afterSave($insert, $changedAttributes);
 }
开发者ID:artkost,项目名称:yii2-starter-kit,代码行数:7,代码来源:PageAttachment.php

示例12: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     if (isset($changedAttributes['is_active']) && $changedAttributes['is_active'] != self::FINISHED && $this->is_active == self::FINISHED) {
         News::updateAll(['archive' => News::ARCHIVE_TRUE], ['id_tournament' => $this->id_tournament]);
         //assigning Events for winners forecast
         Top3TeamsForecast::setEventForTournament($this->id_tournament);
         //adding additional points to the total points field of UserTournaments model
         $this->assignAdditionalPoints();
     }
     //if setting tournament back to active from finished, need to remove calculated additional points and clean additional forecast events
     if (isset($changedAttributes['is_active']) && $changedAttributes['is_active'] == self::FINISHED && $this->is_active == self::GOING) {
         //removing additional points to the total points field of UserTournaments model
         $this->removeAdditionalPoints();
         //assigning Events for winners forecast to NULL
         Top3TeamsForecast::clearEventForTournament($this->id_tournament);
     }
     if ($insert) {
         $news = new News();
         $news->scenario = 'send';
         $news->id_tournament = 0;
         $news->subject = 'Добавлен новый турнир';
         $news->body = "<p>Для прогноза доступен новый турнир {$this->tournament_name}, первый тур которого состоится " . date('d.m.y', $this->startsOn) . " </p>" . "<p>Вы также можете попробовать угадать призеров турнира и заработать дополнительные очки! Прогноз на призеров принимается до " . date('d.m.y', $this->wfDueTo) . " </p>" . "<p>Спешите принять участие! Зайдите в <strong>Профиль->Мои турниры</strong> чтобы начать делать прогнозы</p>";
         $news->save();
     }
 }
开发者ID:Andrewkha,项目名称:sportforecast,代码行数:26,代码来源:Tournaments.php

示例13: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     foreach ($this->order->items as $item) {
         $item->save();
     }
     return parent::afterSave($insert, $changedAttributes);
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:7,代码来源:OrderCode.php

示例14: afterSave

 public function afterSave($insert, $changedAttributes)
 {
     if ($insert) {
         // Да это новая запись (insert)
         $model = new LogReestr();
         $model->resstr = 'apteki';
         $model->id_resstr = $this->id;
         $model->address = $this->address;
         $model->ur_l_id = $this->ur_l_id;
         $model->action = 'insert';
         $model->user = Yii::$app->user->identity->id;
         $model->save();
     } else {
         // Нет, старая (update)
         $save = "";
         foreach ($changedAttributes as $change => $val) {
             if (trim($val) != trim($this->{$change})) {
                 $save .= $this->attributeLabels()[$change] . '[' . $val . '->' . $this->{$change} . "]\n";
             }
         }
         if ($save != "") {
             $model = new LogReestr();
             $model->resstr = 'apteki';
             $model->id_resstr = $this->id;
             $model->address = $this->address;
             $model->ur_l_id = $this->ur_l_id;
             $model->action = 'update';
             $model->change = $save;
             $model->user = Yii::$app->user->identity->id;
             $model->save();
         }
     }
     parent::afterSave($insert, $changedAttributes);
 }
开发者ID:pumi11,项目名称:aau,代码行数:34,代码来源:Apteki.php

示例15: afterSave

 /**
  * @inheritdoc
  */
 public function afterSave($insert, $changedAttributes)
 {
     if ($this->default) {
         $this->setLanguageDefault();
     }
     parent::afterSave($insert, $changedAttributes);
 }
开发者ID:radiata-cms,项目名称:radiata,代码行数:10,代码来源:Lang.php


注:本文中的yii\db\ActiveRecord::afterSave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。