1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace LAG\AdminBundle\Metadata\Factory; |
6
|
|
|
|
7
|
|
|
use LAG\AdminBundle\Event\Events\ResourceEvent; |
|
|
|
|
8
|
|
|
use LAG\AdminBundle\Event\ResourceEvents; |
9
|
|
|
use LAG\AdminBundle\Exception\Exception; |
10
|
|
|
use LAG\AdminBundle\Metadata\AdminResource; |
11
|
|
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; |
12
|
|
|
|
13
|
|
|
class ResourceFactory implements ResourceFactoryInterface |
14
|
|
|
{ |
15
|
|
|
public function __construct( |
16
|
|
|
private EventDispatcherInterface $eventDispatcher, |
17
|
|
|
private OperationFactoryInterface $operationFactory, |
18
|
|
|
) { |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function create(AdminResource $definition): AdminResource |
22
|
|
|
{ |
23
|
|
|
$event = new ResourceEvent($definition); |
24
|
|
|
$this->eventDispatcher->dispatch($event, ResourceEvents::ADMIN_CREATE); |
|
|
|
|
25
|
|
|
$this->eventDispatcher->dispatch($event, sprintf(ResourceEvents::ADMIN_CREATE_PATTERN, $definition->getName())); |
|
|
|
|
26
|
|
|
$resource = $event->getResource(); |
27
|
|
|
$operations = []; |
28
|
|
|
|
29
|
|
|
foreach ($resource->getOperations() as $operationDefinition) { |
30
|
|
|
$operations[] = $this->operationFactory->create($resource, $operationDefinition->withResource($resource)); |
31
|
|
|
} |
32
|
|
|
$resource = $resource->withOperations($operations); |
33
|
|
|
$event = new ResourceEvent($resource); |
34
|
|
|
$this->eventDispatcher->dispatch($event, ResourceEvents::ADMIN_CREATED); |
|
|
|
|
35
|
|
|
$this->eventDispatcher->dispatch($event, sprintf(ResourceEvents::ADMIN_CREATED_PATTERN, $resource->getName())); |
|
|
|
|
36
|
|
|
|
37
|
|
|
if ($event->getResource()->getName() !== $definition->getName()) { |
38
|
|
|
throw new Exception(sprintf('The resource name "%s" to "%s" change is not allowed', $definition->getName(), $resource->getName())); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return $event->getResource(); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths