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
|
6 |
|
public function configurePipeline(): void |
23
|
|
|
{ |
24
|
6 |
|
parent::configurePipeline(); |
25
|
6 |
|
$this->registerReplaceEntitiesNamespaceProcess(); |
26
|
6 |
|
if (null !== $this->replaceIdFieldProcess) { |
27
|
2 |
|
$this->pipeline->register($this->replaceIdFieldProcess); |
28
|
|
|
} |
29
|
6 |
|
} |
30
|
|
|
|
31
|
6 |
|
private function registerReplaceEntitiesNamespaceProcess(): void |
32
|
|
|
{ |
33
|
6 |
|
$process = new ReplaceEntitiesSubNamespaceProcess(); |
34
|
6 |
|
$process->setProjectRootNamespace($this->projectRootNamespace); |
|
|
|
|
35
|
6 |
|
$process->setEntityFqn($this->newObjectFqn); |
|
|
|
|
36
|
6 |
|
$this->pipeline->register($process); |
37
|
6 |
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* If you want to replace the ID field, you must set a preconfigured replace process object using this method |
41
|
|
|
* |
42
|
|
|
* @param ReplaceEntityIdFieldProcess $replaceIdFieldProcess |
43
|
|
|
* |
44
|
|
|
* @return EntityCreator |
45
|
|
|
*/ |
46
|
2 |
|
public function setReplaceIdFieldProcess(ReplaceEntityIdFieldProcess $replaceIdFieldProcess): EntityCreator |
47
|
|
|
{ |
48
|
2 |
|
$this->replaceIdFieldProcess = $replaceIdFieldProcess; |
49
|
|
|
|
50
|
2 |
|
return $this; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|