mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Implemented formMeta
This commit is contained in:
parent
b9a312cfd9
commit
2009f1b691
@ -3,14 +3,55 @@
|
|||||||
namespace App\Domain\FormManagement;
|
namespace App\Domain\FormManagement;
|
||||||
|
|
||||||
use App\Domain\SourceManagement\SourceMetaInterface;
|
use App\Domain\SourceManagement\SourceMetaInterface;
|
||||||
|
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||||
|
use App\Domain\TemplateManagement\TemplateMeta;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
class FormMeta implements FormMetaInterface
|
class FormMeta implements FormMetaInterface
|
||||||
{
|
{
|
||||||
public function __construct(SourceMetaInterface $source)
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getFormPath(): string
|
private function setFormClass(): void
|
||||||
{
|
{
|
||||||
|
$this->formClass = 'App\\Form\\'.implode('\\', $this->sourceMeta->getBasicPathArray()).'\\'.$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(): string
|
||||||
|
{
|
||||||
|
return $this->templateMeta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,5 +4,7 @@ namespace App\Domain\FormManagement;
|
|||||||
|
|
||||||
interface FormMetaInterface
|
interface FormMetaInterface
|
||||||
{
|
{
|
||||||
public function getFormPath(): string;
|
public function getFormClass(): string;
|
||||||
|
|
||||||
|
public function getTemplateMeta(): string;
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,11 @@
|
|||||||
|
|
||||||
namespace App\Domain\SourceManagement;
|
namespace App\Domain\SourceManagement;
|
||||||
|
|
||||||
|
use App\Domain\FormManagement\FormMetaInterface;
|
||||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
use App\Domain\TemplateManagement\TemplateMeta;
|
use App\Domain\TemplateManagement\TemplateMeta;
|
||||||
|
use App\Domain\FormManagement\FormMeta;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -41,6 +43,11 @@ class SourceMeta implements SourceMetaInterface
|
|||||||
*/
|
*/
|
||||||
private $source;
|
private $source;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var FormMetaInterface
|
||||||
|
*/
|
||||||
|
private $formMeta;
|
||||||
|
|
||||||
public function __construct(SourceInterface $source)
|
public function __construct(SourceInterface $source)
|
||||||
{
|
{
|
||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
@ -48,7 +55,8 @@ class SourceMeta implements SourceMetaInterface
|
|||||||
$this->setBasicPathArray();
|
$this->setBasicPathArray();
|
||||||
$this->setBasicName();
|
$this->setBasicName();
|
||||||
$this->setInterfaceReflection();
|
$this->setInterfaceReflection();
|
||||||
$this->templateMeta = new TemplateMeta($this);
|
$this->templateMeta = new TemplateMeta($this->basicPathArray, $this->basicName, 'entity');
|
||||||
|
$this->formMeta = new FormMeta($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setBasicPathArray(): void
|
private function setBasicPathArray(): void
|
||||||
@ -103,4 +111,9 @@ class SourceMeta implements SourceMetaInterface
|
|||||||
{
|
{
|
||||||
return $this->source;
|
return $this->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getFormMeta(): FormMetaInterface
|
||||||
|
{
|
||||||
|
return $this->formMeta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ namespace App\Domain\SourceManagement;
|
|||||||
|
|
||||||
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
use App\Domain\TemplateManagement\TemplateMetaInterface;
|
||||||
use App\Entity\Source\SourceInterface;
|
use App\Entity\Source\SourceInterface;
|
||||||
|
use App\Domain\FormManagement\FormMetaInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A meta source offers informations, which the system needs to handle the source.
|
* A meta source offers informations, which the system needs to handle the source.
|
||||||
@ -32,4 +33,6 @@ interface SourceMetaInterface
|
|||||||
* @return SourceInterface The source to which the meta object belongs to
|
* @return SourceInterface The source to which the meta object belongs to
|
||||||
*/
|
*/
|
||||||
public function getSource(): SourceInterface;
|
public function getSource(): SourceInterface;
|
||||||
|
|
||||||
|
public function getFormMeta(): FormMetaInterface;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
namespace App\Domain\TemplateManagement;
|
namespace App\Domain\TemplateManagement;
|
||||||
|
|
||||||
use App\Domain\SourceManagement\SourceMetaInterface;
|
|
||||||
use App\DBAL\Types\TemplateType;
|
use App\DBAL\Types\TemplateType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -11,9 +10,14 @@ use App\DBAL\Types\TemplateType;
|
|||||||
class TemplateMeta implements TemplateMetaInterface
|
class TemplateMeta implements TemplateMetaInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var SourceMetaInterface
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $sourceMeta;
|
private $basicPathArray;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $basicName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string
|
* @var string
|
||||||
@ -35,9 +39,16 @@ class TemplateMeta implements TemplateMetaInterface
|
|||||||
*/
|
*/
|
||||||
private $contentTemplatePath;
|
private $contentTemplatePath;
|
||||||
|
|
||||||
public function __construct(SourceMetaInterface $sourceMeta)
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $folder;
|
||||||
|
|
||||||
|
public function __construct(array $basicPathArray, string $basicName, string $folder)
|
||||||
{
|
{
|
||||||
$this->sourceMeta = $sourceMeta;
|
$this->basicPathArray = $basicPathArray;
|
||||||
|
$this->basicName = $basicName;
|
||||||
|
$this->folder = $folder;
|
||||||
$this->init();
|
$this->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +61,7 @@ class TemplateMeta implements TemplateMetaInterface
|
|||||||
|
|
||||||
private function setPathSuffix(): void
|
private function setPathSuffix(): void
|
||||||
{
|
{
|
||||||
$this->pathSuffix = implode('/', $this->sourceMeta->getBasicPathArray()).'/'.$this->sourceMeta->getBasicName().'.'.$this->type.'.twig';
|
$this->pathSuffix = $this->folder.'/'.implode('/', $this->basicPathArray).'/'.$this->basicName.'.'.$this->type.'.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setFrameTemplatePath(): void
|
private function setFrameTemplatePath(): void
|
||||||
@ -83,4 +94,9 @@ class TemplateMeta implements TemplateMetaInterface
|
|||||||
{
|
{
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPathSuffix(): string
|
||||||
|
{
|
||||||
|
return $this->pathSuffix;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,14 @@ class TemplateMetaTest extends TestCase
|
|||||||
|
|
||||||
private function getExpectedPath(string $type, string $context): string
|
private function getExpectedPath(string $type, string $context): string
|
||||||
{
|
{
|
||||||
return $context.'/source/primitive/name/firstname.'.$type.'.twig';
|
return $context.'/entity/source/primitive/name/firstname.'.$type.'.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp(): void
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$this->source = new FirstNameSource();
|
$this->source = new FirstNameSource();
|
||||||
$this->templateMeta = new TemplateMeta(new SourceMeta($this->source));
|
$sourceMeta = new SourceMeta($this->source);
|
||||||
|
$this->templateMeta = new TemplateMeta($sourceMeta->getBasicPathArray(), $sourceMeta->getBasicName(), 'entity');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFrameTemplatePath(): void
|
public function testFrameTemplatePath(): void
|
||||||
|
Loading…
Reference in New Issue
Block a user