|
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
|
|
|
public function configurePipeline(): void |
|
23
|
|
|
{ |
|
24
|
|
|
parent::configurePipeline(); |
|
25
|
|
|
$this->registerReplaceEntitiesNamespaceProcess(); |
|
26
|
|
|
if (null !== $this->replaceIdFieldProcess) { |
|
27
|
|
|
$this->pipeline->register($this->replaceIdFieldProcess); |
|
28
|
|
|
} |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
private function registerReplaceEntitiesNamespaceProcess(): void |
|
32
|
|
|
{ |
|
33
|
|
|
$process = new ReplaceEntitiesSubNamespaceProcess(); |
|
34
|
|
|
$process->setProjectRootNamespace($this->projectRootNamespace); |
|
|
|
|
|
|
35
|
|
|
$process->setEntityFqn($this->newObjectFqn); |
|
|
|
|
|
|
36
|
|
|
$this->pipeline->register($process); |
|
37
|
|
|
} |
|
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
|
|
|
public function setReplaceIdFieldProcess(ReplaceEntityIdFieldProcess $replaceIdFieldProcess): EntityCreator |
|
47
|
|
|
{ |
|
48
|
|
|
$this->replaceIdFieldProcess = $replaceIdFieldProcess; |
|
49
|
|
|
|
|
50
|
|
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|