Initial commit: CloudOps infrastructure platform
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\ProjectBundle\Event;
|
||||
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Event dispatched to allow bundles to extend entity type to model key mappings.
|
||||
*/
|
||||
final class EntityTypeModelMappingEvent extends Event
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $mappings
|
||||
*/
|
||||
public function __construct(private array $mappings = [])
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a model key mapping.
|
||||
*/
|
||||
public function addMapping(string $entityType, string $modelKey): void
|
||||
{
|
||||
$this->mappings[$entityType] = $modelKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple model key mappings.
|
||||
*
|
||||
* @param array<string, string> $mappings
|
||||
*/
|
||||
public function addMappings(array $mappings): void
|
||||
{
|
||||
$this->mappings = array_merge($this->mappings, $mappings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all model key mappings.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getMappings(): array
|
||||
{
|
||||
return $this->mappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get model key for entity type or return entity type if no mapping exists.
|
||||
*/
|
||||
public function getModelKey(string $entityType): string
|
||||
{
|
||||
return $this->mappings[$entityType] ?? $entityType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Mautic\ProjectBundle\Event;
|
||||
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* Event dispatched to allow bundles to extend entity type normalization mappings.
|
||||
*/
|
||||
final class EntityTypeNormalizationEvent extends Event
|
||||
{
|
||||
/**
|
||||
* @param array<string, string> $mappings
|
||||
*/
|
||||
public function __construct(private array $mappings = [])
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a normalization mapping.
|
||||
*/
|
||||
public function addMapping(string $from, string $to): void
|
||||
{
|
||||
$this->mappings[$from] = $to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add multiple normalization mappings.
|
||||
*
|
||||
* @param array<string, string> $mappings
|
||||
*/
|
||||
public function addMappings(array $mappings): void
|
||||
{
|
||||
$this->mappings = array_merge($this->mappings, $mappings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all normalization mappings.
|
||||
*
|
||||
* @return array<string, string>
|
||||
*/
|
||||
public function getMappings(): array
|
||||
{
|
||||
return $this->mappings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get normalized entity type or return original if no mapping exists.
|
||||
*/
|
||||
public function getNormalizedType(string $entityType): string
|
||||
{
|
||||
return $this->mappings[$entityType] ?? $entityType;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user