Elgg  Version 6.1
RemoveFromAclHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Friends;
4 
11 
19  public function __invoke(\Elgg\Event $event) {
20  $relationship_object = $event->getObject();
21  if (!$relationship_object instanceof \ElggRelationship) {
22  return;
23  }
24 
25  if ($relationship_object->relationship !== 'friend') {
26  return;
27  }
28 
29  $user = get_user($relationship_object->guid_one);
30  $friend = get_user($relationship_object->guid_two);
31 
32  if (!$user || !$friend) {
33  return;
34  }
35 
36  $acl = $user->getOwnedAccessCollection('friends');
37  if (empty($acl)) {
38  return;
39  }
40 
41  $acl->removeMember($friend->guid);
42  }
43 }
$user
Definition: ban.php:7
__invoke(\Elgg\Event $event)
Add the friend to the user friends ACL.
get_user(int $guid)
Elgg users Functions to manage multiple or single users in an Elgg install.
Definition: users.php:16
Models an event passed to event handlers.
Definition: Event.php:11