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:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
use App\DBAL\Types\RESTResponseType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ReloadTypeInterface
|
||||
{
|
||||
/**
|
||||
* Reloads a Template type.
|
||||
*
|
||||
* @see RESTResponseType::$choices
|
||||
*
|
||||
* @param string $type
|
||||
*/
|
||||
public function reloadType(string $type): void;
|
||||
}
|
@@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
use App\DBAL\Types\RESTResponseType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class TemplateMeta implements TemplateMetaInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $basicPathArray;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $basicName;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $type = RESTResponseType::HTML;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $pathSuffix;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $frameTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $contentTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $folder;
|
||||
|
||||
public function __construct(array $basicPathArray, string $basicName, string $folder)
|
||||
{
|
||||
$this->basicPathArray = $basicPathArray;
|
||||
$this->basicName = $basicName;
|
||||
$this->folder = $folder;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
private function init()
|
||||
{
|
||||
$this->setPathSuffix();
|
||||
$this->setFrameTemplatePath();
|
||||
$this->setContentTemplatePath();
|
||||
}
|
||||
|
||||
private function setPathSuffix(): void
|
||||
{
|
||||
$this->pathSuffix = $this->folder.'/'.implode('/', $this->basicPathArray).'/'.$this->basicName.'.'.$this->type.'.twig';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
/**
|
||||
* Manages all informations which are needed to process templates.
|
||||
*
|
||||
* @deprecated
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface TemplateMetaInterface
|
||||
{
|
||||
/**
|
||||
* Sets the template type which should be processed(General html);.
|
||||
*/
|
||||
public function setTemplateType(string $type): void;
|
||||
|
||||
public function getTemplateType(): string;
|
||||
|
||||
/**
|
||||
* Returns a template inclusiv frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFrameTemplatePath(): string;
|
||||
|
||||
/**
|
||||
* Returns a template without a frame.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getContentTemplatePath(): string;
|
||||
}
|
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace src\Domain\TemplateManagement;
|
||||
|
||||
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
||||
use App\Domain\TemplateManagement\TemplatePathInformation;
|
||||
use App\Domain\TemplateManagement\TemplatePathInformationInterface;
|
||||
use App\Domain\FormManagement\FormMeta;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class TemplatePathFormAndView implements TemplatePathFormAndViewInterface
|
||||
{
|
||||
const FORM_FOLDER = FormMeta::FOLDER;
|
||||
|
||||
const VIEW_FOLDER = 'view';
|
||||
|
||||
/**
|
||||
* @var TemplatePathInformation
|
||||
*/
|
||||
private $form;
|
||||
|
||||
/**
|
||||
* @var TemplatePathInformation
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $folder
|
||||
* @param string $type
|
||||
*/
|
||||
public function __construct(string $file, string $folder)
|
||||
{
|
||||
$this->setForm($file, $folder);
|
||||
$this->setView($file, $folder);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $folder
|
||||
*/
|
||||
private function setForm(string $file, string $folder): void
|
||||
{
|
||||
$this->form = new TemplatePathInformation($file, $folder, self::FORM_FOLDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $folder
|
||||
*/
|
||||
private function setView(string $file, string $folder): void
|
||||
{
|
||||
$this->view = new TemplatePathInformation($file, $folder, $type, self::VIEW_FOLDER);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\TemplateManagement\TemplatePathFormAndViewInterface::getForm()
|
||||
*/
|
||||
public function getForm(): TemplatePathInformationInterface
|
||||
{
|
||||
return $this->form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\TemplateManagement\TemplatePathFormAndViewInterface::getView()
|
||||
*/
|
||||
public function getView(): TemplatePathInformation
|
||||
{
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\TemplateManagement\ReloadTypeInterface::reloadType()
|
||||
*/
|
||||
public function reloadType(string $type): void
|
||||
{
|
||||
$this->view->reloadType($type);
|
||||
$this->form->reloadType($type);
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface TemplatePathFormAndViewInterface extends ReloadTypeInterface
|
||||
{
|
||||
/**
|
||||
* @return TemplatePathInformationInterface
|
||||
*/
|
||||
public function getForm(): TemplatePathInformationInterface;
|
||||
|
||||
/**
|
||||
* @return TemplatePathInformationInterface
|
||||
*/
|
||||
public function getView(): TemplatePathInformation;
|
||||
}
|
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
use App\DBAL\Types\RESTResponseType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class TemplatePathInformation implements TemplatePathInformationInterface
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $file;
|
||||
|
||||
/**
|
||||
* @see RESTResponseType::$choices
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $type = RESTResponseType::HTML;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $suffix;
|
||||
|
||||
/**
|
||||
* @var string Template withouth frame
|
||||
*/
|
||||
private $atomTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string Template with frame
|
||||
*/
|
||||
private $moleculeTemplatePath;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $folder;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $prefix;
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param string $folder
|
||||
* @param string $prefix
|
||||
*/
|
||||
public function __construct(string $file, string $folder, string $prefix = '')
|
||||
{
|
||||
$this->file = $file;
|
||||
$this->folder = $folder;
|
||||
$this->prefix = $prefix;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
private function init(): void
|
||||
{
|
||||
$this->setPathSuffix();
|
||||
$this->setMoleculeTemplatePath();
|
||||
$this->setAtomTemplatePath();
|
||||
}
|
||||
|
||||
private function setPathSuffix(): void
|
||||
{
|
||||
$this->suffix = $this->folder.'/'.$this->file.'.'.$this->type.'.twig';
|
||||
}
|
||||
|
||||
private function setMoleculeTemplatePath(): void
|
||||
{
|
||||
$this->moleculeTemplatePath = 'molecule/'.$this->suffix;
|
||||
}
|
||||
|
||||
private function setAtomTemplatePath(): void
|
||||
{
|
||||
$this->atomTemplatePath = 'atom/'.$this->suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::getAtomTemplatePath()
|
||||
*/
|
||||
public function getAtomTemplatePath(): string
|
||||
{
|
||||
return $this->atomTemplatePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::getMoleculeTemplatePath()
|
||||
*/
|
||||
public function getMoleculeTemplatePath(): string
|
||||
{
|
||||
return $this->moleculeTemplatePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\TemplateManagement\TemplatePathInformationInterface::reloadType()
|
||||
*/
|
||||
public function reloadType(string $type): void
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->init();
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\TemplateManagement;
|
||||
|
||||
/**
|
||||
* Manages all informations which are needed to process templates.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface TemplatePathInformationInterface extends ReloadTypeInterface
|
||||
{
|
||||
/**
|
||||
* @return string A template inclusiv frame. (Standalone)
|
||||
*/
|
||||
public function getMoleculeTemplatePath(): string;
|
||||
|
||||
/**
|
||||
* @return string a template without a frame
|
||||
*/
|
||||
public function getAtomTemplatePath(): string;
|
||||
}
|
Reference in New Issue
Block a user