Optimized draft for meta and template informations

This commit is contained in:
Kevin Frantz
2019-01-06 11:32:05 +01:00
parent 77cd11233d
commit 73a8d5f133
17 changed files with 601 additions and 372 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -1,12 +0,0 @@
<?php
namespace App\Domain\FormManagement;
use App\Domain\TemplateManagement\TemplateMetaInterface;
interface FormMetaInterface
{
public function getFormClass(): string;
public function getTemplateMeta(): TemplateMetaInterface;
}