1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- abstract class SiteNotificationFactory {
-
- public static function create($recipient, $message, $actor, $object = null) {
- $note = new SiteNotification();
- $note->owner_guid = $recipient->guid;
- $note->container_guid = $recipient->guid;
- $note->access_id = ACCESS_PRIVATE;
- $note->description = $message;
- if ($object) {
-
- switch ($object->getType()) {
- case 'annotation':
-
- $note->setURL($object->getEntity()->getURL());
- break;
- default:
- $note->setURL($object->getURL());
- }
- }
- $note->setRead(false);
- if ($note->save()) {
- $note->setActor($actor);
- return $note;
- } else {
- return null;
- }
- }
- }
|