getDefinitionsForContexts($contexts); } else { $definitions = $this->getDefinitions(); } $type = $this->getType(); $hooks = []; $hooks[] = "plugin_filter_{$type}"; $hooks[] = "plugin_filter_{$type}__{$consumer}"; $this->moduleHandler()->alter($hooks, $definitions, $extra, $consumer); $this->themeManager()->alter($hooks, $definitions, $extra, $consumer); return $definitions; } /** * A string identifying the plugin type. * * This string should be unique and generally will correspond to the string * used by the discovery, e.g. the annotation class or the YAML file name. * * @return string * A string identifying the plugin type. */ abstract protected function getType(); /** * Wraps the module handler. * * @return \Drupal\Core\Extension\ModuleHandlerInterface * The module handler. */ protected function moduleHandler() { if (property_exists($this, 'moduleHandler') && $this->moduleHandler instanceof ModuleHandlerInterface) { return $this->moduleHandler; } return \Drupal::service('module_handler'); } /** * Wraps the theme manager. * * @return \Drupal\Core\Theme\ThemeManagerInterface * The theme manager. */ protected function themeManager() { if (property_exists($this, 'themeManager') && $this->themeManager instanceof ThemeManagerInterface) { return $this->themeManager; } return \Drupal::service('theme.manager'); } }