mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
Implemented NameSpacePathMap as attribut
This commit is contained in:
parent
77822b8e56
commit
c7c4e1c16e
@ -8,6 +8,7 @@ use App\Domain\TemplateManagement\TemplatePathFormAndView;
|
|||||||
use App\Domain\FormManagement\FormMetaInformationInterface;
|
use App\Domain\FormManagement\FormMetaInformationInterface;
|
||||||
use App\Domain\FormManagement\FormMetaInformation;
|
use App\Domain\FormManagement\FormMetaInformation;
|
||||||
use App\Domain\PathManagement\NamespacePathMapInterface;
|
use App\Domain\PathManagement\NamespacePathMapInterface;
|
||||||
|
use App\Domain\PathManagement\NamespacePathMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -29,11 +30,6 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
*/
|
*/
|
||||||
private $templatePathFormAndView;
|
private $templatePathFormAndView;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
private $basicPathArray;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
@ -49,11 +45,6 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
*/
|
*/
|
||||||
private $formMetaInformation;
|
private $formMetaInformation;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
private $basicPathString;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var NamespacePathMapInterface
|
* @var NamespacePathMapInterface
|
||||||
*/
|
*/
|
||||||
@ -67,31 +58,23 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
$this->entity = $entity;
|
$this->entity = $entity;
|
||||||
$this->entityReflection = new \ReflectionClass($entity);
|
$this->entityReflection = new \ReflectionClass($entity);
|
||||||
$this->setBasicPathArray();
|
$this->setBasicPathArray();
|
||||||
$this->setBasicPathString();
|
|
||||||
$this->setPureName();
|
$this->setPureName();
|
||||||
$this->setInterfaceReflection();
|
$this->setInterfaceReflection();
|
||||||
$this->setTemplatePathFormAndView();
|
$this->setTemplatePathFormAndView();
|
||||||
$this->formMetaInformation = new FormMetaInformation($this);
|
$this->formMetaInformation = new FormMetaInformation($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setBasicPathString(): void
|
|
||||||
{
|
|
||||||
$this->basicPathString = implode('/', $this->basicPathArray);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function setTemplatePathFormAndView(): void
|
private function setTemplatePathFormAndView(): void
|
||||||
{
|
{
|
||||||
$this->templatePathFormAndView = new TemplatePathFormAndView(implode('/', $this->basicPathArray), $this->pureName);
|
$this->templatePathFormAndView = new TemplatePathFormAndView($this->namespacePathMap->getPath(), $this->pureName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setBasicPathArray(): void
|
private function setBasicPathArray(): void
|
||||||
{
|
{
|
||||||
$namespace = $this->entityReflection->getNamespaceName();
|
$namespace = $this->entityReflection->getNamespaceName();
|
||||||
$namespaceWithoutRoot = str_replace('App\\Entity\\', '', $namespace);
|
$namespaceWithoutRoot = str_replace('App\\Entity\\', '', $namespace);
|
||||||
$this->basicPathArray = [];
|
$this->namespacePathMap = new NamespacePathMap();
|
||||||
foreach (explode('\\', $namespaceWithoutRoot) as $element) {
|
$this->namespacePathMap->setNamespace($namespaceWithoutRoot);
|
||||||
$this->basicPathArray[] = strtolower($element);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setInterfaceReflection(): void
|
private function setInterfaceReflection(): void
|
||||||
@ -106,16 +89,6 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
$this->pureName = strtolower($withoutAbstract);
|
$this->pureName = strtolower($withoutAbstract);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*
|
|
||||||
* @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getBasicPathArray()
|
|
||||||
*/
|
|
||||||
public function getBasicPathArray(): array
|
|
||||||
{
|
|
||||||
return $this->basicPathArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
@ -179,10 +152,10 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
|||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*
|
*
|
||||||
* @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getBasicPathString()
|
* @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getNamespacePathMap()
|
||||||
*/
|
*/
|
||||||
public function getBasicPathString(): string
|
public function getNamespacePathMap(): NamespacePathMapInterface
|
||||||
{
|
{
|
||||||
return $this->basicPathString;
|
return $this->namespacePathMap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ namespace App\Domain\EntityManagement;
|
|||||||
use App\Entity\EntityInterface;
|
use App\Entity\EntityInterface;
|
||||||
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
||||||
use App\Domain\FormManagement\FormMetaInformationInterface;
|
use App\Domain\FormManagement\FormMetaInformationInterface;
|
||||||
|
use App\Domain\PathManagement\NamespacePathMap;
|
||||||
|
use App\Domain\PathManagement\NamespacePathMapInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Offers informations, which the system needs to handle Entities.
|
* Offers informations, which the system needs to handle Entities.
|
||||||
@ -28,11 +30,6 @@ interface EntityMetaInformationInterface
|
|||||||
*/
|
*/
|
||||||
public function getTemplatePathFormAndView(): TemplatePathFormAndViewInterface;
|
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"
|
* @return string Short class name in lower case without "Abstract"
|
||||||
*/
|
*/
|
||||||
@ -49,7 +46,7 @@ interface EntityMetaInformationInterface
|
|||||||
public function getFormMetaInformation(): FormMetaInformationInterface;
|
public function getFormMetaInformation(): FormMetaInformationInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return NamespacePathMap
|
||||||
*/
|
*/
|
||||||
public function getBasicPathString(): string;
|
public function getNamespacePathMap(): NamespacePathMapInterface;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ final class FormMetaInformation implements FormMetaInformationInterface
|
|||||||
private function setFormClass(): void
|
private function setFormClass(): void
|
||||||
{
|
{
|
||||||
$this->formClass = 'App\\Form';
|
$this->formClass = 'App\\Form';
|
||||||
foreach ($this->entityMetaInformation->getBasicPathArray() as $element) {
|
foreach ($this->entityMetaInformation->getNamespacePathMap()->getFolders() as $element) {
|
||||||
$this->formClass .= '\\'.ucfirst($element);
|
$this->formClass .= '\\'.ucfirst($element);
|
||||||
}
|
}
|
||||||
$this->formClass .= '\\'.ucfirst($this->entityMetaInformation->getPureName()).'Type';
|
$this->formClass .= '\\'.ucfirst($this->entityMetaInformation->getPureName()).'Type';
|
||||||
|
@ -115,4 +115,14 @@ final class TemplatePathInformation implements TemplatePathInformationInterface
|
|||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::getType()
|
||||||
|
*/
|
||||||
|
public function getType(): string
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Domain\TemplateManagement;
|
namespace App\Domain\TemplateManagement;
|
||||||
|
|
||||||
|
use App\DBAL\Types\RESTResponseType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages all informations which are needed to process templates.
|
* Manages all informations which are needed to process templates.
|
||||||
*
|
*
|
||||||
@ -18,4 +20,11 @@ interface TemplatePathInformationInterface extends ReloadTypeInterface
|
|||||||
* @return string a template without a frame
|
* @return string a template without a frame
|
||||||
*/
|
*/
|
||||||
public function getAtomTemplatePath(): string;
|
public function getAtomTemplatePath(): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see RESTResponseType::$choices
|
||||||
|
*
|
||||||
|
* @return string Type of the template
|
||||||
|
*/
|
||||||
|
public function getType(): string;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ use App\Domain\SourceManagement\SourceMetaInformation;
|
|||||||
use App\Domain\FormManagement\FormMetaInformation;
|
use App\Domain\FormManagement\FormMetaInformation;
|
||||||
use App\Domain\TemplateManagement\TemplatePathInformationInterface;
|
use App\Domain\TemplateManagement\TemplatePathInformationInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
class FormMetaInformationTest extends TestCase
|
class FormMetaInformationTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ class SourceMetaInformationTest extends TestCase
|
|||||||
{
|
{
|
||||||
$subset = ['source', 'complex'];
|
$subset = ['source', 'complex'];
|
||||||
$amount = count($subset);
|
$amount = count($subset);
|
||||||
$basicPathArray = $this->sourceMetaInformation->getBasicPathArray();
|
$basicPathArray = $this->sourceMetaInformation->getNamespacePathMap()->getFolders();
|
||||||
for ($index = 0; $index < $amount; ++$index) {
|
for ($index = 0; $index < $amount; ++$index) {
|
||||||
$this->assertEquals($subset[$index], $basicPathArray[$index]);
|
$this->assertEquals($subset[$index], $basicPathArray[$index]);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class TemplatePathInformationTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->source = new FirstNameSource();
|
$this->source = new FirstNameSource();
|
||||||
$sourceMeta = new SourceMetaInformation($this->source);
|
$sourceMeta = new SourceMetaInformation($this->source);
|
||||||
$folder = implode('/', $sourceMeta->getBasicPathArray());
|
$folder = $sourceMeta->getNamespacePathMap()->getPath();
|
||||||
$this->templateMeta = new TemplatePathInformation($sourceMeta->getPureName(), $folder, 'entity');
|
$this->templateMeta = new TemplatePathInformation($sourceMeta->getPureName(), $folder, 'entity');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class TemplatePathInformationTest extends TestCase
|
|||||||
$this->templateMeta->reloadType($type);
|
$this->templateMeta->reloadType($type);
|
||||||
$this->assertEquals($this->getExpectedPath($type, 'atom'), $this->templateMeta->getAtomTemplatePath());
|
$this->assertEquals($this->getExpectedPath($type, 'atom'), $this->templateMeta->getAtomTemplatePath());
|
||||||
$this->assertEquals($this->getExpectedPath($type, 'molecule'), $this->templateMeta->getMoleculeTemplatePath());
|
$this->assertEquals($this->getExpectedPath($type, 'molecule'), $this->templateMeta->getMoleculeTemplatePath());
|
||||||
$this->assertEquals($type, $this->templateMeta->getTemplateType());
|
$this->assertEquals($type, $this->templateMeta->getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user