mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Optimized view generation process
This commit is contained in:
@@ -6,6 +6,7 @@ use FOS\RestBundle\View\View;
|
||||
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
|
||||
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -27,14 +28,37 @@ final class ViewBuilder implements ViewBuilderInterface
|
||||
*/
|
||||
private $actionFactoryService;
|
||||
|
||||
/**
|
||||
* @var TemplateNameServiceInterface
|
||||
*/
|
||||
private $templateNameService;
|
||||
|
||||
/**
|
||||
* Don't know if this function will be usefull in the future.
|
||||
* Feel free to remove it if this should not be the case.
|
||||
*
|
||||
* @todo Implement tests
|
||||
*
|
||||
* @return string The general entity template or a individual template if it is set
|
||||
*/
|
||||
private function getTemplate(): string
|
||||
{
|
||||
if ($this->templateNameService->doesMoleculeTemplateExist()) {
|
||||
return $this->templateNameService->getMoleculeTemplateName();
|
||||
}
|
||||
|
||||
return self::TWIG_ENTITY_TEMPLATE_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ActionServiceInterface $actionService
|
||||
* @param ActionFactoryServiceInterface $actionFactoryService
|
||||
*/
|
||||
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService)
|
||||
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService)
|
||||
{
|
||||
$this->view = new View();
|
||||
$this->view = View::create();
|
||||
$this->actionService = $actionService;
|
||||
$this->templateNameService = $templateNameService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -42,10 +66,10 @@ final class ViewBuilder implements ViewBuilderInterface
|
||||
*/
|
||||
public function getView(): View
|
||||
{
|
||||
$view = View::create();
|
||||
$view->setTemplate(self::TWIG_ENTITY_TEMPLATE_PATH);
|
||||
$template = $this->getTemplate();
|
||||
$this->view->setTemplate($template);
|
||||
|
||||
return $view;
|
||||
return $this->view;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user