mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 01:09:41 +00:00 
			
		
		
		
	deleted deprecated code
This commit is contained in:
		| @@ -1,163 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\EntityManagement; | ||||
|  | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathFormAndViewInterface; | ||||
| use Infinito\Entity\EntityInterface; | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathFormAndView; | ||||
| use Infinito\Domain\FormManagement\FormMetaInformationInterface; | ||||
| use Infinito\Domain\FormManagement\FormMetaInformation; | ||||
| use Infinito\Domain\PathManagement\NamespacePathMapInterface; | ||||
| use Infinito\Domain\PathManagement\NamespacePathMap; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated | ||||
|  */ | ||||
| class EntityMetaInformation implements EntityMetaInformationInterface | ||||
| { | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $entityReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var \ReflectionClass | ||||
|      */ | ||||
|     private $interfaceReflection; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplatePathFormAndViewInterface | ||||
|      */ | ||||
|     private $templatePathFormAndView; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     protected $pureName; | ||||
|  | ||||
|     /** | ||||
|      * @var EntityInterface | ||||
|      */ | ||||
|     private $entity; | ||||
|  | ||||
|     /** | ||||
|      * @var FormMetaInformationInterface | ||||
|      */ | ||||
|     private $formMetaInformation; | ||||
|  | ||||
|     /** | ||||
|      * @var NamespacePathMapInterface | ||||
|      */ | ||||
|     private $namespacePathMap; | ||||
|  | ||||
|     /** | ||||
|      * @param EntityInterface $entity | ||||
|      */ | ||||
|     public function __construct(EntityInterface $entity) | ||||
|     { | ||||
|         $this->entity = $entity; | ||||
|         $this->entityReflection = new \ReflectionClass($entity); | ||||
|         $this->setNamespacePathMap(); | ||||
|         $this->setPureName(); | ||||
|         $this->setInterfaceReflection(); | ||||
|         $this->setTemplatePathFormAndView(); | ||||
|         $this->formMetaInformation = new FormMetaInformation($this); | ||||
|     } | ||||
|  | ||||
|     private function setTemplatePathFormAndView(): void | ||||
|     { | ||||
|         $this->templatePathFormAndView = new TemplatePathFormAndView($this->pureName, $this->namespacePathMap->getPath()); | ||||
|     } | ||||
|  | ||||
|     private function setNamespacePathMap(): void | ||||
|     { | ||||
|         $namespace = $this->entityReflection->getNamespaceName(); | ||||
|         $namespaceWithoutRoot = str_replace('Infinito\\Entity\\', '', $namespace); | ||||
|         $this->namespacePathMap = new NamespacePathMap(); | ||||
|         $this->namespacePathMap->setNamespace($namespaceWithoutRoot); | ||||
|     } | ||||
|  | ||||
|     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 \Infinito\Domain\EntityManagement\EntityMetaInformationInterface::getInterfaceReflection() | ||||
|      */ | ||||
|     public function getInterfaceReflection(): \ReflectionClass | ||||
|     { | ||||
|         return $this->interfaceReflection; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformationInterface::getPureName() | ||||
|      */ | ||||
|     public function getPureName(): string | ||||
|     { | ||||
|         return $this->pureName; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformationInterface::getTemplatePathFormAndView() | ||||
|      */ | ||||
|     public function getTemplatePathFormAndView(): TemplatePathFormAndViewInterface | ||||
|     { | ||||
|         return $this->templatePathFormAndView; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformationInterface::getEntity() | ||||
|      */ | ||||
|     public function getEntity(): EntityInterface | ||||
|     { | ||||
|         return $this->entity; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformationInterface::getEntityReflection() | ||||
|      */ | ||||
|     public function getEntityReflection(): \ReflectionClass | ||||
|     { | ||||
|         return $this->entityReflection; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformationInterface::getFormMetaInformation() | ||||
|      */ | ||||
|     public function getFormMetaInformation(): FormMetaInformationInterface | ||||
|     { | ||||
|         return $this->formMetaInformation; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformationInterface::getNamespacePathMap() | ||||
|      */ | ||||
|     public function getNamespacePathMap(): NamespacePathMapInterface | ||||
|     { | ||||
|         return $this->namespacePathMap; | ||||
|     } | ||||
| } | ||||
| @@ -1,54 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\EntityManagement; | ||||
|  | ||||
| use Infinito\Entity\EntityInterface; | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathFormAndViewInterface; | ||||
| use Infinito\Domain\FormManagement\FormMetaInformationInterface; | ||||
| use Infinito\Domain\PathManagement\NamespacePathMap; | ||||
| use Infinito\Domain\PathManagement\NamespacePathMapInterface; | ||||
|  | ||||
| /** | ||||
|  * Offers some meta information about an entity. | ||||
|  * | ||||
|  * @deprecated | ||||
|  * | ||||
|  * @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 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; | ||||
|  | ||||
|     /** | ||||
|      * @return NamespacePathMap | ||||
|      */ | ||||
|     public function getNamespacePathMap(): NamespacePathMapInterface; | ||||
| } | ||||
| @@ -1,64 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\FormManagement; | ||||
|  | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathInformationInterface; | ||||
| use Infinito\Domain\EntityManagement\EntityMetaInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated | ||||
|  */ | ||||
| final class FormMetaInformation implements FormMetaInformationInterface | ||||
| { | ||||
|     const FOLDER = 'form'; | ||||
|  | ||||
|     /** | ||||
|      * @var EntityMetaInformationInterface | ||||
|      */ | ||||
|     private $entityMetaInformation; | ||||
|  | ||||
|     /** | ||||
|      * @var string | ||||
|      */ | ||||
|     private $formClass; | ||||
|  | ||||
|     /** | ||||
|      * @param EntityMetaInformationInterface $entityMetaInformation | ||||
|      */ | ||||
|     public function __construct(EntityMetaInformationInterface $entityMetaInformation) | ||||
|     { | ||||
|         $this->entityMetaInformation = $entityMetaInformation; | ||||
|         $this->setFormClass(); | ||||
|     } | ||||
|  | ||||
|     private function setFormClass(): void | ||||
|     { | ||||
|         $this->formClass = 'Infinito\\Form'; | ||||
|         foreach ($this->entityMetaInformation->getNamespacePathMap()->getFolders() as $element) { | ||||
|             $this->formClass .= '\\'.ucfirst($element); | ||||
|         } | ||||
|         $this->formClass .= '\\'.ucfirst($this->entityMetaInformation->getPureName()).'Type'; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\FormManagement\FormMetaInformationInterface::getFormClass() | ||||
|      */ | ||||
|     public function getFormClass(): string | ||||
|     { | ||||
|         return $this->formClass; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\FormManagement\FormMetaInformationInterface::getTemplatePathInformation() | ||||
|      */ | ||||
|     public function getTemplatePathInformation(): TemplatePathInformationInterface | ||||
|     { | ||||
|         return $this->entityMetaInformation->getTemplatePathFormAndView()->getForm(); | ||||
|     } | ||||
| } | ||||
| @@ -1,23 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\FormManagement; | ||||
|  | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated | ||||
|  */ | ||||
| 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; | ||||
| } | ||||
| @@ -8,6 +8,7 @@ use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerServiceInterface | ||||
| use Infinito\Domain\ActionManagement\ActionHandlerServiceInterface; | ||||
| use Infinito\Entity\Source\Primitive\Text\TextSource; | ||||
| use Infinito\Domain\DataAccessManagement\ActionsResultsDAOServiceInterface; | ||||
| use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
| @@ -34,18 +35,24 @@ final class ProcessService implements ProcessServiceInterface | ||||
|      */ | ||||
|     private $actionsResultsDAOService; | ||||
|  | ||||
|     /** | ||||
|      * @var ValidGetParameterServiceInterface | ||||
|      */ | ||||
|     private $validGetParameterService; | ||||
|  | ||||
|     /** | ||||
|      * @param ActionHandlerServiceInterface               $actionHandlerService | ||||
|      * @param ActionsResultsDAOServiceInterface           $actionTemplateDataStore | ||||
|      * @param RequestedActionServiceInterface             $requestedActionService | ||||
|      * @param SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService | ||||
|      */ | ||||
|     public function __construct(ActionHandlerServiceInterface $actionHandlerService, ActionsResultsDAOServiceInterface $actionTemplateDataStore, RequestedActionServiceInterface $requestedActionService, SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService) | ||||
|     public function __construct(ActionHandlerServiceInterface $actionHandlerService, ActionsResultsDAOServiceInterface $actionTemplateDataStore, RequestedActionServiceInterface $requestedActionService, SecureRequestedRightCheckerServiceInterface $secureRequestedRightCheckerService, ValidGetParameterServiceInterface $validGetParameterService) | ||||
|     { | ||||
|         $this->actionHandlerService = $actionHandlerService; | ||||
|         $this->actionsResultsDAOService = $actionTemplateDataStore; | ||||
|         $this->requestedActionService = $requestedActionService; | ||||
|         $this->secureRequestedRightCheckerService = $secureRequestedRightCheckerService; | ||||
|         $this->validGetParameterService = $validGetParameterService; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -59,15 +66,19 @@ final class ProcessService implements ProcessServiceInterface | ||||
|         if ($this->requestedActionService->hasRequestedEntity() && $this->requestedActionService->getRequestedEntity()->hasIdentity()) { | ||||
|             // READ VIEW | ||||
|             if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) { | ||||
|                 $read = $this->actionHandlerService->handle(); | ||||
|                 $this->actionsResultsDAOService->setData(ActionType::READ, $read); | ||||
|                 $actionType = $this->requestedActionService->getActionType(); | ||||
|                 switch ($actionType) { | ||||
|                     case ActionType::READ: | ||||
|                         $read = $this->actionHandlerService->handle(); | ||||
|                         $this->actionsResultsDAOService->setData($actionType, $read); | ||||
|                         break; | ||||
|                     case ActionType::UPDATE: | ||||
|                         $updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView(); | ||||
|                         $this->actionTemplateDataStore->setData(ActionType::UPDATE, $updateForm); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             // $this->requestedActionService->setActionType(ActionType::UPDATE); | ||||
|             // UPDATE VIEW | ||||
|             // if ($this->secureRequestedRightCheckerService->check($this->requestedActionService)) { | ||||
|             // $updateForm = $this->requestedActionFormBuilderService->createByService()->getForm()->createView(); | ||||
|             // $this->actionTemplateDataStore->setData(ActionType::UPDATE, $updateForm); | ||||
|             // } | ||||
|             // DELETE VIEW | ||||
|             // EXECUTE VIEW | ||||
|         } else { | ||||
|   | ||||
| @@ -1,41 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\SourceManagement; | ||||
|  | ||||
| use Infinito\Domain\EntityManagement\EntityMetaInformation; | ||||
| use Infinito\Entity\Source\AbstractSource; | ||||
| use Infinito\Exception\NotCorrectInstanceException; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class SourceMetaInformation extends EntityMetaInformation implements SourceMetaInformationInterface | ||||
| { | ||||
|     const UNPURE = 'source'; | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformation::__construct() | ||||
|      * | ||||
|      * @param $entity AbstractSource | ||||
|      */ | ||||
|     public function __construct(\Infinito\Entity\EntityInterface $entity) | ||||
|     { | ||||
|         if (!$entity instanceof AbstractSource) { | ||||
|             throw new NotCorrectInstanceException('Entity has to be an instance of '.AbstractSource::class); | ||||
|         } | ||||
|         parent::__construct($entity); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\EntityManagement\EntityMetaInformation::setPureName() | ||||
|      */ | ||||
|     protected function setPureName(): void | ||||
|     { | ||||
|         parent::setPureName(); | ||||
|         $this->pureName = substr($this->pureName, 0, -strlen(self::UNPURE)); | ||||
|     } | ||||
| } | ||||
| @@ -1,12 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\SourceManagement; | ||||
|  | ||||
| use Infinito\Domain\EntityManagement\EntityMetaInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface SourceMetaInformationInterface extends EntityMetaInformationInterface | ||||
| { | ||||
| } | ||||
| @@ -1,22 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\TemplateManagement; | ||||
|  | ||||
| use Infinito\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated | ||||
|  */ | ||||
| interface ReloadTypeInterface | ||||
| { | ||||
|     /** | ||||
|      * Reloads a Template type. | ||||
|      * | ||||
|      * @see RESTResponseType::$choices | ||||
|      * | ||||
|      * @param string $type | ||||
|      */ | ||||
|     public function reloadType(string $type): void; | ||||
| } | ||||
| @@ -1,87 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\TemplateManagement; | ||||
|  | ||||
| use Infinito\Domain\FormManagement\FormMetaInformation; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated | ||||
|  */ | ||||
| final class TemplatePathFormAndView implements TemplatePathFormAndViewInterface | ||||
| { | ||||
|     const FORM_FOLDER = FormMetaInformation::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, self::VIEW_FOLDER); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\TemplateManagement\TemplatePathFormAndViewInterface::getForm() | ||||
|      */ | ||||
|     public function getForm(): TemplatePathInformationInterface | ||||
|     { | ||||
|         return $this->form; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\TemplateManagement\TemplatePathFormAndViewInterface::getView() | ||||
|      */ | ||||
|     public function getView(): TemplatePathInformation | ||||
|     { | ||||
|         return $this->view; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\TemplateManagement\ReloadTypeInterface::reloadType() | ||||
|      */ | ||||
|     public function reloadType(string $type): void | ||||
|     { | ||||
|         $this->view->reloadType($type); | ||||
|         $this->form->reloadType($type); | ||||
|     } | ||||
| } | ||||
| @@ -1,21 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\TemplateManagement; | ||||
|  | ||||
| /** | ||||
|  * @deprecated | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface TemplatePathFormAndViewInterface extends ReloadTypeInterface | ||||
| { | ||||
|     /** | ||||
|      * @return TemplatePathInformationInterface | ||||
|      */ | ||||
|     public function getForm(): TemplatePathInformationInterface; | ||||
|  | ||||
|     /** | ||||
|      * @return TemplatePathInformationInterface | ||||
|      */ | ||||
|     public function getView(): TemplatePathInformation; | ||||
| } | ||||
| @@ -1,131 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\TemplateManagement; | ||||
|  | ||||
| use Infinito\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated | ||||
|  * @see TemplatePathService | ||||
|  */ | ||||
| final class TemplatePathInformation implements TemplatePathInformationInterface | ||||
| { | ||||
|     const MOLECULE_FOLDER = 'molecule'; | ||||
|  | ||||
|     const ATOM_FOLDER = 'atom'; | ||||
|  | ||||
|     /** | ||||
|      * @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 = self::MOLECULE_FOLDER.'/'.$this->prefix.'/'.$this->suffix; | ||||
|     } | ||||
|  | ||||
|     private function setAtomTemplatePath(): void | ||||
|     { | ||||
|         $this->atomTemplatePath = self::ATOM_FOLDER.'/'.$this->prefix.'/'.$this->suffix; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\TemplateManagement\TemplatePathInformationInterface::getAtomTemplatePath() | ||||
|      */ | ||||
|     public function getAtomTemplatePath(): string | ||||
|     { | ||||
|         return $this->atomTemplatePath; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\TemplateManagement\TemplatePathInformationInterface::getMoleculeTemplatePath() | ||||
|      */ | ||||
|     public function getMoleculeTemplatePath(): string | ||||
|     { | ||||
|         return $this->moleculeTemplatePath; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\TemplateManagement\TemplatePathInformationInterface::reloadType() | ||||
|      */ | ||||
|     public function reloadType(string $type): void | ||||
|     { | ||||
|         $this->type = $type; | ||||
|         $this->init(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \Infinito\Domain\TemplateManagement\TemplatePathInformationInterface::getCrud() | ||||
|      */ | ||||
|     public function getCrud(): string | ||||
|     { | ||||
|         return $this->type; | ||||
|     } | ||||
| } | ||||
| @@ -1,35 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Infinito\Domain\TemplateManagement; | ||||
|  | ||||
| use Infinito\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| /** | ||||
|  * Manages all informations which are needed to process templates. | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  * | ||||
|  * @deprecated | ||||
|  * @see TemplatePathServiceInterface | ||||
|  */ | ||||
| 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; | ||||
|  | ||||
|     /** | ||||
|      * @todo Check if this is really needed. Otherwise remove it! | ||||
|      * | ||||
|      * @see RESTResponseType::$choices | ||||
|      * | ||||
|      * @return string Type of the template | ||||
|      */ | ||||
|     public function getCrud(): string; | ||||
| } | ||||
| @@ -1,51 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Tests\Unit\Domain\FormManagement; | ||||
|  | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use Infinito\Entity\Source\Primitive\Name\SurnameSource; | ||||
| use Infinito\Domain\FormManagement\FormMetaInformationInterface; | ||||
| use Infinito\Domain\SourceManagement\SourceMetaInformation; | ||||
| use Infinito\Domain\FormManagement\FormMetaInformation; | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathInformationInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| class FormMetaInformationTest extends TestCase | ||||
| { | ||||
|     const FORM_CLASS = 'Infinito\Form\Source\Primitive\Name\SurnameType'; | ||||
|  | ||||
|     const FORM_VIEW_ATOM = 'atom/form/source/primitive/name/surname.html.twig'; | ||||
|  | ||||
|     const FORM_VIEW_MOLECULE = 'molecule/form/source/primitive/name/surname.html.twig'; | ||||
|  | ||||
|     /** | ||||
|      * @var FormMetaInformationInterface | ||||
|      */ | ||||
|     private $formMeta; | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $sourceMeta = new SourceMetaInformation(new SurnameSource()); | ||||
|         $this->formMeta = new FormMetaInformation($sourceMeta); | ||||
|     } | ||||
|  | ||||
|     public function testGetFormClass(): void | ||||
|     { | ||||
|         $this->assertEquals(self::FORM_CLASS, $this->formMeta->getFormClass()); | ||||
|     } | ||||
|  | ||||
|     public function testGetView(): void | ||||
|     { | ||||
|         $this->assertEquals(self::FORM_VIEW_ATOM, $this->formMeta->getTemplatePathInformation()->getAtomTemplatePath()); | ||||
|         $this->assertEquals(self::FORM_VIEW_MOLECULE, $this->formMeta->getTemplatePathInformation()->getMoleculeTemplatePath()); | ||||
|     } | ||||
|  | ||||
|     public function testTemplateMeta(): void | ||||
|     { | ||||
|         $templatePathInformation = $this->formMeta->getTemplatePathInformation(); | ||||
|         $this->assertInstanceOf(TemplatePathInformationInterface::class, $templatePathInformation); | ||||
|         $this->assertEquals('atom/form/source/primitive/name/surname.html.twig', $templatePathInformation->getAtomTemplatePath()); | ||||
|     } | ||||
| } | ||||
| @@ -1,94 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Tests\Unit\Domain\SourceManagement; | ||||
|  | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use Infinito\Entity\Source\Complex\UserSource; | ||||
| use Infinito\Entity\Source\Complex\UserSourceInterface; | ||||
| use Infinito\Entity\Source\SourceInterface; | ||||
| use Infinito\Domain\SourceManagement\SourceMetaInformation; | ||||
| use Infinito\Domain\SourceManagement\SourceMetaInformationInterface; | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathFormAndViewInterface; | ||||
| use Infinito\Domain\FormManagement\FormMetaInformationInterface; | ||||
| use Infinito\Entity\EntityInterface; | ||||
| use Infinito\Exception\NotCorrectInstanceException; | ||||
|  | ||||
| class SourceMetaInformationTest extends TestCase | ||||
| { | ||||
|     const FOLDERS = [ | ||||
|         'source', | ||||
|         'complex', | ||||
|     ]; | ||||
|  | ||||
|     /** | ||||
|      * @var SourceMetaInformationInterface | ||||
|      */ | ||||
|     private $sourceMetaInformation; | ||||
|  | ||||
|     /** | ||||
|      * @var SourceInterface | ||||
|      */ | ||||
|     private $source; | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->source = new UserSource(); | ||||
|         $this->sourceMetaInformation = new SourceMetaInformation($this->source); | ||||
|     } | ||||
|  | ||||
|     public function testBasicName(): void | ||||
|     { | ||||
|         $this->assertEquals('user', $this->sourceMetaInformation->getPureName()); | ||||
|         $this->assertNotEquals('user2', $this->sourceMetaInformation->getPureName()); | ||||
|     } | ||||
|  | ||||
|     public function testFolders(): void | ||||
|     { | ||||
|         $amount = count(self::FOLDERS); | ||||
|         $folders = $this->sourceMetaInformation->getNamespacePathMap()->getFolders(); | ||||
|         for ($index = 0; $index < $amount; ++$index) { | ||||
|             $this->assertEquals(self::FOLDERS[$index], $folders[$index]); | ||||
|         } | ||||
|         $this->assertArraySubset(self::FOLDERS, $folders); | ||||
|         $this->assertEquals($amount, count($folders)); | ||||
|     } | ||||
|  | ||||
|     public function testInterfaceReflection(): void | ||||
|     { | ||||
|         /** | ||||
|          * @var \ReflectionClass | ||||
|          */ | ||||
|         $interfaceReflection = $this->sourceMetaInformation->getInterfaceReflection(); | ||||
|         $this->assertEquals(UserSourceInterface::class, $interfaceReflection->getName()); | ||||
|     } | ||||
|  | ||||
|     public function testSourceReflection(): void | ||||
|     { | ||||
|         /** | ||||
|          * @var \ReflectionClass | ||||
|          */ | ||||
|         $sourceReflection = $this->sourceMetaInformation->getEntityReflection(); | ||||
|         $this->assertEquals(UserSource::class, $sourceReflection->getName()); | ||||
|     } | ||||
|  | ||||
|     public function testTemplateMeta(): void | ||||
|     { | ||||
|         $this->assertInstanceOf(TemplatePathFormAndViewInterface::class, $this->sourceMetaInformation->getTemplatePathFormAndView()); | ||||
|     } | ||||
|  | ||||
|     public function testSource(): void | ||||
|     { | ||||
|         $this->assertEquals($this->source, $this->sourceMetaInformation->getEntity()); | ||||
|     } | ||||
|  | ||||
|     public function testFormMeta(): void | ||||
|     { | ||||
|         $this->assertInstanceOf(FormMetaInformationInterface::class, $this->sourceMetaInformation->getFormMetaInformation()); | ||||
|     } | ||||
|  | ||||
|     public function testTypeError(): void | ||||
|     { | ||||
|         $this->expectException(NotCorrectInstanceException::class); | ||||
|         new SourceMetaInformation($this->createMock(EntityInterface::class)); | ||||
|     } | ||||
| } | ||||
| @@ -1,37 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace tests\Unit\Domain\TemplateManagement; | ||||
|  | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathFormAndView; | ||||
| use Infinito\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| class TemplatePathFormAndViewTest extends TestCase | ||||
| { | ||||
|     const FILE = 'hello_world'; | ||||
|  | ||||
|     const FOLDER = 'folder'; | ||||
|  | ||||
|     const BASE_PATH = 'atom/view/'.self::FOLDER.'/'.self::FILE.'.'; | ||||
|  | ||||
|     /** | ||||
|      * @var TemplatePathFormAndView | ||||
|      */ | ||||
|     private $templatePathFormAndView; | ||||
|  | ||||
|     public function setUp() | ||||
|     { | ||||
|         $this->templatePathFormAndView = new TemplatePathFormAndView(self::FILE, self::FOLDER); | ||||
|     } | ||||
|  | ||||
|     public function testTypeReload(): void | ||||
|     { | ||||
|         foreach (RESTResponseType::getValues() as $type) { | ||||
|             $this->templatePathFormAndView->reloadType($type); | ||||
|             $this->assertEquals(self::BASE_PATH.$type.'.twig', $this->templatePathFormAndView->getView()->getAtomTemplatePath()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,62 +0,0 @@ | ||||
| <?php | ||||
|  | ||||
| namespace Tests\Unit\Domain\TemplateManagement; | ||||
|  | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use Infinito\Entity\Source\Primitive\Name\FirstNameSource; | ||||
| use Infinito\Entity\Source\SourceInterface; | ||||
| use Infinito\Domain\TemplateManagement\TemplatePathInformation; | ||||
| use Infinito\Domain\SourceManagement\SourceMetaInformation; | ||||
| use Infinito\DBAL\Types\RESTResponseType; | ||||
|  | ||||
| class TemplatePathInformationTest extends TestCase | ||||
| { | ||||
|     /** | ||||
|      * @var TemplatePathInformation | ||||
|      */ | ||||
|     private $templateMeta; | ||||
|  | ||||
|     /** | ||||
|      * @var SourceInterface | ||||
|      */ | ||||
|     private $source; | ||||
|  | ||||
|     /** | ||||
|      * @param string $type | ||||
|      * @param string $context | ||||
|      * | ||||
|      * @return string | ||||
|      */ | ||||
|     private function getExpectedPath(string $type, string $context): string | ||||
|     { | ||||
|         return $context.'/entity/source/primitive/name/firstname.'.$type.'.twig'; | ||||
|     } | ||||
|  | ||||
|     public function setUp(): void | ||||
|     { | ||||
|         $this->source = new FirstNameSource(); | ||||
|         $sourceMeta = new SourceMetaInformation($this->source); | ||||
|         $folder = $sourceMeta->getNamespacePathMap()->getPath(); | ||||
|         $this->templateMeta = new TemplatePathInformation($sourceMeta->getPureName(), $folder, 'entity'); | ||||
|     } | ||||
|  | ||||
|     public function testFrameTemplatePath(): void | ||||
|     { | ||||
|         $this->assertEquals($this->getExpectedPath('html', 'molecule'), $this->templateMeta->getMoleculeTemplatePath()); | ||||
|     } | ||||
|  | ||||
|     public function testContentTemplatePath(): void | ||||
|     { | ||||
|         $this->assertEquals($this->getExpectedPath('html', 'atom'), $this->templateMeta->getAtomTemplatePath()); | ||||
|     } | ||||
|  | ||||
|     public function testSetType(): void | ||||
|     { | ||||
|         foreach (RESTResponseType::getValues() as $type) { | ||||
|             $this->templateMeta->reloadType($type); | ||||
|             $this->assertEquals($this->getExpectedPath($type, 'atom'), $this->templateMeta->getAtomTemplatePath()); | ||||
|             $this->assertEquals($this->getExpectedPath($type, 'molecule'), $this->templateMeta->getMoleculeTemplatePath()); | ||||
|             $this->assertEquals($type, $this->templateMeta->getCrud()); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user