Implemented TemplateMeta and tests

This commit is contained in:
Kevin Frantz
2018-11-23 15:23:43 +01:00
parent 8a311caddc
commit b9a312cfd9
6 changed files with 124 additions and 16 deletions

View 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
{
}
}

View File

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

View File

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

View File

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