Bristol SU Support Package
ActionManager.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use BristolSU\Support\Action\Contracts\ActionManager as ActionManagerContract;
6 
12 class ActionManager implements ActionManagerContract
13 {
14 
25  protected $actions = [];
26 
36  public function registerAction(string $class, string $name, string $description): void
37  {
38  $this->actions[$class] = [
39  'name' => $name,
40  'class' => $class,
41  'description' => $description
42  ];
43  }
44 
50  public function all(): array
51  {
52  return $this->actions;
53  }
54 
63  public function fromClass(string $class): array
64  {
65  if (!array_key_exists($class, $this->actions)) {
66  throw new \Exception(sprintf('Action [%s] not found', $class));
67  }
68  return $this->actions[$class];
69  }
70 
71 }
registerAction(string $class, string $name, string $description)