Elgg  Version master
UpdateRiverLastActionHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Comments;
4 
11 
19  public function __invoke(\Elgg\Event $event) {
20  $item = $event->getObject();
21  if (!$item instanceof \ElggRiverItem) {
22  return;
23  }
24 
25  $object = $item->getObjectEntity();
26  if (!$object instanceof \ElggComment || $item->action_type !== 'comment') {
27  return;
28  }
29 
30  // find create river and update the river item
31  $river = elgg_get_river([
32  'object_guid' => $item->target_guid,
33  'action' => 'create',
34  'limit' => 1,
35  ]);
36  if (empty($river)) {
37  return;
38  }
39 
40  $old_item = $river[0];
41  $old_item->updateLastAction($item->getTimePosted());
42  }
43 }
if(!$items) $item
Definition: delete.php:13
elgg_get_river(array $options=[])
Get river items.
Definition: river.php:101
__invoke(\Elgg\Event $event)
Updates the last action of a related river item.
if($email instanceof\Elgg\Email) $object
Definition: body.php:24
Models an event passed to event handlers.
Definition: Event.php:11