mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 09:19:08 +00:00 
			
		
		
		
	Optimized draft for meta and template informations
This commit is contained in:
		| @@ -0,0 +1,161 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\EntityManagement; | ||||
|  | ||||
| use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface; | ||||
| use App\Entity\EntityInterface; | ||||
| use src\Domain\TemplateManagement\TemplatePathFormAndView; | ||||
| use App\Domain\FormManagement\FormMetaInformationInterface; | ||||
| use App\Domain\FormManagement\FormMetaInformation; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| class EntityMetaInformation implements EntityMetaInformationInterface | ||||
| { | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $entityReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $interfaceReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplatePathFormAndViewInterface | ||||
|      */ | ||||
|     private $templatePathFormAndView; | ||||
|  | ||||
|     /** | ||||
|      * @var array | ||||
|      */ | ||||
|     private $basicPathArray; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $pureName; | ||||
|  | ||||
|     /** | ||||
|      * @var EntityInterface | ||||
|      */ | ||||
|     private $entity; | ||||
|  | ||||
|     /** | ||||
|      * @var FormMetaInformationInterface | ||||
|      */ | ||||
|     private $formMetaInformation; | ||||
|  | ||||
|     /** | ||||
|      * @param EntityInterface $entity | ||||
|      */ | ||||
|     public function __construct(EntityInterface $entity) | ||||
|     { | ||||
|         $this->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; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,50 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\EntityManagement; | ||||
|  | ||||
| use App\Entity\EntityInterface; | ||||
| use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface; | ||||
| use App\Domain\FormManagement\FormMetaInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * Offers informations, which the system needs to handle Entities. | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface EntityMetaInformationInterface | ||||
| { | ||||
|     /** | ||||
|      * @return \ReflectionClass | ||||
|      */ | ||||
|     public function getEntityReflection(): \ReflectionClass; | ||||
|  | ||||
|     /** | ||||
|      * @return \ReflectionClass | ||||
|      */ | ||||
|     public function getInterfaceReflection(): \ReflectionClass; | ||||
|  | ||||
|     /** | ||||
|      * @return TemplatePathFormAndViewInterface Informations about the template path | ||||
|      */ | ||||
|     public function getTemplatePathFormAndView(): TemplatePathFormAndViewInterface; | ||||
|  | ||||
|     /** | ||||
|      * @return array the namespace elements without the root | ||||
|      */ | ||||
|     public function getBasicPathArray(): array; | ||||
|  | ||||
|     /** | ||||
|      * @return string Short class name in lower case without "Abstract" | ||||
|      */ | ||||
|     public function getPureName(): string; | ||||
|  | ||||
|     /** | ||||
|      * @return EntityInterface Entity to which the meta object belongs to | ||||
|      */ | ||||
|     public function getEntity(): EntityInterface; | ||||
|  | ||||
|     /** | ||||
|      * @return FormMetaInformationInterface The meta informations about the form | ||||
|      */ | ||||
|     public function getFormMetaInformation(): FormMetaInformationInterface; | ||||
| } | ||||
| @@ -1,63 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\FormManagement; | ||||
|  | ||||
| use App\Domain\SourceManagement\SourceMetaInterface; | ||||
| use App\Domain\TemplateManagement\TemplateMetaInterface; | ||||
| use App\Domain\TemplateManagement\TemplateMeta; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @todo Optimize contructor parameter! | ||||
|  */ | ||||
| class FormMeta implements FormMetaInterface | ||||
| { | ||||
|     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(); | ||||
|     } | ||||
|  | ||||
|     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; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,73 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\FormManagement; | ||||
|  | ||||
| use App\Domain\TemplateManagement\TemplatePathInformationInterface; | ||||
| use App\Domain\EntityManagement\EntityMetaInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class FormMetaInformation implements FormMetaInformationInterface | ||||
| { | ||||
|     const FOLDER = 'form'; | ||||
|  | ||||
|     /** | ||||
|      * @var EntityMetaInformationInterface | ||||
|      */ | ||||
|     private $entityMetaInformation; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplatePathInformationInterface | ||||
|      */ | ||||
|     private $templatePathInformation; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $formClass; | ||||
|  | ||||
|     /** | ||||
|      * @param EntityMetaInformationInterface $entityMetaInformation | ||||
|      */ | ||||
|     public function __construct(EntityMetaInformationInterface $entityMetaInformation) | ||||
|     { | ||||
|         $this->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; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,21 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\FormManagement; | ||||
|  | ||||
| use App\Domain\TemplateManagement\TemplatePathInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface FormMetaInformationInterface | ||||
| { | ||||
|     /** | ||||
|      * @return string The string to the form class | ||||
|      */ | ||||
|     public function getFormClass(): string; | ||||
|  | ||||
|     /** | ||||
|      * @return TemplatePathInformationInterface The form template path information | ||||
|      */ | ||||
|     public function getTemplatePathInformation(): TemplatePathInformationInterface; | ||||
| } | ||||
| @@ -1,12 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\FormManagement; | ||||
|  | ||||
| use App\Domain\TemplateManagement\TemplateMetaInterface; | ||||
|  | ||||
| interface FormMetaInterface | ||||
| { | ||||
|     public function getFormClass(): string; | ||||
|  | ||||
|     public function getTemplateMeta(): TemplateMetaInterface; | ||||
| } | ||||
| @@ -1,126 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| 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 | ||||
|  */ | ||||
| final class SourceMeta implements SourceMetaInterface | ||||
| { | ||||
|     const FOLDER = 'entity'; | ||||
|  | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $sourceReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $interfaceReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplateMetaInterface | ||||
|      */ | ||||
|     private $templateMeta; | ||||
|  | ||||
|     /** | ||||
|      * @var array | ||||
|      */ | ||||
|     private $basicPathArray; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $basicName; | ||||
|  | ||||
|     /** | ||||
|      * @var SourceInterface | ||||
|      */ | ||||
|     private $source; | ||||
|  | ||||
|     /** | ||||
|      * @var FormMetaInterface | ||||
|      */ | ||||
|     private $formMeta; | ||||
|  | ||||
|     public function __construct(SourceInterface $source) | ||||
|     { | ||||
|         $this->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; | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,22 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\SourceManagement; | ||||
|  | ||||
| use App\Domain\EntityManagement\EntityMetaInformation; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class SourceMetaInformation extends EntityMetaInformation implements SourceMetaInformationInterface | ||||
| { | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \App\Domain\EntityManagement\EntityMetaInformation::setPureName() | ||||
|      */ | ||||
|     protected function setPureName(): void | ||||
|     { | ||||
|         parent::setPureName(); | ||||
|         $this->pureName = str_replace('Source', '', $this->pureName); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,12 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\SourceManagement; | ||||
|  | ||||
| use App\Domain\EntityManagement\EntityMetaInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface SourceMetaInformationInterface extends EntityMetaInformationInterface | ||||
| { | ||||
| } | ||||
| @@ -1,40 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| 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. | ||||
|  * | ||||
|  * @deprecated | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface SourceMetaInterface | ||||
| { | ||||
|     public function getSourceReflection(): \ReflectionClass; | ||||
|  | ||||
|     public function getInterfaceReflection(): \ReflectionClass; | ||||
|  | ||||
|     public function getTemplateMeta(): TemplateMetaInterface; | ||||
|  | ||||
|     /** | ||||
|      * @return array the namespace elements without the root | ||||
|      */ | ||||
|     public function getBasicPathArray(): array; | ||||
|  | ||||
|     /** | ||||
|      * @return string Short class name in lower case without "Abstract" and "Source" | ||||
|      */ | ||||
|     public function getBasicName(): string; | ||||
|  | ||||
|     /** | ||||
|      * @return SourceInterface The source to which the meta object belongs to | ||||
|      */ | ||||
|     public function getSource(): SourceInterface; | ||||
|  | ||||
|     public function getFormMeta(): FormMetaInterface; | ||||
| } | ||||
| @@ -0,0 +1,20 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| use App\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface ReloadTypeInterface | ||||
| { | ||||
|     /** | ||||
|      * Reloads a Template type. | ||||
|      * | ||||
|      * @see RESTResponseType::$choices | ||||
|      * | ||||
|      * @param string $type | ||||
|      */ | ||||
|     public function reloadType(string $type): void; | ||||
| } | ||||
| @@ -1,97 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| use App\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class TemplateMeta implements TemplateMetaInterface | ||||
| { | ||||
|     /** | ||||
|      * @var array | ||||
|      */ | ||||
|     private $basicPathArray; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $basicName; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $type = RESTResponseType::HTML; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $pathSuffix; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $frameTemplatePath; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $contentTemplatePath; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $folder; | ||||
|  | ||||
|     public function __construct(array $basicPathArray, string $basicName, string $folder) | ||||
|     { | ||||
|         $this->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; | ||||
|     } | ||||
| } | ||||
| @@ -1,34 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| /** | ||||
|  * Manages all informations which are needed to process templates. | ||||
|  * | ||||
|  * @deprecated | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface TemplateMetaInterface | ||||
| { | ||||
|     /** | ||||
|      * Sets the template type which should be processed(General html);. | ||||
|      */ | ||||
|     public function setTemplateType(string $type): void; | ||||
|  | ||||
|     public function getTemplateType(): string; | ||||
|  | ||||
|     /** | ||||
|      * Returns a template inclusiv frame. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getFrameTemplatePath(): string; | ||||
|  | ||||
|     /** | ||||
|      * Returns a template without a frame. | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     public function getContentTemplatePath(): string; | ||||
| } | ||||
| @@ -0,0 +1,88 @@ | ||||
| <?php | ||||
|  | ||||
| namespace src\Domain\TemplateManagement; | ||||
|  | ||||
| use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface; | ||||
| use App\Domain\TemplateManagement\TemplatePathInformation; | ||||
| use App\Domain\TemplateManagement\TemplatePathInformationInterface; | ||||
| use App\Domain\FormManagement\FormMeta; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class TemplatePathFormAndView implements TemplatePathFormAndViewInterface | ||||
| { | ||||
|     const FORM_FOLDER = FormMeta::FOLDER; | ||||
|  | ||||
|     const VIEW_FOLDER = 'view'; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplatePathInformation | ||||
|      */ | ||||
|     private $form; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplatePathInformation | ||||
|      */ | ||||
|     private $view; | ||||
|  | ||||
|     /** | ||||
|      * @param string $file | ||||
|      * @param string $folder | ||||
|      * @param string $type | ||||
|      */ | ||||
|     public function __construct(string $file, string $folder) | ||||
|     { | ||||
|         $this->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); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,19 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface TemplatePathFormAndViewInterface extends ReloadTypeInterface | ||||
| { | ||||
|     /** | ||||
|      * @return TemplatePathInformationInterface | ||||
|      */ | ||||
|     public function getForm(): TemplatePathInformationInterface; | ||||
|  | ||||
|     /** | ||||
|      * @return TemplatePathInformationInterface | ||||
|      */ | ||||
|     public function getView(): TemplatePathInformation; | ||||
| } | ||||
| @@ -0,0 +1,114 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| use App\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class TemplatePathInformation implements TemplatePathInformationInterface | ||||
| { | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $file; | ||||
|  | ||||
|     /** | ||||
|      * @see RESTResponseType::$choices | ||||
|      * | ||||
|      * @var string | ||||
|      */ | ||||
|     private $type = RESTResponseType::HTML; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $suffix; | ||||
|  | ||||
|     /** | ||||
|      * @var string Template withouth frame | ||||
|      */ | ||||
|     private $atomTemplatePath; | ||||
|  | ||||
|     /** | ||||
|      * @var string Template with frame | ||||
|      */ | ||||
|     private $moleculeTemplatePath; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $folder; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $prefix; | ||||
|  | ||||
|     /** | ||||
|      * @param string $file | ||||
|      * @param string $folder | ||||
|      * @param string $prefix | ||||
|      */ | ||||
|     public function __construct(string $file, string $folder, string $prefix = '') | ||||
|     { | ||||
|         $this->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(); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,21 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\TemplateManagement; | ||||
|  | ||||
| /** | ||||
|  * Manages all informations which are needed to process templates. | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface TemplatePathInformationInterface extends ReloadTypeInterface | ||||
| { | ||||
|     /** | ||||
|      * @return string A template inclusiv frame. (Standalone) | ||||
|      */ | ||||
|     public function getMoleculeTemplatePath(): string; | ||||
|  | ||||
|     /** | ||||
|      * @return string a template without a frame | ||||
|      */ | ||||
|     public function getAtomTemplatePath(): string; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user