| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 33 | public function create(string $resourceClass): ResourceMetadata |
||
| 34 | { |
||
| 35 | $resourceMetadata = $this->decorated->create($resourceClass); |
||
| 36 | |||
| 37 | $refl = new \ReflectionClass($resourceClass); |
||
| 38 | if (!$refl->implementsInterface(RoutableInterface::class)) { |
||
| 39 | return $resourceMetadata; |
||
| 40 | } |
||
| 41 | |||
| 42 | $itemOps = $resourceMetadata->getItemOperations(); |
||
| 43 | foreach ($itemOps as $name => $config) { |
||
| 44 | if ($config['security'] ?? null) { |
||
| 45 | continue; |
||
| 46 | } |
||
| 47 | $itemOps[$name]['security'] = sprintf("is_granted('%s', object)", AbstractRoutableVoter::READ_ROUTABLE); |
||
| 48 | } |
||
| 49 | |||
| 50 | return $resourceMetadata->withItemOperations($itemOps); |
||
|
|
|||
| 51 | } |
||
| 53 |