mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-18 19:09:20 +02:00
Implemented ActionTemplateNameService
This commit is contained in:
parent
a117d16429
commit
aa86cfce98
@ -6,3 +6,4 @@ twig:
|
|||||||
globals:
|
globals:
|
||||||
layer_action_map: "@Infinito\\Domain\\LayerManagement\\LayerActionMap"
|
layer_action_map: "@Infinito\\Domain\\LayerManagement\\LayerActionMap"
|
||||||
action_icon_class_map: "@Infinito\\Domain\\TwigManagement\\ActionIconClassMap"
|
action_icon_class_map: "@Infinito\\Domain\\TwigManagement\\ActionIconClassMap"
|
||||||
|
action_template_name_service: "@Infinito\\Domain\\TemplateManagement\\ActionTemplateNameServiceInterface"
|
@ -44,6 +44,9 @@ services:
|
|||||||
# add more service definitions when explicit configuration is needed
|
# add more service definitions when explicit configuration is needed
|
||||||
# please note that last definitions always *replace* previous ones
|
# please note that last definitions always *replace* previous ones
|
||||||
|
|
||||||
|
# Map Interfaces to concrete classes
|
||||||
|
Infinito\Domain\TemplateManagement\TemplateNameServiceInterface: "@Infinito\\Domain\\TemplateManagement\\TemplateNameService"
|
||||||
|
|
||||||
# Needed for integration tests
|
# Needed for integration tests
|
||||||
Infinito\Domain\RequestManagement\Entity\RequestedEntityService:
|
Infinito\Domain\RequestManagement\Entity\RequestedEntityService:
|
||||||
public: true
|
public: true
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Infinito\Domain\TemplateManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
final class ActionTemplateNameService extends TemplateNameService implements ActionTemplateNameServiceInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $actionType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getActionType(): string
|
||||||
|
{
|
||||||
|
if ($this->actionType) {
|
||||||
|
return $this->actionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->requestedActionService->getActionType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \Infinito\Domain\TemplateManagement\ActionTemplateNameServiceInterface::setActionType()
|
||||||
|
*/
|
||||||
|
public function setActionType(?string $actionType): void
|
||||||
|
{
|
||||||
|
$this->actionType = $actionType;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Infinito\Domain\TemplateManagement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows to manually define the action type.
|
||||||
|
*
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
interface ActionTemplateNameServiceInterface extends TemplateNameServiceInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* @see \Infinito\Attribut\ActionTypeAttributInterface::setActionType()
|
||||||
|
*/
|
||||||
|
public function setActionType(?string $actionType): void;
|
||||||
|
}
|
@ -7,7 +7,7 @@ use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
|||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
final class TemplateNameService implements TemplateNameServiceInterface
|
class TemplateNameService implements TemplateNameServiceInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var string The namespace which should be ignored
|
* @var string The namespace which should be ignored
|
||||||
@ -39,6 +39,22 @@ final class TemplateNameService implements TemplateNameServiceInterface
|
|||||||
*/
|
*/
|
||||||
private $requestedActionService;
|
private $requestedActionService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getActionType(): string
|
||||||
|
{
|
||||||
|
return $this->requestedActionService->getActionType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function getClass(): string
|
||||||
|
{
|
||||||
|
return $this->requestedActionService->getRequestedEntity()->getClass();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RequestedActionServiceInterface $requestedActionService
|
* @param RequestedActionServiceInterface $requestedActionService
|
||||||
*/
|
*/
|
||||||
@ -52,7 +68,7 @@ final class TemplateNameService implements TemplateNameServiceInterface
|
|||||||
*/
|
*/
|
||||||
private function getBasePath(): string
|
private function getBasePath(): string
|
||||||
{
|
{
|
||||||
$origineClass = $this->requestedActionService->getRequestedEntity()->getClass();
|
$origineClass = $this->getClass();
|
||||||
$baseReplaced = str_replace(self::BASE_NAMESPACE, self::BASE_ENTITY_TEMPLATE_FOLDER, $origineClass);
|
$baseReplaced = str_replace(self::BASE_NAMESPACE, self::BASE_ENTITY_TEMPLATE_FOLDER, $origineClass);
|
||||||
$elements = explode('\\', $baseReplaced);
|
$elements = explode('\\', $baseReplaced);
|
||||||
array_pop($elements); //Removes class name
|
array_pop($elements); //Removes class name
|
||||||
@ -67,7 +83,7 @@ final class TemplateNameService implements TemplateNameServiceInterface
|
|||||||
*/
|
*/
|
||||||
private function getShortName(): string
|
private function getShortName(): string
|
||||||
{
|
{
|
||||||
$origineClass = $this->requestedActionService->getRequestedEntity()->getClass();
|
$origineClass = $this->getClass();
|
||||||
$elements = explode('\\', $origineClass);
|
$elements = explode('\\', $origineClass);
|
||||||
$class = $elements[count($elements) - 1];
|
$class = $elements[count($elements) - 1];
|
||||||
$lcFirst = lcfirst($class);
|
$lcFirst = lcfirst($class);
|
||||||
@ -82,7 +98,7 @@ final class TemplateNameService implements TemplateNameServiceInterface
|
|||||||
*/
|
*/
|
||||||
private function getActionSuffix(): string
|
private function getActionSuffix(): string
|
||||||
{
|
{
|
||||||
return '_'.strtolower($this->requestedActionService->getActionType());
|
return '_'.strtolower($this->getActionType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user