diff --git a/application/symfony/src/Domain/EntityManagement/EntityMetaInformation.php b/application/symfony/src/Domain/EntityManagement/EntityMetaInformation.php new file mode 100644 index 0000000..d10a6cb --- /dev/null +++ b/application/symfony/src/Domain/EntityManagement/EntityMetaInformation.php @@ -0,0 +1,161 @@ +entity = $entity; + $this->entityReflection = new \ReflectionClass($entity); + $this->setBasicPathArray(); + $this->setPureName(); + $this->setInterfaceReflection(); + $this->setTemplatePathFormAndView(); + $this->formMetaInformation = new FormMetaInformation($this); + } + + private function setTemplatePathFormAndView(): void + { + $this->templatePathFormAndView = new TemplatePathFormAndView(implode('/', $this->basicPathArray), $this->pureName); + } + + private function setBasicPathArray(): void + { + $namespace = $this->entityReflection->getNamespaceName(); + $namespaceWithoutRoot = str_replace('App\\Entity\\', '', $namespace); + $this->basicPathArray = []; + foreach (explode('\\', $namespaceWithoutRoot) as $element) { + $this->basicPathArray[] = strtolower($element); + } + } + + private function setInterfaceReflection(): void + { + $namespace = str_replace('\Abstract', '\\', $this->entityReflection->getName()).'Interface'; + $this->interfaceReflection = new \ReflectionClass($namespace); + } + + protected function setPureName(): void + { + $withoutAbstract = str_replace('Abstract', '', $this->entityReflection->getShortName()); + $this->pureName = strtolower($withoutAbstract); + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getBasicPathArray() + */ + public function getBasicPathArray(): array + { + return $this->basicPathArray; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getInterfaceReflection() + */ + public function getInterfaceReflection(): \ReflectionClass + { + return $this->interfaceReflection; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getPureName() + */ + public function getPureName(): string + { + return $this->pureName; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getTemplatePathFormAndView() + */ + public function getTemplatePathFormAndView(): TemplatePathFormAndViewInterface + { + return $this->templatePathFormAndView; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getEntity() + */ + public function getEntity(): EntityInterface + { + return $this->entity; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getEntityReflection() + */ + public function getEntityReflection(): \ReflectionClass + { + return $this->entityReflection; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getFormMetaInformation() + */ + public function getFormMetaInformation(): FormMetaInformationInterface + { + return $this->formMetaInformation; + } +} diff --git a/application/symfony/src/Domain/EntityManagement/EntityMetaInformationInterface.php b/application/symfony/src/Domain/EntityManagement/EntityMetaInformationInterface.php new file mode 100644 index 0000000..352e4c0 --- /dev/null +++ b/application/symfony/src/Domain/EntityManagement/EntityMetaInformationInterface.php @@ -0,0 +1,50 @@ +sourceMeta = $sourceMeta; - $this->setMeta(); - $this->setFormClass(); - } - - private function setFormClass(): void - { - $this->formClass = 'App\\Form'; - foreach ($this->sourceMeta->getBasicPathArray() as $element) { - $this->formClass .= '\\'.ucfirst($element); - } - $this->formClass .= '\\'.ucfirst($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(): TemplateMetaInterface - { - return $this->templateMeta; - } -} diff --git a/application/symfony/src/Domain/FormManagement/FormMetaInformation.php b/application/symfony/src/Domain/FormManagement/FormMetaInformation.php new file mode 100644 index 0000000..eee5c12 --- /dev/null +++ b/application/symfony/src/Domain/FormManagement/FormMetaInformation.php @@ -0,0 +1,73 @@ +entityMetaInformation = $entityMetaInformation; + $this->setTemplateMetaInformation(); + $this->setFormClass(); + } + + private function setFormClass(): void + { + $this->formClass = 'App\\Form'; + foreach ($this->entityMetaInformation->getBasicPathArray() as $element) { + $this->formClass .= '\\'.ucfirst($element); + } + $this->formClass .= '\\'.ucfirst($this->entityMetaInformation->getPureName()).'Type'; + } + + private function setTemplateMetaInformation(): void + { + $this->templatePathInformation = $this->entityMetaInformation->getTemplatePathFormAndView()->getForm(); + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\FormManagement\FormMetaInformationInterface::getFormClass() + */ + public function getFormClass(): string + { + return $this->formClass; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\FormManagement\FormMetaInformationInterface::getTemplatePathInformation() + */ + public function getTemplatePathInformation(): TemplatePathInformationInterface + { + return $this->templatePathInformation; + } +} diff --git a/application/symfony/src/Domain/FormManagement/FormMetaInformationInterface.php b/application/symfony/src/Domain/FormManagement/FormMetaInformationInterface.php new file mode 100644 index 0000000..9b43acc --- /dev/null +++ b/application/symfony/src/Domain/FormManagement/FormMetaInformationInterface.php @@ -0,0 +1,21 @@ +source = $source; - $this->sourceReflection = new \ReflectionClass($source); - $this->setBasicPathArray(); - $this->setBasicName(); - $this->setInterfaceReflection(); - $this->setTemplateMeta(); - $this->formMeta = new FormMeta($this); - } - - private function setTemplateMeta(): void - { - $this->templateMeta = new TemplateMeta($this->basicPathArray, $this->basicName, self::FOLDER); - } - - private function setBasicPathArray(): void - { - $namespace = $this->sourceReflection->getNamespaceName(); - $namespaceWithoutRoot = str_replace('App\\Entity\\', '', $namespace); - $this->basicPathArray = []; - foreach (explode('\\', $namespaceWithoutRoot) as $element) { - $this->basicPathArray[] = strtolower($element); - } - } - - private function setInterfaceReflection(): void - { - $namespace = str_replace('\Abstract', '\\', $this->sourceReflection->getName()).'Interface'; - $this->interfaceReflection = new \ReflectionClass($namespace); - } - - private function setBasicName(): void - { - $withoutAbstract = str_replace('Abstract', '', $this->sourceReflection->getShortName()); - $withoutSource = str_replace('Source', '', $withoutAbstract); - $this->basicName = strtolower($withoutSource); - } - - public function getBasicPathArray(): array - { - return $this->basicPathArray; - } - - public function getInterfaceReflection(): \ReflectionClass - { - return $this->interfaceReflection; - } - - public function getSourceReflection(): \ReflectionClass - { - return $this->sourceReflection; - } - - public function getTemplateMeta(): TemplateMetaInterface - { - return $this->templateMeta; - } - - public function getBasicName(): string - { - return $this->basicName; - } - - public function getSource(): SourceInterface - { - return $this->source; - } - - public function getFormMeta(): FormMetaInterface - { - return $this->formMeta; - } -} diff --git a/application/symfony/src/Domain/SourceManagement/SourceMetaInformation.php b/application/symfony/src/Domain/SourceManagement/SourceMetaInformation.php new file mode 100644 index 0000000..992d391 --- /dev/null +++ b/application/symfony/src/Domain/SourceManagement/SourceMetaInformation.php @@ -0,0 +1,22 @@ +pureName = str_replace('Source', '', $this->pureName); + } +} diff --git a/application/symfony/src/Domain/SourceManagement/SourceMetaInformationInterface.php b/application/symfony/src/Domain/SourceManagement/SourceMetaInformationInterface.php new file mode 100644 index 0000000..1f0dce0 --- /dev/null +++ b/application/symfony/src/Domain/SourceManagement/SourceMetaInformationInterface.php @@ -0,0 +1,12 @@ +basicPathArray = $basicPathArray; - $this->basicName = $basicName; - $this->folder = $folder; - $this->init(); - } - - private function init() - { - $this->setPathSuffix(); - $this->setFrameTemplatePath(); - $this->setContentTemplatePath(); - } - - private function setPathSuffix(): void - { - $this->pathSuffix = $this->folder.'/'.implode('/', $this->basicPathArray).'/'.$this->basicName.'.'.$this->type.'.twig'; - } - - private function setFrameTemplatePath(): void - { - $this->frameTemplatePath = 'frame/'.$this->pathSuffix; - } - - private function setContentTemplatePath(): void - { - $this->contentTemplatePath = 'content/'.$this->pathSuffix; - } - - public function getFrameTemplatePath(): string - { - return $this->frameTemplatePath; - } - - public function getContentTemplatePath(): string - { - return $this->contentTemplatePath; - } - - public function setTemplateType(string $type): void - { - $this->type = $type; - $this->init(); - } - - public function getTemplateType(): string - { - return $this->type; - } -} diff --git a/application/symfony/src/Domain/TemplateManagement/TemplateMetaInterface.php b/application/symfony/src/Domain/TemplateManagement/TemplateMetaInterface.php deleted file mode 100644 index 8d64f8c..0000000 --- a/application/symfony/src/Domain/TemplateManagement/TemplateMetaInterface.php +++ /dev/null @@ -1,34 +0,0 @@ -setForm($file, $folder); + $this->setView($file, $folder); + } + + /** + * @param string $file + * @param string $folder + */ + private function setForm(string $file, string $folder): void + { + $this->form = new TemplatePathInformation($file, $folder, self::FORM_FOLDER); + } + + /** + * @param string $file + * @param string $folder + */ + private function setView(string $file, string $folder): void + { + $this->view = new TemplatePathInformation($file, $folder, $type, self::VIEW_FOLDER); + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\TemplateManagement\TemplatePathFormAndViewInterface::getForm() + */ + public function getForm(): TemplatePathInformationInterface + { + return $this->form; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\TemplateManagement\TemplatePathFormAndViewInterface::getView() + */ + public function getView(): TemplatePathInformation + { + return $this->view; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\TemplateManagement\ReloadTypeInterface::reloadType() + */ + public function reloadType(string $type): void + { + $this->view->reloadType($type); + $this->form->reloadType($type); + } +} diff --git a/application/symfony/src/Domain/TemplateManagement/TemplatePathFormAndViewInterface.php b/application/symfony/src/Domain/TemplateManagement/TemplatePathFormAndViewInterface.php new file mode 100644 index 0000000..985ecb6 --- /dev/null +++ b/application/symfony/src/Domain/TemplateManagement/TemplatePathFormAndViewInterface.php @@ -0,0 +1,19 @@ +file = $file; + $this->folder = $folder; + $this->prefix = $prefix; + $this->init(); + } + + private function init(): void + { + $this->setPathSuffix(); + $this->setMoleculeTemplatePath(); + $this->setAtomTemplatePath(); + } + + private function setPathSuffix(): void + { + $this->suffix = $this->folder.'/'.$this->file.'.'.$this->type.'.twig'; + } + + private function setMoleculeTemplatePath(): void + { + $this->moleculeTemplatePath = 'molecule/'.$this->suffix; + } + + private function setAtomTemplatePath(): void + { + $this->atomTemplatePath = 'atom/'.$this->suffix; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::getAtomTemplatePath() + */ + public function getAtomTemplatePath(): string + { + return $this->atomTemplatePath; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::getMoleculeTemplatePath() + */ + public function getMoleculeTemplatePath(): string + { + return $this->moleculeTemplatePath; + } + + /** + * {@inheritdoc} + * + * @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::reloadType() + */ + public function reloadType(string $type): void + { + $this->type = $type; + $this->init(); + } +} diff --git a/application/symfony/src/Domain/TemplateManagement/TemplatePathInformationInterface.php b/application/symfony/src/Domain/TemplateManagement/TemplatePathInformationInterface.php new file mode 100644 index 0000000..4a26e6c --- /dev/null +++ b/application/symfony/src/Domain/TemplateManagement/TemplatePathInformationInterface.php @@ -0,0 +1,21 @@ +