1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entities; |
4
|
|
|
|
5
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\AbstractCreator; |
6
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\CreatorInterface; |
7
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Process\ReplaceEntitiesSubNamespaceProcess; |
8
|
|
|
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Process\ReplaceEntityIdFieldProcess; |
9
|
|
|
|
10
|
|
|
class EntityCreator extends AbstractCreator |
11
|
|
|
{ |
12
|
|
|
public const FIND_NAME = 'TemplateEntity'; |
13
|
|
|
|
14
|
|
|
public const TEMPLATE_PATH = self::ROOT_TEMPLATE_PATH . '/' . CreatorInterface::SRC_FOLDER . '/Entities/' |
15
|
|
|
. self::FIND_NAME . '.php'; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var ReplaceEntityIdFieldProcess|null |
19
|
|
|
*/ |
20
|
|
|
private $replaceIdFieldProcess; |
21
|
|
|
|
22
|
3 |
|
public function configurePipeline(): void |
23
|
|
|
{ |
24
|
3 |
|
parent::configurePipeline(); |
25
|
3 |
|
$this->registerReplaceEntitiesNamespaceProcess(); |
26
|
3 |
|
if (null !== $this->replaceIdFieldProcess) { |
27
|
1 |
|
$this->pipeline->register($this->replaceIdFieldProcess); |
28
|
|
|
} |
29
|
3 |
|
} |
30
|
|
|
|
31
|
3 |
|
private function registerReplaceEntitiesNamespaceProcess(): void |
32
|
|
|
{ |
33
|
3 |
|
$process = new ReplaceEntitiesSubNamespaceProcess(); |
34
|
3 |
|
$process->setEntityFqn($this->newObjectFqn); |
35
|
3 |
|
$this->pipeline->register($process); |
36
|
3 |
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* If you want to replace the ID field, you must set a preconfigured replace process object using this method |
40
|
|
|
* |
41
|
|
|
* @param ReplaceEntityIdFieldProcess $replaceIdFieldProcess |
42
|
|
|
* |
43
|
|
|
* @return EntityCreator |
44
|
|
|
*/ |
45
|
1 |
|
public function setReplaceIdFieldProcess(ReplaceEntityIdFieldProcess $replaceIdFieldProcess): EntityCreator |
46
|
|
|
{ |
47
|
1 |
|
$this->replaceIdFieldProcess = $replaceIdFieldProcess; |
48
|
|
|
|
49
|
1 |
|
return $this; |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|