mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
In between commit solving tests for meta and template management
This commit is contained in:
@@ -4,9 +4,10 @@ namespace App\Domain\EntityManagement;
|
||||
|
||||
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
||||
use App\Entity\EntityInterface;
|
||||
use src\Domain\TemplateManagement\TemplatePathFormAndView;
|
||||
use App\Domain\TemplateManagement\TemplatePathFormAndView;
|
||||
use App\Domain\FormManagement\FormMetaInformationInterface;
|
||||
use App\Domain\FormManagement\FormMetaInformation;
|
||||
use App\Domain\PathManagement\NamespacePathMapInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -36,7 +37,7 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pureName;
|
||||
protected $pureName;
|
||||
|
||||
/**
|
||||
* @var EntityInterface
|
||||
@@ -48,6 +49,16 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
||||
*/
|
||||
private $formMetaInformation;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basicPathString;
|
||||
|
||||
/**
|
||||
* @var NamespacePathMapInterface
|
||||
*/
|
||||
private $namespacePathMap;
|
||||
|
||||
/**
|
||||
* @param EntityInterface $entity
|
||||
*/
|
||||
@@ -56,12 +67,18 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
||||
$this->entity = $entity;
|
||||
$this->entityReflection = new \ReflectionClass($entity);
|
||||
$this->setBasicPathArray();
|
||||
$this->setBasicPathString();
|
||||
$this->setPureName();
|
||||
$this->setInterfaceReflection();
|
||||
$this->setTemplatePathFormAndView();
|
||||
$this->formMetaInformation = new FormMetaInformation($this);
|
||||
}
|
||||
|
||||
private function setBasicPathString(): void
|
||||
{
|
||||
$this->basicPathString = implode('/', $this->basicPathArray);
|
||||
}
|
||||
|
||||
private function setTemplatePathFormAndView(): void
|
||||
{
|
||||
$this->templatePathFormAndView = new TemplatePathFormAndView(implode('/', $this->basicPathArray), $this->pureName);
|
||||
@@ -158,4 +175,14 @@ class EntityMetaInformation implements EntityMetaInformationInterface
|
||||
{
|
||||
return $this->formMetaInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\EntityManagement\EntityMetaInformationInterface::getBasicPathString()
|
||||
*/
|
||||
public function getBasicPathString(): string
|
||||
{
|
||||
return $this->basicPathString;
|
||||
}
|
||||
}
|
||||
|
@@ -47,4 +47,9 @@ interface EntityMetaInformationInterface
|
||||
* @return FormMetaInformationInterface The meta informations about the form
|
||||
*/
|
||||
public function getFormMetaInformation(): FormMetaInformationInterface;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBasicPathString(): string;
|
||||
}
|
||||
|
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\PathManagement;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class NamespacePathMap implements NamespacePathMapInterface
|
||||
{
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
private $folders;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $namespace;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\PathManagement\NamespacePathMapInterface::getNamespace()
|
||||
*/
|
||||
public function getNamespace(): string
|
||||
{
|
||||
return $this->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\PathManagement\NamespacePathMapInterface::getPath()
|
||||
*/
|
||||
public function getPath(): string
|
||||
{
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\PathManagement\NamespacePathMapInterface::setPath()
|
||||
*/
|
||||
public function setPath(string $path): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\PathManagement\NamespacePathMapInterface::setNamespace()
|
||||
*/
|
||||
public function setNamespace(string $namespace): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\PathManagement\NamespacePathMapInterface::setFolderArray()
|
||||
*/
|
||||
public function setFolderArray(array $folders): void
|
||||
{
|
||||
}
|
||||
|
||||
public function getFolderArray(): array
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\PathManagement;
|
||||
|
||||
/**
|
||||
* Allows to map a path to an namespace.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface NamespacePathMapInterface
|
||||
{
|
||||
/**
|
||||
* @param string $namespace
|
||||
*/
|
||||
public function setNamespace(string $namespace): void;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function setPath(string $path): void;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNamespace(): string;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPath(): string;
|
||||
|
||||
/**
|
||||
* @param array|string[] $folders
|
||||
*/
|
||||
public function setFolderArray(array $folders): void;
|
||||
|
||||
/**
|
||||
* @return array|string[]
|
||||
*/
|
||||
public function getFolderArray(): array;
|
||||
}
|
@@ -3,12 +3,30 @@
|
||||
namespace App\Domain\SourceManagement;
|
||||
|
||||
use App\Domain\EntityManagement\EntityMetaInformation;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class SourceMetaInformation extends EntityMetaInformation implements SourceMetaInformationInterface
|
||||
{
|
||||
const UNPURE = 'source';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\EntityManagement\EntityMetaInformation::__construct()
|
||||
*
|
||||
* @param $entity AbstractSource
|
||||
*/
|
||||
public function __construct(\App\Entity\EntityInterface $entity)
|
||||
{
|
||||
if (!$entity instanceof AbstractSource) {
|
||||
throw new \TypeError('Entity has to be an instance of '.AbstractSource::class);
|
||||
}
|
||||
parent::__construct($entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
@@ -17,6 +35,6 @@ final class SourceMetaInformation extends EntityMetaInformation implements Sourc
|
||||
protected function setPureName(): void
|
||||
{
|
||||
parent::setPureName();
|
||||
$this->pureName = str_replace('Source', '', $this->pureName);
|
||||
$this->pureName = substr($this->pureName, 0, -strlen(self::UNPURE));
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,10 @@ use App\DBAL\Types\RESTResponseType;
|
||||
*/
|
||||
final class TemplatePathInformation implements TemplatePathInformationInterface
|
||||
{
|
||||
const MOLECULE_FOLDER = 'molecule';
|
||||
|
||||
const ATOM_FOLDER = 'atom';
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -73,12 +77,12 @@ final class TemplatePathInformation implements TemplatePathInformationInterface
|
||||
|
||||
private function setMoleculeTemplatePath(): void
|
||||
{
|
||||
$this->moleculeTemplatePath = 'molecule/'.$this->suffix;
|
||||
$this->moleculeTemplatePath = self::MOLECULE_FOLDER.'/'.$this->prefix.'/'.$this->suffix;
|
||||
}
|
||||
|
||||
private function setAtomTemplatePath(): void
|
||||
{
|
||||
$this->atomTemplatePath = 'atom/'.$this->suffix;
|
||||
$this->atomTemplatePath = self::ATOM_FOLDER.'/'.$this->prefix.'/'.$this->suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user