Commit a98f4dd5 authored by alexpott's avatar alexpott
Browse files

Issue #2038233 by tim.plunkett: Convert TipPluginManager to extend DefaultPluginManager.

parent bd51e51a
......@@ -7,32 +7,35 @@
namespace Drupal\tour;
use Drupal\Component\Plugin\Discovery\ProcessDecorator;
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Factory\ContainerFactory;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManager;
use Drupal\Core\Plugin\DefaultPluginManager;
/**
* Configurable tour manager.
*/
class TipPluginManager extends PluginManagerBase {
class TipPluginManager extends DefaultPluginManager {
/**
* Overrides \Drupal\Component\Plugin\PluginManagerBase::__construct().
* Constructs a new TipPluginManager.
*
* @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\Language\LanguageManager $language_manager
* The language manager.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler to invoke the alter hook with.
*/
public function __construct(\Traversable $namespaces) {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) {
$annotation_namespaces = array('Drupal\tour\Annotation' => $namespaces['Drupal\tour']);
$this->discovery = new AnnotatedClassDiscovery('tour/tip', $namespaces, $annotation_namespaces, 'Drupal\tour\Annotation\Tip');
$this->discovery = new AlterDecorator($this->discovery, 'tour_tips_info');
$this->discovery = new CacheDecorator($this->discovery, 'tour');
parent::__construct('tour/tip', $namespaces, $annotation_namespaces, 'Drupal\tour\Annotation\Tip');
$this->factory = new ContainerFactory($this->discovery);
$this->alterInfo($module_handler, 'tour_tips_info');
$this->setCacheBackend($cache_backend, $language_manager, 'tour');
}
}
services:
plugin.manager.tour.tip:
class: Drupal\tour\TipPluginManager
arguments: ['@container.namespaces']
arguments: ['@container.namespaces', '@cache.cache', '@language_manager', '@module_handler']
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment