Elgg  Version master
Tools.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Groups;
4 
7 
13 class Tools {
14 
18  protected $tools;
19 
25  public function __construct(protected EventsService $events) {
26  $this->tools = new Collection([], Tool::class);
27  }
28 
42  public function register($name, array $options = []) {
43  $tool = new Tool($name, $options);
44 
45  $this->tools->add($tool);
46  }
47 
55  public function unregister($name) {
56  $this->tools->remove($name);
57  }
58 
65  public function get($name) {
66  return $this->all()->get($name);
67  }
68 
74  public function all() {
75  $tool_options = clone $this->tools;
76 
77  return $this->events->triggerResults('tool_options', 'group', [], $tool_options);
78  }
79 
87  public function group(\ElggGroup $group) {
88 
89  $tool_options = clone $this->tools;
90 
91  $params = [
92  'entity' => $group,
93  ];
94 
95  return $this->events->triggerResults('tool_options', 'group', $params, $tool_options);
96  }
97 }
if(!elgg_get_config('trash_enabled')) $group
Definition: group.php:13
A collection of unique items.
Definition: Collection.php:11
$params
Saves global plugin settings.
Definition: save.php:13
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
Events service.
Group tools service.
Definition: Tools.php:13
group(\ElggGroup $group)
Returns group specific tools.
Definition: Tools.php:87
if($who_can_change_language=== 'nobody') elseif($who_can_change_language=== 'admin_only'&&!elgg_is_admin_logged_in()) $options
Definition: language.php:20
all()
Returns registered tools.
Definition: Tools.php:74
__construct(protected EventsService $events)
Constructor.
Definition: Tools.php:25
unregister($name)
Removes a group tool.
Definition: Tools.php:55