|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of FlexPHP. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Freddie Gar <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace FlexPHP\Generator\Domain\Builders\Template; |
|
11
|
|
|
|
|
12
|
|
|
use FlexPHP\Generator\Domain\Builders\AbstractBuilder; |
|
13
|
|
|
use FlexPHP\Inputs\Builder\InputBuilder; |
|
|
|
|
|
|
14
|
|
|
use FlexPHP\Schema\Constants\Keyword; |
|
15
|
|
|
use Jawira\CaseConverter\Convert; |
|
16
|
|
|
|
|
17
|
|
|
final class TemplateBuilder extends AbstractBuilder |
|
18
|
|
|
{ |
|
19
|
|
|
private $action; |
|
20
|
|
|
|
|
21
|
|
|
public function __construct(string $entity, string $action, array $properties) |
|
22
|
|
|
{ |
|
23
|
|
|
$this->action = $action; |
|
24
|
|
|
|
|
25
|
|
|
$name = $this->getPascalCase($this->getSingularize($entity)); |
|
26
|
|
|
$entity = $this->getPascalCase($this->getPluralize($entity)); |
|
27
|
|
|
$route = $this->getDashCase($entity); |
|
28
|
|
|
$item = $this->getCamelCase($this->getSingularize($entity)); |
|
29
|
|
|
$headers = \array_reduce($properties, function (array $result, array $property) { |
|
30
|
|
|
$result[] = (new Convert($property[Keyword::NAME]))->toTitle(); |
|
31
|
|
|
|
|
32
|
|
|
return $result; |
|
33
|
|
|
}, []); |
|
34
|
|
|
|
|
35
|
|
|
$properties = \array_reduce($properties, function (array $result, array $property) { |
|
36
|
|
|
$result[$this->getCamelCase($property[Keyword::NAME])] = $property; |
|
37
|
|
|
|
|
38
|
|
|
return $result; |
|
39
|
|
|
}, []); |
|
40
|
|
|
|
|
41
|
|
|
parent::__construct(\compact('name', 'entity', 'route', 'item', 'headers', 'properties')); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
protected function getFileTemplate(): string |
|
45
|
|
|
{ |
|
46
|
|
|
return $this->action . '.html.twig'; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
protected function getPathTemplate(): string |
|
50
|
|
|
{ |
|
51
|
|
|
return \sprintf('%1$s/Symfony/v43/templates', parent::getPathTemplate()); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
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