123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- <?php
- class ElggRiverItem {
- public $id;
- public $subject_guid;
- public $object_guid;
- public $target_guid;
- public $annotation_id;
- public $type;
- public $subtype;
- public $action_type;
- public $access_id;
- public $view;
- public $posted;
- public $enabled;
-
- public function __construct($object) {
- if (!($object instanceof \stdClass)) {
- throw new \InvalidParameterException("Invalid input to \ElggRiverItem constructor");
- }
-
- $int_types = array('id', 'subject_guid', 'object_guid', 'target_guid', 'annotation_id', 'access_id', 'posted');
- foreach ($object as $key => $value) {
- if (in_array($key, $int_types)) {
- $this->$key = (int)$value;
- } else {
- $this->$key = $value;
- }
- }
- }
-
- public function getSubjectEntity() {
- return get_entity($this->subject_guid);
- }
-
- public function getObjectEntity() {
- return get_entity($this->object_guid);
- }
-
- public function getTargetEntity() {
- return get_entity($this->target_guid);
- }
-
- public function getAnnotation() {
- return elgg_get_annotation_from_id($this->annotation_id);
- }
-
- public function getView() {
- return $this->view;
- }
-
- public function getPostedTime() {
- elgg_deprecated_notice("\ElggRiverItem::getPostedTime() deprecated in favor of getTimePosted()", 1.9);
- return (int)$this->posted;
- }
-
- public function getTimePosted() {
- return (int)$this->posted;
- }
-
- public function getType() {
- return 'river';
- }
-
- public function getSubtype() {
- return 'item';
- }
-
- public function toObject() {
- $object = new \stdClass();
- $object->id = $this->id;
- $object->subject_guid = $this->subject_guid;
- $object->object_guid = $this->object_guid;
- $object->annotation_id = $this->annotation_id;
- $object->read_access = $this->access_id;
- $object->action = $this->action_type;
- $object->time_posted = date('c', $this->getTimePosted());
- $object->enabled = $this->enabled;
- $params = array('item' => $this);
- return _elgg_services()->hooks->trigger('to:object', 'river_item', $params, $object);
- }
- }
|