57 $row = $this->db->getDataRow($select);
59 return $row ? new \ElggRiverItem($row) : null;
75 if (!empty($item->view) && !$this->views->viewExists($item->view)) {
79 if (empty($item->action_type)) {
83 if (empty($item->subject_guid) || !$this->entityTable->exists($item->subject_guid)) {
87 if (empty($item->object_guid) || !$this->entityTable->exists($item->object_guid)) {
91 if (!empty($item->target_guid) && !$this->entityTable->exists($item->target_guid)) {
95 if (!empty($item->annotation_id) && !$this->annotationsTable->get($item->annotation_id)) {
99 $created = $item->posted ?: $this->
getCurrentTime()->getTimestamp();
101 if (!$this->events->triggerBefore(
'create',
'river', $item)) {
109 'subject_guid' => $insert->param($item->subject_guid,
ELGG_VALUE_GUID),
111 'target_guid' => $insert->param($item->target_guid ?? 0,
ELGG_VALUE_GUID),
112 'annotation_id' => $insert->param($item->annotation_id ?? 0,
ELGG_VALUE_ID),
117 $id = $this->db->insertData($insert);
123 $item->posted = $created;
124 $item->last_action = $created;
126 $this->events->triggerAfter(
'create',
'river', $item);
143 if (!$this->events->triggerBefore(
'delete',
'river',
$item)) {
152 $this->events->triggerAfter(
'delete',
'river',
$item);
166 if ($last_action === null) {
172 ->where($update->compare(
'id',
'=', $item->id,
ELGG_VALUE_ID));
174 $this->db->updateData($update);
176 return (
int) $last_action;
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
create(\ElggRiverItem $item)
Save a river item to the database.
__construct(protected Database $db, protected AnnotationsTable $annotationsTable, protected EntityTable $entityTable, protected EventsService $events, protected ViewsService $views)
Create the river table service.
trait TimeUsing
Adds methods for setting the current time (for testing)
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
getCurrentTime($modifier= '')
Get the (cloned) time.
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given 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(string $table, string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
Interfaces with the database to perform CRUD operations on annotations.
River table database action.
$id
Generic annotation delete action.
Entity table database service.