Implemented FrameFunctionalTest

This commit is contained in:
Kevin Frantz
2019-03-28 16:31:03 +01:00
parent 2a1b5f2a99
commit 421e8cfdd3
4 changed files with 55 additions and 75 deletions

View File

@@ -1,4 +1,5 @@
<?php
namespace Infinito\Domain\ViewManagement;
use FOS\RestBundle\View\View;
@@ -6,60 +7,50 @@ use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Infinito\Domain\ActionManagement\ActionServiceInterface;
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
use Infinito\Domain\ParameterManagement\OptionalGetParameterService;
use Infinito\Domain\ParameterManagement\OptionalGetParameterServiceInterface;
/**
*
* @author kevinfrantz
*/
final class ViewBuilder implements ViewBuilderInterface
{
/**
*
* @var string The path to the atom entity template
*/
const TWIG_ENTITY_ATOM_TEMPLATE_PATH = 'entity/_entity.html.twig';
/**
*
* @var string The path to the molecule entity template
*/
const TWIG_ENTITY_MOLECULE_TEMPLATE_PATH = 'entity/entity.html.twig';
/**
*
* @var View
*/
private $view;
/**
*
* @var RequestedActionInterface
*/
private $actionService;
/**
*
* @var ActionFactoryServiceInterface
*/
private $actionFactoryService;
/**
*
* @var TemplateNameServiceInterface
*/
private $templateNameService;
/**
*
* @var OptionalGetParameterServiceInterface
*/
private $optionalGetParameterService;
/**
* Containes the routine to decide if the template should be loaded with or without frame
* Containes the routine to decide if the template should be loaded with or without frame.
*
* @return bool
*/
@@ -68,6 +59,7 @@ final class ViewBuilder implements ViewBuilderInterface
if ($this->optionalGetParameterService->hasParameter(OptionalGetParameterServiceInterface::FRAME_PARAMETER)) {
return $this->optionalGetParameterService->getParameter(OptionalGetParameterServiceInterface::FRAME_PARAMETER);
}
return true;
}
@@ -76,7 +68,7 @@ final class ViewBuilder implements ViewBuilderInterface
* 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
@@ -85,17 +77,18 @@ final class ViewBuilder implements ViewBuilderInterface
if ($this->templateNameService->doesMoleculeTemplateExist()) {
return $this->templateNameService->getMoleculeTemplateName();
}
return self::TWIG_ENTITY_MOLECULE_TEMPLATE_PATH;
}
if ($this->templateNameService->doesAtomTemplateExist()) {
return $this->templateNameService->getAtomTemplateName();
}
return self::TWIG_ENTITY_ATOM_TEMPLATE_PATH;
}
/**
*
* @param ActionServiceInterface $actionService
* @param ActionServiceInterface $actionService
* @param ActionFactoryServiceInterface $actionFactoryService
*/
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService, OptionalGetParameterServiceInterface $optionalGetParameterService)
@@ -107,7 +100,6 @@ final class ViewBuilder implements ViewBuilderInterface
}
/**
*
* @return View
*/
public function getView(): View
@@ -119,7 +111,6 @@ final class ViewBuilder implements ViewBuilderInterface
}
/**
*
* {@inheritdoc}
*
* @see \Infinito\Domain\ViewManagement\ViewBuilderInterface::getActionService()
@@ -130,7 +121,6 @@ final class ViewBuilder implements ViewBuilderInterface
}
/**
*
* {@inheritdoc}
*
* @see \Infinito\Domain\ViewManagement\ViewBuilderInterface::build()