Adding custom, dynamic applications was difficult in the previous implementation, since a couple of controllers inherited from YamlApplicationAwareController. It's behaviour could only be modified controller by controller, reuslting in several sources of truth.
The new implementation extracts the logic of resolving a slug to an application class to a seperate service (Mapbender\CoreBundle\Component\Application\ApplicationResolver, or it alias mapbender.application.resolver. It defaults to Mapbender\CoreBundle\Component\Application\DbAndYamlApplicationResolver, but can be easily overridden by either changing the parameter mapbender.application.resolver.class or creating a new service that aliases to Mapbender\CoreBundle\Component\Application\ApplicationResolver, e.g.
#[AsAlias(ApplicationResolver::class)]
class CustomApplicationResolver extends DbAndYamlApplicationResolver
{
public function __construct(
#[Autowire(service: 'mapbender.application.yaml_entity_repository')] ApplicationYAMLMapper $yamlRepository,
EntityManagerInterface $em,
AuthorizationCheckerInterface $authorizationChecker)
{
parent::__construct($yamlRepository, $em, $authorizationChecker);
}
public function getApplicationEntity(string $slug): Application
{
// Your custom logic here
return parent::getApplicationEntity($slug);
}
}
Adding custom, dynamic applications was difficult in the previous implementation, since a couple of controllers inherited from YamlApplicationAwareController. It's behaviour could only be modified controller by controller, reuslting in several sources of truth.
The new implementation extracts the logic of resolving a slug to an application class to a seperate service (
Mapbender\CoreBundle\Component\Application\ApplicationResolver
, or it aliasmapbender.application.resolver
. It defaults toMapbender\CoreBundle\Component\Application\DbAndYamlApplicationResolver
, but can be easily overridden by either changing the parametermapbender.application.resolver.class
or creating a new service that aliases toMapbender\CoreBundle\Component\Application\ApplicationResolver
, e.g.