mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Optimized draft for meta and template informations
This commit is contained in:
@@ -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;
|
||||
}
|
Reference in New Issue
Block a user