mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-18 16:16:02 +02:00
Renamed domain MapManagement to Map
This commit is contained in:
44
application/symfony/src/Domain/Map/AbstractMap.php
Normal file
44
application/symfony/src/Domain/Map/AbstractMap.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Map;
|
||||
|
||||
/**
|
||||
* This class offers the basic functions for managing an 2 dimensional map.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractMap implements MapInterface
|
||||
{
|
||||
/**
|
||||
* @param string $index
|
||||
* @param array|string[] $map
|
||||
*
|
||||
* @return array|string[]
|
||||
*/
|
||||
protected static function getValuesByIndex(string $index, array $map): array
|
||||
{
|
||||
if (array_key_exists($index, $map)) {
|
||||
return $map[$index];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param array|string[] $map
|
||||
*
|
||||
* @return array|string[]
|
||||
*/
|
||||
protected static function getIndizesByValue(string $value, array $map): array
|
||||
{
|
||||
$result = [];
|
||||
foreach ($map as $index => $values) {
|
||||
if (in_array($value, $values)) {
|
||||
$result[] = $index;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
45
application/symfony/src/Domain/Map/ActionHttpMethodMap.php
Normal file
45
application/symfony/src/Domain/Map/ActionHttpMethodMap.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Map;
|
||||
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ActionHttpMethodMap extends AbstractMap implements ActionHttpMethodMapInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
const ACTION_HTTP_METHOD_MAP = [
|
||||
ActionType::READ => [
|
||||
Request::METHOD_GET,
|
||||
],
|
||||
ActionType::CREATE => [
|
||||
Request::METHOD_POST,
|
||||
Request::METHOD_HEAD,
|
||||
],
|
||||
ActionType::UPDATE => [
|
||||
Request::METHOD_PUT,
|
||||
Request::METHOD_PATCH,
|
||||
],
|
||||
ActionType::DELETE => [
|
||||
Request::METHOD_DELETE,
|
||||
],
|
||||
ActionType::EXECUTE => [
|
||||
Request::METHOD_GET,
|
||||
],
|
||||
];
|
||||
|
||||
public static function getActions(string $httpMethod): array
|
||||
{
|
||||
return parent::getIndizesByValue($httpMethod, self::ACTION_HTTP_METHOD_MAP);
|
||||
}
|
||||
|
||||
public static function getHttpMethods(string $action): array
|
||||
{
|
||||
return parent::getValuesByIndex($action, self::ACTION_HTTP_METHOD_MAP);
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Map;
|
||||
|
||||
/**
|
||||
* This class offers a map for ActionTypes to HttpMethods.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ActionHttpMethodMapInterface
|
||||
{
|
||||
/**
|
||||
* @param string $httpMethod
|
||||
*
|
||||
* @return array|string[] The Http-Methods which belong to an action
|
||||
*/
|
||||
public static function getActions(string $httpMethod): array;
|
||||
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return array|string[] The Http-Methods which are possible for an action
|
||||
*/
|
||||
public static function getHttpMethods(string $action): array;
|
||||
}
|
10
application/symfony/src/Domain/Map/MapInterface.php
Normal file
10
application/symfony/src/Domain/Map/MapInterface.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\Map;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface MapInterface
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user