Commit 0cf4cd39 authored by alexpott's avatar alexpott

Issue #1984648 by tim.plunkett: Add AlterDecorator to TipPluginManager.

parent 8296db7a
......@@ -9,6 +9,7 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Component\Plugin\Discovery\ProcessDecorator;
......@@ -28,6 +29,7 @@ class TipPluginManager extends PluginManagerBase {
public function __construct(\Traversable $namespaces) {
$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');
$this->factory = new DefaultFactory($this->discovery);
......
......@@ -21,6 +21,21 @@ function hook_tour_tips_alter(array &$tour_tips, Drupal\Core\Entity\EntityInterf
}
}
/**
* Allow modules to alter tip plugin definitions.
*
* @param array $info
* The array of tip plugin definitions, keyed by plugin ID.
*
* @see \Drupal\tour\Annotation\Tip
*/
function hook_tour_tips_info_alter(&$info) {
// Swap out the class used for this tip plugin.
if (isset($info['text'])) {
$info['class'] = 'Drupal\mymodule\Plugin\tour\tip\MyCustomTipPlugin';
}
}
/**
* Act on tour objects when loaded.
*
......
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