Prepared structure for forms

This commit is contained in:
Kevin Frantz
2018-09-17 13:09:04 +02:00
parent 54a2a6a19c
commit 72ddc46712
13 changed files with 83 additions and 32 deletions

View File

@@ -1,20 +1,19 @@
<?php
namespace App\Creator\Factory\Template;
namespace App\Creator\Factory\Template\Source;
use App\Entity\SourceInterface;
use Symfony\Component\HttpFoundation\Request;
/**
* Didn't know where to structure this file and how to name it.
* Feel free to move it to a better place.
*
* @author kevinfrantz
*/
class SourceTemplateFactory
{
const SOURCE_TEMPLATE_ROOT = 'source';
const VIEW_FOLDER = 'view';
/**
* @var SourceInterface
*/
@@ -36,10 +35,10 @@ class SourceTemplateFactory
public function getTemplatePath(): string
{
return self::SOURCE_TEMPLATE_ROOT.'/'.$this->generateName().'.'.$this->request->getRequestFormat().'.twig';
return self::SOURCE_TEMPLATE_ROOT.'/'.self::VIEW_FOLDER.'/'.$this->generateName().'.'.$this->request->getRequestFormat().'.twig';
}
private function generateName(): string
protected function generateName(): string
{
$reflection = new \ReflectionClass($this->source);
$shortName = $reflection->getShortName();

View File

@@ -0,0 +1,18 @@
<?php
namespace App\Creator\Factory\Template\Source;
/**
*
* @author kevinfrantz
*
*/
class SourceTemplateFormFactory extends SourceTemplateFactory
{
const FORM_FOLDER = 'form';
public function getTemplatePath(): string
{
return parent::SOURCE_TEMPLATE_ROOT.'/'.self::FORM_FOLDER.'/'.$this->generateName().'.'.$this->request->getRequestFormat().'.twig';
}
}