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