|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace LAG\AdminBundle\Metadata\Factory; |
|
6
|
|
|
|
|
7
|
|
|
use LAG\AdminBundle\Event\Events\OperationEvent; |
|
|
|
|
|
|
8
|
|
|
use LAG\AdminBundle\Event\OperationEvents; |
|
9
|
|
|
use LAG\AdminBundle\Filter\Factory\FilterFactoryInterface; |
|
10
|
|
|
use LAG\AdminBundle\Metadata\AdminResource; |
|
11
|
|
|
use LAG\AdminBundle\Metadata\CollectionOperationInterface; |
|
12
|
|
|
use LAG\AdminBundle\Metadata\OperationInterface; |
|
13
|
|
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; |
|
14
|
|
|
|
|
15
|
|
|
class OperationFactory implements OperationFactoryInterface |
|
16
|
|
|
{ |
|
17
|
|
|
public function __construct( |
|
18
|
|
|
private EventDispatcherInterface $eventDispatcher, |
|
19
|
|
|
private PropertyFactoryInterface $propertyFactory, |
|
20
|
|
|
private FilterFactoryInterface $filterFactory, |
|
21
|
|
|
) { |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function create(AdminResource $resource, OperationInterface $operationDefinition): OperationInterface |
|
25
|
|
|
{ |
|
26
|
|
|
$operationDefinition = $operationDefinition |
|
27
|
|
|
->withResource($resource) |
|
28
|
|
|
; |
|
29
|
|
|
$event = new OperationEvent($operationDefinition); |
|
30
|
|
|
$this->eventDispatcher->dispatch($event, OperationEvents::OPERATION_CREATE); |
|
|
|
|
|
|
31
|
|
|
$this->eventDispatcher->dispatch($event, sprintf( |
|
32
|
|
|
OperationEvents::OPERATION_CREATE_PATTERN, |
|
|
|
|
|
|
33
|
|
|
$resource->getName(), |
|
34
|
|
|
$operationDefinition->getName(), |
|
35
|
|
|
)); |
|
36
|
|
|
$properties = []; |
|
37
|
|
|
$operation = $event->getOperation(); |
|
38
|
|
|
|
|
39
|
|
|
foreach ($operation->getProperties() as $property) { |
|
40
|
|
|
$properties[] = $this->propertyFactory->create($property); |
|
41
|
|
|
} |
|
42
|
|
|
$operation = $operation->withProperties($properties); |
|
43
|
|
|
|
|
44
|
|
|
if ($operation instanceof CollectionOperationInterface) { |
|
45
|
|
|
$filters = []; |
|
46
|
|
|
|
|
47
|
|
|
foreach ($operation->getFilters() ?? [] as $filter) { |
|
48
|
|
|
$filters[] = $this->filterFactory->create($filter); |
|
49
|
|
|
} |
|
50
|
|
|
$operation = $operation->withFilters($filters); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$event = new OperationEvent($operation); |
|
54
|
|
|
$this->eventDispatcher->dispatch($event, OperationEvents::OPERATION_CREATED); |
|
|
|
|
|
|
55
|
|
|
$this->eventDispatcher->dispatch($event, sprintf( |
|
56
|
|
|
OperationEvents::OPERATION_CREATED_PATTERN, |
|
|
|
|
|
|
57
|
|
|
$resource->getName(), |
|
58
|
|
|
$operation->getName(), |
|
59
|
|
|
)); |
|
60
|
|
|
|
|
61
|
|
|
// Ensure the operation belongs to the right resource |
|
62
|
|
|
return $event |
|
63
|
|
|
->getOperation() |
|
64
|
|
|
->withResource($resource) |
|
65
|
|
|
; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
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