mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Renamed domain LayerManagement to Layer
This commit is contained in:
46
application/symfony/src/Domain/Layer/LayerActionMap.php
Normal file
46
application/symfony/src/Domain/Layer/LayerActionMap.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Layer;
|
||||
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Domain\MapManagement\AbstractMap;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LayerActionMap extends AbstractMap implements LayerActionMapInterface
|
||||
{
|
||||
/**
|
||||
* @var array Add new combination possibilities to this map!
|
||||
*/
|
||||
const LAYER_ACTION_MAP = [
|
||||
LayerType::SOURCE => [
|
||||
ActionType::READ,
|
||||
ActionType::CREATE,
|
||||
ActionType::UPDATE,
|
||||
ActionType::DELETE,
|
||||
ActionType::EXECUTE,
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Layer\LayerActionMapInterface::getLayers()
|
||||
*/
|
||||
public static function getLayers(string $action): array
|
||||
{
|
||||
return parent::getIndizesByValue($action, self::LAYER_ACTION_MAP);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\Layer\LayerActionMapInterface::getActions()
|
||||
*/
|
||||
public static function getActions(string $layer): array
|
||||
{
|
||||
return parent::getValuesByIndex($layer, self::LAYER_ACTION_MAP);
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Layer;
|
||||
|
||||
/**
|
||||
* This LayerActionMap offers the possibility, to see which Action\Layer-Cobinations are possible.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LayerActionMapInterface
|
||||
{
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return array|string[]
|
||||
*/
|
||||
public static function getLayers(string $action): array;
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
*
|
||||
* @return array|string[]
|
||||
*/
|
||||
public static function getActions(string $layer): array;
|
||||
}
|
45
application/symfony/src/Domain/Layer/LayerClassMap.php
Normal file
45
application/symfony/src/Domain/Layer/LayerClassMap.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Layer;
|
||||
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
use Infinito\Entity\Source\AbstractSource;
|
||||
use Infinito\Exception\Collection\NotSetElementException;
|
||||
use Infinito\Entity\Meta\Law;
|
||||
use Infinito\Entity\Meta\Right;
|
||||
use Infinito\Entity\Meta\Relation\Parent\HeredityRelation;
|
||||
use Infinito\Entity\Meta\Relation\Member\MemberRelation;
|
||||
use Infinito\Entity\Meta\Relation\Parent\CreatorRelation;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class LayerClassMap implements LayerClassMapInterface
|
||||
{
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
const LAYER_CLASS_MAP = [
|
||||
LayerType::SOURCE => AbstractSource::class,
|
||||
LayerType::LAW => Law::class,
|
||||
LayerType::RIGHT => Right::class,
|
||||
LayerType::HEREDITY => HeredityRelation::class,
|
||||
LayerType::MEMBER => MemberRelation::class,
|
||||
LayerType::CREATOR => CreatorRelation::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
*
|
||||
* @throws NotSetElementException
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getClass(string $layer): string
|
||||
{
|
||||
if (array_key_exists($layer, self::LAYER_CLASS_MAP)) {
|
||||
return self::LAYER_CLASS_MAP[$layer];
|
||||
}
|
||||
throw new NotSetElementException('The requested layer is not mapped!');
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Layer;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LayerClassMapInterface
|
||||
{
|
||||
/**
|
||||
* @param string $layer
|
||||
*
|
||||
* @return string The class which belongs to an Layer
|
||||
*/
|
||||
public static function getClass(string $layer): string;
|
||||
}
|
77
application/symfony/src/Domain/Layer/LayerInterfaceMap.php
Normal file
77
application/symfony/src/Domain/Layer/LayerInterfaceMap.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Layer;
|
||||
|
||||
use Infinito\DBAL\Types\Meta\Right\LayerType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo for performance reasons it could be helpfull to implement lazy loading in the future
|
||||
*/
|
||||
final class LayerInterfaceMap implements LayerInterfaceMapInterface
|
||||
{
|
||||
/**
|
||||
* @var string The abstract class prefix, which will be removed from the interface name
|
||||
*/
|
||||
const ABSTRACT_CLASS_PREFIX = 'Abstract';
|
||||
|
||||
/**
|
||||
* @var string The suffix which will be added to the interface name
|
||||
*/
|
||||
const INTERFACE_SUFFIX = 'Interface';
|
||||
|
||||
/**
|
||||
* @param string $shortClass
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function filterAbstractClassName(string $shortClass): string
|
||||
{
|
||||
if (self::ABSTRACT_CLASS_PREFIX === substr($shortClass, 0, strlen(self::ABSTRACT_CLASS_PREFIX))) {
|
||||
return substr($shortClass, strlen(self::ABSTRACT_CLASS_PREFIX));
|
||||
}
|
||||
|
||||
return $shortClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function addInterfaceSuffix(string $class): string
|
||||
{
|
||||
return $class.self::INTERFACE_SUFFIX;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getInterface(string $layer): string
|
||||
{
|
||||
$className = LayerClassMap::getClass($layer);
|
||||
$elements = explode('\\', $className);
|
||||
$shortClass = $elements[count($elements) - 1];
|
||||
$filteredAbstractClass = self::filterAbstractClassName($shortClass);
|
||||
$elements[count($elements) - 1] = self::addInterfaceSuffix($filteredAbstractClass);
|
||||
$interfaceName = implode('\\', $elements);
|
||||
|
||||
return $interfaceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getAllInterfaces(): array
|
||||
{
|
||||
$allInterfaces = [];
|
||||
foreach (LayerType::getValues() as $layer) {
|
||||
$allInterfaces[$layer] = self::getInterface($layer);
|
||||
}
|
||||
|
||||
return $allInterfaces;
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Layer;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface LayerInterfaceMapInterface
|
||||
{
|
||||
/**
|
||||
* @return array|string[] All layer interfaces
|
||||
*/
|
||||
public static function getAllInterfaces(): array;
|
||||
|
||||
/**
|
||||
* @param string $layer
|
||||
*
|
||||
* @return string The interface which belongs to an Layer
|
||||
*/
|
||||
public static function getInterface(string $layer): string;
|
||||
}
|
Reference in New Issue
Block a user