- All plugins need to have a service that acts as a plugin manager. Create a new file in your module's src directory called GeoLocatorManager.php. This will hold the GeoLocatorManager class.
- Create the GeoLocatorManager class by extending the \Drupal\Core\Plugin\DefaultPluginManager class:
<?php namespace Drupal\geoip; use Drupal\Core\Plugin\DefaultPluginManager; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Extension\ModuleHandlerInterface; class GeoLocatorManager extends DefaultPluginManager { }
- When creating a new plugin type, it is recommended that the plugin manager provides a set of defaults for new plugins, in case an item is missing from the definition:
<?php namespace Drupal\geoip; use Drupal\Core\Plugin\DefaultPluginManager; ...