Bristol SU Support Package
RoleFilter.php
Go to the documentation of this file.
1 <?php
2 
3 
5 
7 
11 abstract class RoleFilter extends Filter
12 {
13 
19  private $role;
20 
29  public function setModel($model)
30  {
31  if (!($model instanceof Role)) {
32  throw new \Exception(
33  sprintf('Cannot pass a class of type [%s] to a role filter', get_class($model))
34  );
35  }
36  $this->role = $model;
37  }
38 
44  public function hasModel(): bool
45  {
46  return $this->role !== null;
47  }
48 
54  public function model()
55  {
56  return $this->role;
57  }
58 
64  public function role()
65  {
66  return $this->model();
67  }
68 
69 }