Elgg  Version 5.1
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 
23  protected $events;
24 
30  public function __construct(EventsService $events) {
31  $this->tools = new Collection([], Tool::class);
32  $this->events = $events;
33  }
34 
48  public function register($name, array $options = []) {
49  $tool = new Tool($name, $options);
50 
51  $this->tools->add($tool);
52  }
53 
61  public function unregister($name) {
62  $this->tools->remove($name);
63  }
64 
71  public function get($name) {
72  return $this->all()->get($name);
73  }
74 
80  public function all() {
81  $tool_options = clone $this->tools;
82 
83  return $this->events->triggerResults('tool_options', 'group', [], $tool_options);
84  }
85 
93  public function group(\ElggGroup $group) {
94 
95  $tool_options = clone $this->tools;
96 
97  $params = [
98  'entity' => $group,
99  ];
100 
101  return $this->events->triggerResults('tool_options', 'group', $params, $tool_options);
102  }
103 }
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:93
$options
Elgg admin footer.
Definition: footer.php:6
all()
Returns registered tools.
Definition: Tools.php:80
unregister($name)
Removes a group tool.
Definition: Tools.php:61
__construct(EventsService $events)
Constructor.
Definition: Tools.php:30