src/AutoMapper/RestAutoMapperConfiguration.php
<?php
declare(strict_types = 1);
/**
* /src/AutoMapper/RestAutoMapperConfiguration.php
*
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
namespace App\AutoMapper;
use AutoMapperPlus\AutoMapperPlusBundle\AutoMapperConfiguratorInterface;
use AutoMapperPlus\Configuration\AutoMapperConfigInterface;
use AutoMapperPlus\MapperInterface;
use Override;
use Symfony\Component\HttpFoundation\Request;
/**
* @package App\AutoMapper
* @author TLe, Tarmo Leppänen <tarmo.leppanen@pinja.com>
*/
abstract class RestAutoMapperConfiguration implements AutoMapperConfiguratorInterface
{
/**
* Classes to use specified request mapper.
*
* @var array<int, class-string>
*/
protected static array $requestMapperClasses = [];
public function __construct(
protected readonly MapperInterface $requestMapper,
) {
}
/**
* Use this method to register your mappings.
*
* @psalm-suppress UndefinedThisPropertyFetch
*/
#[Override]
public function configure(AutoMapperConfigInterface $config): void
{
foreach (static::$requestMapperClasses as $requestMapperClass) {
$config
->registerMapping(Request::class, $requestMapperClass)
->useCustomMapper($this->requestMapper);
}
}
}