Elgg  Version 3.0
Tools.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Groups;
4 
7 use ElggGroup;
8 
14 class Tools {
15 
19  protected $tools;
20 
24  protected $hooks;
25 
32  $this->tools = new Collection([], Tool::class);
33  $this->hooks = $hooks;
34  }
35 
49  public function register($name, array $options = []) {
50  $tool = new Tool($name, $options);
51 
52  $this->tools->add($tool);
53  }
54 
62  public function unregister($name) {
63  $this->tools->remove($name);
64  }
65 
72  public function get($name) {
73  return $this->tools->get($name);
74  }
75 
81  public function all() {
82  $tool_options = clone $this->tools;
83 
84  return $this->hooks->trigger('tool_options', 'group', [], $tool_options);
85  }
86 
94  public function group(ElggGroup $group) {
95 
96  $tool_options = clone $this->tools;
97 
98  $params = [
99  'entity' => $group,
100  ];
101 
102  return $this->hooks->trigger('tool_options', 'group', $params, $tool_options);
103  }
104 }
if(!$user||!$user->canDelete()) $name
Definition: delete.php:22
A collection of unique items.
Definition: Collection.php:14
$params
Saves global plugin settings.
Definition: save.php:13
Group tools service.
Definition: Tools.php:14
group(ElggGroup $group)
Returns group specific tools.
Definition: Tools.php:94
$options
Elgg admin footer.
Definition: footer.php:6
all()
Returns registered tools.
Definition: Tools.php:81
__construct(PluginHooksService $hooks)
Constructor.
Definition: Tools.php:31
class
Definition: placeholder.php:21
unregister($name)
Removes a group tool.
Definition: Tools.php:62