public static function PluginTypeExampleController::create in Examples for Developers 3.x
Same name and namespace in other branches
- 8 plugin_type_example/src/Controller/PluginTypeExampleController.php \Drupal\plugin_type_example\Controller\PluginTypeExampleController::create()
Override the parent method so that we can inject our sandwich plugin manager service into the controller.
For more about how dependency injection works read https://www.drupal.org/node/2133171
Overrides ControllerBase::create
See also
Services and Dependency Injection Container
File
- modules/
plugin_type_example/ src/ Controller/ PluginTypeExampleController.php, line 119
Class
- PluginTypeExampleController
- Controller for our example pages.
Namespace
Drupal\plugin_type_example\ControllerCode
public static function create(ContainerInterface $container) {
// Inject the plugin.manager.sandwich service that represents our plugin
// manager as defined in the plugin_type_example.services.yml file.
return new static($container
->get('plugin.manager.sandwich'));
}