1 | <?php |
||
17 | class Admin extends App implements MiddlewareInterface |
||
18 | { |
||
19 | private $entities = []; |
||
20 | |||
21 | public $title = 'Folk'; |
||
22 | public $description = 'Universal CMS'; |
||
23 | |||
24 | public function __construct($path, UriInterface $uri) |
||
33 | |||
34 | /** |
||
35 | * Use the app as a middleware component. |
||
36 | * |
||
37 | * @param ServerRequestInterface $request |
||
38 | * @param DelegateInterface $delegate |
||
39 | * |
||
40 | * @return ResponseInterface |
||
41 | */ |
||
42 | public function process(ServerRequestInterface $request, DelegateInterface $delegate) |
||
46 | |||
47 | /** |
||
48 | * @return ResponseInterface |
||
49 | */ |
||
50 | public function __invoke(ServerRequestInterface $request): ResponseInterface |
||
56 | |||
57 | public function getRoute(string $name, array $data = [], array $query = null): string |
||
61 | |||
62 | /** |
||
63 | * Set the admin entities. |
||
64 | * |
||
65 | * @param array $entities |
||
66 | */ |
||
67 | public function setEntities(array $entities) |
||
77 | |||
78 | /** |
||
79 | * Add a new entity. |
||
80 | * |
||
81 | * @param EntityInterface $entity |
||
82 | * @param string|null $id |
||
83 | */ |
||
84 | public function addEntity(EntityInterface $entity, $id = null) |
||
94 | |||
95 | /** |
||
96 | * Return whether an entity exists. |
||
97 | * |
||
98 | * @param string $name |
||
99 | * |
||
100 | * @return bool |
||
101 | */ |
||
102 | public function hasEntity(string $name): bool |
||
106 | |||
107 | /** |
||
108 | * Return the entity id. |
||
109 | * |
||
110 | * @param string $name |
||
111 | * |
||
112 | * @return mixed|null |
||
113 | */ |
||
114 | public function getEntityId(string $name) |
||
120 | |||
121 | /** |
||
122 | * Return an entity. |
||
123 | * |
||
124 | * @param string $name |
||
125 | * |
||
126 | * @throw NotFoundException |
||
127 | * |
||
128 | * @return EntityInterface |
||
129 | */ |
||
130 | public function getEntity(string $name): EntityInterface |
||
138 | |||
139 | /** |
||
140 | * Return all entities. |
||
141 | * |
||
142 | * @return array |
||
143 | */ |
||
144 | public function getAllEntities(): array |
||
148 | } |
||
149 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: