mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Implemented ActionTemplateNameService
This commit is contained in:
		@@ -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
 | 
			
		||||
 */
 | 
			
		||||
final class TemplateNameService implements TemplateNameServiceInterface
 | 
			
		||||
class TemplateNameService implements TemplateNameServiceInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var string The namespace which should be ignored
 | 
			
		||||
@@ -39,6 +39,22 @@ final class TemplateNameService implements TemplateNameServiceInterface
 | 
			
		||||
     */
 | 
			
		||||
    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
 | 
			
		||||
     */
 | 
			
		||||
@@ -52,7 +68,7 @@ final class TemplateNameService implements TemplateNameServiceInterface
 | 
			
		||||
     */
 | 
			
		||||
    private function getBasePath(): string
 | 
			
		||||
    {
 | 
			
		||||
        $origineClass = $this->requestedActionService->getRequestedEntity()->getClass();
 | 
			
		||||
        $origineClass = $this->getClass();
 | 
			
		||||
        $baseReplaced = str_replace(self::BASE_NAMESPACE, self::BASE_ENTITY_TEMPLATE_FOLDER, $origineClass);
 | 
			
		||||
        $elements = explode('\\', $baseReplaced);
 | 
			
		||||
        array_pop($elements); //Removes class name
 | 
			
		||||
@@ -67,7 +83,7 @@ final class TemplateNameService implements TemplateNameServiceInterface
 | 
			
		||||
     */
 | 
			
		||||
    private function getShortName(): string
 | 
			
		||||
    {
 | 
			
		||||
        $origineClass = $this->requestedActionService->getRequestedEntity()->getClass();
 | 
			
		||||
        $origineClass = $this->getClass();
 | 
			
		||||
        $elements = explode('\\', $origineClass);
 | 
			
		||||
        $class = $elements[count($elements) - 1];
 | 
			
		||||
        $lcFirst = lcfirst($class);
 | 
			
		||||
@@ -82,7 +98,7 @@ final class TemplateNameService implements TemplateNameServiceInterface
 | 
			
		||||
     */
 | 
			
		||||
    private function getActionSuffix(): string
 | 
			
		||||
    {
 | 
			
		||||
        return '_'.strtolower($this->requestedActionService->getActionType());
 | 
			
		||||
        return '_'.strtolower($this->getActionType());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user