Plugin managers have the ability to define an alter hook. The following line of code will be added to the GeoLocatorManager class's constructor to provide hook_geolocator_plugins_alter. This is passed to the module handler service for invocations:
/**
* Constructs a new GeoLocatorManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths
* keyed by the corresponding namespace to look for plugin implementations.
* @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
* Cache backend instance to use.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct(
'Plugin/GeoLocator',
$namespaces,
$module_handler,
'Drupal\geoip\Plugin\GeoLocator\GeoLocatorInterface',
'Drupal\geoip\Annotation\GeoLocator'
);
$this->alterInfo('geolocator_info');
$this->setCacheBackend($cache_backend, 'geolocator_plugins');
}
Modules implementing hook_geolocator_plugins_alter in the .module file have the ability to modify all the discovered plugin definitions. They also have the ability to remove defined plugin entries or alter any information provided for the annotation definition.