本文整理汇总了PHP中Participant::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Participant::setAttributes方法的具体用法?PHP Participant::setAttributes怎么用?PHP Participant::setAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Participant
的用法示例。
在下文中一共展示了Participant::setAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterSave
protected function afterSave($wasNew)
{
if (!$wasNew && $this->updateRelatedParticipants && $this->isModified('status')) {
$stmt = $this->getRelatedParticipants();
foreach ($stmt as $participant) {
$participant->updateRelatedParticipants = false;
//prevent endless loop. Because it will also process this aftersave
$participant->event->touch();
// Touch the event to update its mtime.
$participant->status = $this->status;
$participant->save();
}
//$this->event->touch(); // Touch the event to update the modification date.
}
if ($wasNew && $this->event->is_organizer) {
//add this participant to each existing event.
if (!$this->dontCreateEvent && $this->user_id > 0 && !$this->is_organizer) {
// if ($this->user_id > 0 && !$this->is_organizer) {
$newEvent = $this->event->createCopyForParticipant($this);
}
$stmt = $this->event->getRelatedParticipantEvents();
foreach ($stmt as $event) {
if (empty($newEvent) || $event->id != $newEvent->id) {
$p = Participant::model()->findSingleByAttributes(array('event_id' => $event->id, 'email' => $this->email));
if (!$p) {
$p = new Participant();
$p->setAttributes($this->getAttributes('raw'), false);
$p->event_id = $event->id;
$p->id = null;
$p->save();
}
}
}
if (!$this->is_organizer && $this->contact) {
$this->contact->link($this->event);
}
}
return parent::afterSave($wasNew);
}