mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Implemented TemplateMeta and tests
This commit is contained in:
16
application/src/Domain/FormManagement/FormMeta.php
Normal file
16
application/src/Domain/FormManagement/FormMeta.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\FormManagement;
|
||||
|
||||
use App\Domain\SourceManagement\SourceMetaInterface;
|
||||
|
||||
class FormMeta implements FormMetaInterface
|
||||
{
|
||||
public function __construct(SourceMetaInterface $source)
|
||||
{
|
||||
}
|
||||
|
||||
public function getFormPath(): string
|
||||
{
|
||||
}
|
||||
}
|
@@ -54,7 +54,7 @@ class SourceMeta implements SourceMetaInterface
|
||||
private function setBasicPathArray(): void
|
||||
{
|
||||
$namespace = $this->sourceReflection->getNamespaceName();
|
||||
$namespaceWithoutRoot = str_replace('App\\', '', $namespace);
|
||||
$namespaceWithoutRoot = str_replace('App\\Entity\\', '', $namespace);
|
||||
$this->basicPathArray = [];
|
||||
foreach (explode('\\', $namespaceWithoutRoot) as $element) {
|
||||
$this->basicPathArray[] = strtolower($element);
|
||||
|
@@ -2,14 +2,16 @@
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
use App\Domain\FormManagement\FormMetaInterface;
|
||||
use App\Domain\SourceManagement\SourceMetaInterface;
|
||||
use App\DBAL\Types\TemplateType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class TemplateMeta implements TemplateMetaInterface
|
||||
{
|
||||
/**
|
||||
* @var TemplateMetaInterface
|
||||
* @var SourceMetaInterface
|
||||
*/
|
||||
private $sourceMeta;
|
||||
|
||||
@@ -18,24 +20,67 @@ class TemplateMeta implements TemplateMetaInterface
|
||||
*/
|
||||
private $type = TemplateType::HTML;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pathSuffix;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $frameTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentTemplatePath;
|
||||
|
||||
public function __construct(SourceMetaInterface $sourceMeta)
|
||||
{
|
||||
$this->sourceMeta = $sourceMeta;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function getFramedTemplatePath(): string
|
||||
private function init()
|
||||
{
|
||||
$this->setPathSuffix();
|
||||
$this->setFrameTemplatePath();
|
||||
$this->setContentTemplatePath();
|
||||
}
|
||||
|
||||
public function getFramelessTemplatePath(): string
|
||||
private function setPathSuffix(): void
|
||||
{
|
||||
$this->pathSuffix = implode('/', $this->sourceMeta->getBasicPathArray()).'/'.$this->sourceMeta->getBasicName().'.'.$this->type.'.twig';
|
||||
}
|
||||
|
||||
public function getFormMeta(): FormMetaInterface
|
||||
private function setFrameTemplatePath(): void
|
||||
{
|
||||
$this->frameTemplatePath = 'frame/'.$this->pathSuffix;
|
||||
}
|
||||
|
||||
private function setContentTemplatePath(): void
|
||||
{
|
||||
$this->contentTemplatePath = 'content/'.$this->pathSuffix;
|
||||
}
|
||||
|
||||
public function getFrameTemplatePath(): string
|
||||
{
|
||||
return $this->frameTemplatePath;
|
||||
}
|
||||
|
||||
public function getContentTemplatePath(): string
|
||||
{
|
||||
return $this->contentTemplatePath;
|
||||
}
|
||||
|
||||
public function setTemplateType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
public function getTemplateType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
use App\Domain\FormManagement\FormMetaInterface;
|
||||
|
||||
/**
|
||||
* Manages all informations which are needed to process templates.
|
||||
*
|
||||
@@ -16,22 +14,19 @@ interface TemplateMetaInterface
|
||||
*/
|
||||
public function setTemplateType(string $type): void;
|
||||
|
||||
public function getTemplateType(): string;
|
||||
|
||||
/**
|
||||
* Returns a template inclusiv frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFramedTemplatePath(): string;
|
||||
public function getFrameTemplatePath(): string;
|
||||
|
||||
/**
|
||||
* Returns a template without a frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFramelessTemplatePath(): string;
|
||||
|
||||
/**
|
||||
* @return FormMetaInterface
|
||||
*/
|
||||
public function getFormMeta(): FormMetaInterface;
|
||||
public function getContentTemplatePath(): string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user