List Discovery
Component lists (enums) are discovered by namespace. The Pinto module discovers lists in the Pinto namespace by default:
php
namespace Drupal\my_module\Pinto;
enum PintoList implements ObjectListInterface {}Override namespace
Namespaces may be overridden by setting service parameters.
In the site directory, usually sites/default/, create a services.yml and reference it from settings.php.
php
$settings['container_yamls'][] = __DIR__ . '/services.yml';yaml
parameters:
pinto.namespaces:
- 'Pinto'
- 'MyProjectDesignSystem'Advanced discovery
In some cases it maybe necessary to add Pinto lists for discovery using custom PHP code.
This is possible by implementing a compiler pass.
Create a service provider
The naming of this class is magical, which varies depending on the machine name of the containing module. See
php
namespace Drupal\my_module;
final class MyModuleServiceProvider implements \Drupal\Core\DependencyInjection\ServiceProviderInterface {
public function register(\Drupal\Core\DependencyInjection\ContainerBuilder $container): void {
$container->addCompilerPass(new MyModuleCompilerPass(), priority: 100);
}
}Create a compiler pass
php
<?php
namespace Drupal\my_module;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
final class MyModuleCompilerPass implements CompilerPassInterface {
public function process(ContainerBuilder $container): void {
$pintoLists = $container->getParameter('pinto.lists');
$pintoLists[] = MyPintoList::class;
$container->setParameter('pinto.lists', $pintoLists);
}
}Get the lists parameter, merge in class-string references to Pinto lists enums, then set the list parameter with modified values.