diff --git a/application/src/Domain/FormManagement/FormMeta.php b/application/src/Domain/FormManagement/FormMeta.php index 9ecba3f..d0630aa 100644 --- a/application/src/Domain/FormManagement/FormMeta.php +++ b/application/src/Domain/FormManagement/FormMeta.php @@ -3,14 +3,55 @@ namespace App\Domain\FormManagement; use App\Domain\SourceManagement\SourceMetaInterface; +use App\Domain\TemplateManagement\TemplateMetaInterface; +use App\Domain\TemplateManagement\TemplateMeta; +/** + * @author kevinfrantz + */ class FormMeta implements FormMetaInterface { - public function __construct(SourceMetaInterface $source) + const FOLDER = 'form'; + + /** + * @var SourceMetaInterface + */ + private $sourceMeta; + + /** + * @var TemplateMetaInterface + */ + private $templateMeta; + + /** + * @var string + */ + private $formClass; + + public function __construct(SourceMetaInterface $sourceMeta) { + $this->sourceMeta = $sourceMeta; + $this->setMeta(); + $this->setFormClass(); } - public function getFormPath(): string + private function setFormClass(): void { + $this->formClass = 'App\\Form\\'.implode('\\', $this->sourceMeta->getBasicPathArray()).'\\'.$this->sourceMeta->getBasicName().'Type'; + } + + private function setMeta(): void + { + $this->templateMeta = new TemplateMeta($this->sourceMeta->getBasicPathArray(), $this->sourceMeta->getBasicName(), self::FOLDER); + } + + public function getFormClass(): string + { + return $this->formClass; + } + + public function getTemplateMeta(): string + { + return $this->templateMeta; } } diff --git a/application/src/Domain/FormManagement/FormMetaInterface.php b/application/src/Domain/FormManagement/FormMetaInterface.php index f008d42..7f3352e 100644 --- a/application/src/Domain/FormManagement/FormMetaInterface.php +++ b/application/src/Domain/FormManagement/FormMetaInterface.php @@ -4,5 +4,7 @@ namespace App\Domain\FormManagement; interface FormMetaInterface { - public function getFormPath(): string; + public function getFormClass(): string; + + public function getTemplateMeta(): string; } diff --git a/application/src/Domain/SourceManagement/SourceMeta.php b/application/src/Domain/SourceManagement/SourceMeta.php index c249f95..8ad35c3 100644 --- a/application/src/Domain/SourceManagement/SourceMeta.php +++ b/application/src/Domain/SourceManagement/SourceMeta.php @@ -2,9 +2,11 @@ namespace App\Domain\SourceManagement; +use App\Domain\FormManagement\FormMetaInterface; use App\Domain\TemplateManagement\TemplateMetaInterface; use App\Entity\Source\SourceInterface; use App\Domain\TemplateManagement\TemplateMeta; +use App\Domain\FormManagement\FormMeta; /** * @author kevinfrantz @@ -41,6 +43,11 @@ class SourceMeta implements SourceMetaInterface */ private $source; + /** + * @var FormMetaInterface + */ + private $formMeta; + public function __construct(SourceInterface $source) { $this->source = $source; @@ -48,7 +55,8 @@ class SourceMeta implements SourceMetaInterface $this->setBasicPathArray(); $this->setBasicName(); $this->setInterfaceReflection(); - $this->templateMeta = new TemplateMeta($this); + $this->templateMeta = new TemplateMeta($this->basicPathArray, $this->basicName, 'entity'); + $this->formMeta = new FormMeta($this); } private function setBasicPathArray(): void @@ -103,4 +111,9 @@ class SourceMeta implements SourceMetaInterface { return $this->source; } + + public function getFormMeta(): FormMetaInterface + { + return $this->formMeta; + } } diff --git a/application/src/Domain/SourceManagement/SourceMetaInterface.php b/application/src/Domain/SourceManagement/SourceMetaInterface.php index 88a8706..99f0fe7 100644 --- a/application/src/Domain/SourceManagement/SourceMetaInterface.php +++ b/application/src/Domain/SourceManagement/SourceMetaInterface.php @@ -4,6 +4,7 @@ namespace App\Domain\SourceManagement; use App\Domain\TemplateManagement\TemplateMetaInterface; use App\Entity\Source\SourceInterface; +use App\Domain\FormManagement\FormMetaInterface; /** * A meta source offers informations, which the system needs to handle the source. @@ -32,4 +33,6 @@ interface SourceMetaInterface * @return SourceInterface The source to which the meta object belongs to */ public function getSource(): SourceInterface; + + public function getFormMeta(): FormMetaInterface; } diff --git a/application/src/Domain/TemplateManagement/TemplateMeta.php b/application/src/Domain/TemplateManagement/TemplateMeta.php index b0374d8..6f038a5 100644 --- a/application/src/Domain/TemplateManagement/TemplateMeta.php +++ b/application/src/Domain/TemplateManagement/TemplateMeta.php @@ -2,7 +2,6 @@ namespace App\Domain\TemplateManagement; -use App\Domain\SourceManagement\SourceMetaInterface; use App\DBAL\Types\TemplateType; /** @@ -11,9 +10,14 @@ use App\DBAL\Types\TemplateType; class TemplateMeta implements TemplateMetaInterface { /** - * @var SourceMetaInterface + * @var array */ - private $sourceMeta; + private $basicPathArray; + + /** + * @var string + */ + private $basicName; /** * @var string @@ -35,9 +39,16 @@ class TemplateMeta implements TemplateMetaInterface */ private $contentTemplatePath; - public function __construct(SourceMetaInterface $sourceMeta) + /** + * @var string + */ + private $folder; + + public function __construct(array $basicPathArray, string $basicName, string $folder) { - $this->sourceMeta = $sourceMeta; + $this->basicPathArray = $basicPathArray; + $this->basicName = $basicName; + $this->folder = $folder; $this->init(); } @@ -50,7 +61,7 @@ class TemplateMeta implements TemplateMetaInterface private function setPathSuffix(): void { - $this->pathSuffix = implode('/', $this->sourceMeta->getBasicPathArray()).'/'.$this->sourceMeta->getBasicName().'.'.$this->type.'.twig'; + $this->pathSuffix = $this->folder.'/'.implode('/', $this->basicPathArray).'/'.$this->basicName.'.'.$this->type.'.twig'; } private function setFrameTemplatePath(): void @@ -83,4 +94,9 @@ class TemplateMeta implements TemplateMetaInterface { return $this->type; } + + public function getPathSuffix(): string + { + return $this->pathSuffix; + } } diff --git a/application/tests/Unit/Domain/TemplateManagement/TemplateMetaTest.php b/application/tests/Unit/Domain/TemplateManagement/TemplateMetaTest.php index 0a75d51..3fde8df 100644 --- a/application/tests/Unit/Domain/TemplateManagement/TemplateMetaTest.php +++ b/application/tests/Unit/Domain/TemplateManagement/TemplateMetaTest.php @@ -23,13 +23,14 @@ class TemplateMetaTest extends TestCase private function getExpectedPath(string $type, string $context): string { - return $context.'/source/primitive/name/firstname.'.$type.'.twig'; + return $context.'/entity/source/primitive/name/firstname.'.$type.'.twig'; } public function setUp(): void { $this->source = new FirstNameSource(); - $this->templateMeta = new TemplateMeta(new SourceMeta($this->source)); + $sourceMeta = new SourceMeta($this->source); + $this->templateMeta = new TemplateMeta($sourceMeta->getBasicPathArray(), $sourceMeta->getBasicName(), 'entity'); } public function testFrameTemplatePath(): void