1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kami\ApiCoreBundle\RequestProcessor\Step\Create; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Annotations\Reader; |
6
|
|
|
use Kami\ApiCoreBundle\Annotation\Form; |
7
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\AbstractBuildFormStep; |
8
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\GetEntityFromReflectionStep; |
|
|
|
|
9
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\GetReflectionFromRequestStep; |
10
|
|
|
use Kami\ApiCoreBundle\RequestProcessor\Step\Common\ValidateResourceAccessStep; |
11
|
|
|
use Kami\ApiCoreBundle\Security\AccessManager; |
12
|
|
|
use Symfony\Component\Form\FormFactory; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
class BuildCreateFormStep extends AbstractBuildFormStep |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* @var FormFactory |
19
|
|
|
*/ |
20
|
|
|
protected $formFactory; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var AccessManager |
24
|
|
|
*/ |
25
|
|
|
protected $accessManager; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var Reader |
29
|
|
|
*/ |
30
|
|
|
protected $reader; |
31
|
|
|
|
32
|
|
|
public function execute() |
33
|
|
|
{ |
34
|
|
|
$builder = $this->getBaseFormBuilder(); |
35
|
|
|
/** @var \ReflectionClass $reflection */ |
36
|
|
|
$reflection = $this->getFromResponse('reflection'); |
37
|
|
|
|
38
|
|
|
foreach ($reflection->getProperties() as $property) { |
39
|
|
|
if ($this->accessManager->canCreateProperty($property)) { |
40
|
|
|
if($annotation = $this->reader->getPropertyAnnotation($property, Form::class)) { |
41
|
|
|
$builder->add($property->getName(), $annotation->type, $annotation->options); |
42
|
|
|
} |
43
|
|
|
$builder->add($property->getName()); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
return $this->createResponse(['form' => $builder->getForm()]); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
public function requiresBefore() |
52
|
|
|
{ |
53
|
|
|
return [ |
54
|
|
|
ValidateResourceAccessStep::class, |
55
|
|
|
GetEntityFromReflectionStep::class, |
56
|
|
|
GetReflectionFromRequestStep::class |
57
|
|
|
]; |
58
|
|
|
} |
59
|
|
|
} |
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