Optimized view generation process

This commit is contained in:
Kevin Frantz 2019-03-28 13:26:40 +01:00
parent 4a129b172b
commit 13b45b31ae
8 changed files with 44 additions and 20 deletions

View File

@ -19,7 +19,6 @@ final class MemberManager implements MemberManagerInterface
private $memberRelation; private $memberRelation;
/** /**
*
* @param MemberRelationInterface $memberRelation * @param MemberRelationInterface $memberRelation
*/ */
public function __construct(MemberRelationInterface $memberRelation) public function __construct(MemberRelationInterface $memberRelation)
@ -28,8 +27,8 @@ final class MemberManager implements MemberManagerInterface
} }
/** /**
* * {@inheritdoc}
* {@inheritDoc} *
* @see \Infinito\Domain\MemberManagement\MemberManagerInterface::addMember() * @see \Infinito\Domain\MemberManagement\MemberManagerInterface::addMember()
*/ */
public function addMember(MemberRelationInterface $member): void public function addMember(MemberRelationInterface $member): void
@ -41,8 +40,8 @@ final class MemberManager implements MemberManagerInterface
} }
/** /**
* * {@inheritdoc}
* {@inheritDoc} *
* @see \Infinito\Domain\MemberManagement\MemberManagerInterface::removeMember() * @see \Infinito\Domain\MemberManagement\MemberManagerInterface::removeMember()
*/ */
public function removeMember(MemberRelationInterface $member): void public function removeMember(MemberRelationInterface $member): void
@ -54,8 +53,8 @@ final class MemberManager implements MemberManagerInterface
} }
/** /**
* * {@inheritdoc}
* {@inheritDoc} *
* @see \Infinito\Domain\MemberManagement\MemberManagerInterface::addMembership() * @see \Infinito\Domain\MemberManagement\MemberManagerInterface::addMembership()
*/ */
public function addMembership(MemberRelationInterface $membership): void public function addMembership(MemberRelationInterface $membership): void
@ -67,8 +66,8 @@ final class MemberManager implements MemberManagerInterface
} }
/** /**
* * {@inheritdoc}
* {@inheritDoc} *
* @see \Infinito\Domain\MemberManagement\MemberManagerInterface::removeMembership() * @see \Infinito\Domain\MemberManagement\MemberManagerInterface::removeMembership()
*/ */
public function removeMembership(MemberRelationInterface $membership): void public function removeMembership(MemberRelationInterface $membership): void

View File

@ -5,9 +5,7 @@ namespace Infinito\Domain\MemberManagement;
use Infinito\Entity\Meta\Relation\Member\MemberRelationInterface; use Infinito\Entity\Meta\Relation\Member\MemberRelationInterface;
/** /**
*
* @author kevinfrantz * @author kevinfrantz
*
*/ */
interface MemberManagerInterface interface MemberManagerInterface
{ {

View File

@ -65,6 +65,7 @@ final class ProcessService implements ProcessServiceInterface
} }
/** /**
* @todo Move
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ProcessManagement\ProcessServiceInterface::process() * @see \Infinito\Domain\ProcessManagement\ProcessServiceInterface::process()

View File

@ -10,7 +10,7 @@ use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
class TemplateNameService implements TemplateNameServiceInterface class TemplateNameService implements TemplateNameServiceInterface
{ {
/** /**
* @var unknown * @var string
*/ */
const BASE_TEMPLATE_DIR = __DIR__.'/../../../templates/'; const BASE_TEMPLATE_DIR = __DIR__.'/../../../templates/';
@ -136,6 +136,11 @@ class TemplateNameService implements TemplateNameServiceInterface
return $this->getTemplatePath(self::MOLECULE_PRAEFFIX); return $this->getTemplatePath(self::MOLECULE_PRAEFFIX);
} }
/**
* @param string $template
*
* @return bool
*/
private function templateExists(string $template): bool private function templateExists(string $template): bool
{ {
return file_exists(self::BASE_TEMPLATE_DIR.$template); return file_exists(self::BASE_TEMPLATE_DIR.$template);

View File

@ -6,6 +6,7 @@ use FOS\RestBundle\View\View;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface; use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionServiceInterface;
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface; use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -27,14 +28,37 @@ final class ViewBuilder implements ViewBuilderInterface
*/ */
private $actionFactoryService; 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 ActionServiceInterface $actionService
* @param ActionFactoryServiceInterface $actionFactoryService * @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->actionService = $actionService;
$this->templateNameService = $templateNameService;
} }
/** /**
@ -42,10 +66,10 @@ final class ViewBuilder implements ViewBuilderInterface
*/ */
public function getView(): View public function getView(): View
{ {
$view = View::create(); $template = $this->getTemplate();
$view->setTemplate(self::TWIG_ENTITY_TEMPLATE_PATH); $this->view->setTemplate($template);
return $view; return $this->view;
} }
/** /**

View File

@ -1 +0,0 @@
{{ action_template_data_store_service.getData(action).text }}

View File

@ -1 +0,0 @@
{{ form(action_template_data_store_service.getData(action)) }}

View File

@ -1 +0,0 @@
{% extends "entity/source/source.html.twig" %}