|
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
|
7 |
|
*/ |
|
10
|
|
|
namespace FlexPHP\Generator\Domain\Builders\Controller; |
|
11
|
7 |
|
|
|
12
|
|
|
use FlexPHP\Generator\Domain\Builders\AbstractBuilder; |
|
13
|
|
|
use FlexPHP\Schema\Constants\Action; |
|
14
|
7 |
|
use FlexPHP\Schema\SchemaInterface; |
|
15
|
|
|
|
|
16
|
7 |
|
final class ResponseMessageBuilder extends AbstractBuilder |
|
17
|
|
|
{ |
|
18
|
|
|
public function __construct(SchemaInterface $schema, string $action) |
|
19
|
7 |
|
{ |
|
20
|
|
|
$action = $this->getInflector()->camelAction($action); |
|
21
|
7 |
|
$entity = $this->getInflector()->entity($schema->name()); |
|
22
|
|
|
$item = $this->getInflector()->item($schema->name()); |
|
23
|
|
|
$items = $this->getInflector()->items($schema->name()); |
|
24
|
|
|
$templates = $item; |
|
25
|
|
|
$route = $this->getInflector()->route($schema->name()); |
|
26
|
|
|
$hasFilter = $schema->hasAction(Action::FILTER); |
|
27
|
|
|
|
|
28
|
|
|
parent::__construct(\compact('entity', 'route', 'action', 'item', 'items', 'templates', 'hasFilter')); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function build(): string |
|
32
|
|
|
{ |
|
33
|
|
|
return \rtrim(parent::build()); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
protected function getFileTemplate(): string |
|
37
|
|
|
{ |
|
38
|
|
|
return 'ResponseMessage.php.twig'; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
protected function getPathTemplate(): string |
|
42
|
|
|
{ |
|
43
|
|
|
return \sprintf('%1$s/Symfony/src/Controller', parent::getPathTemplate()); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|