function PluginTypeExampleController::create

Same name in other branches
  1. 3.x modules/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 AutowireTrait::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\Controller

Code

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'));
}