Example #1
0
 public function afterSave()
 {
     // Loop over each eall entry and make sure its update_at / update_by
     // will also updated. (Sorting wall against update)
     foreach ($this->getWallEntries() as $wallEntry) {
         $wallEntry->save();
     }
     // Handle user notifications by ContentFormWidget
     if ($this->isNewRecord) {
         foreach ($this->notifyUsersOfNewContent as $user) {
             // Fire Notification to user
             $notification = new Notification();
             $notification->class = "ContentCreatedNotification";
             $notification->user_id = $user->id;
             if (get_class($this->container) == 'Space') {
                 $notification->space_id = $this->container->id;
             }
             $notification->source_object_model = $this->object_model;
             $notification->source_object_id = $this->object_id;
             $notification->target_object_model = $this->object_model;
             $notification->target_object_id = $this->object_id;
             $notification->save();
         }
     }
     $this->updateInvolvedUsers();
     File::attachToContent($this, $this->attachFileGuidsAfterSave);
     return parent::afterSave();
 }