64 $row = $this->db->getDataRow($select);
66 return $row ? new \ElggRiverItem($row) : null;
82 if (!empty($item->view) && !$this->views->viewExists($item->view)) {
86 if (empty($item->action_type)) {
90 if (empty($item->subject_guid) || !$this->entityTable->exists($item->subject_guid)) {
94 if (empty($item->object_guid) || !$this->entityTable->exists($item->object_guid)) {
98 if (!empty($item->target_guid) && !$this->entityTable->exists($item->target_guid)) {
102 if (!empty($item->annotation_id) && !$this->annotationsTable->get($item->annotation_id)) {
106 $created = $item->posted ?: $this->
getCurrentTime()->getTimestamp();
108 if (!$this->events->triggerBefore(
'create',
'river', $item)) {
116 'subject_guid' => $insert->param($item->subject_guid,
ELGG_VALUE_GUID),
118 'target_guid' => $insert->param($item->target_guid ?? 0,
ELGG_VALUE_GUID),
119 'annotation_id' => $insert->param($item->annotation_id ?? 0,
ELGG_VALUE_ID),
124 $id = $this->db->insertData($insert);
130 $item->posted = $created;
131 $item->last_action = $created;
133 $this->events->triggerAfter(
'create',
'river', $item);
150 if (!$this->events->triggerBefore(
'delete',
'river',
$item)) {
159 $this->events->triggerAfter(
'delete',
'river',
$item);
173 if ($last_action === null) {
179 ->where($update->compare(
'id',
'=', $item->id,
ELGG_VALUE_ID));
181 $this->db->updateData($update);
183 return (
int) $last_action;
create(\ElggRiverItem $item)
Save a river item to the database.
static table($table, $alias=null)
{}
trait TimeUsing
Adds methods for setting the current time (for testing)
getCurrentTime($modifier= '')
Get the (cloned) time.
static intoTable($table)
{}
updateLastAction(\ElggRiverItem $item, int $last_action=null)
Update the last_action column in the river table for $item.
const ELGG_VALUE_TIMESTAMP
static fromTable($table, $alias=null)
{}
Interfaces with the database to perform CRUD operations on annotations.
River table database action.
__construct(Database $db, AnnotationsTable $annotationsTable, EntityTable $entityTable, EventsService $events, ViewsService $views)
Create the river table service.
$id
Generic annotation delete action.
static fromTable($table, $alias=null)
{}
AnnotationsTable $annotationsTable
Entity table database service.