diff --git a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php index 03658be385b897c295200072cb8458329694854a..4fc8b99f370c1d96b411b251f38886cc6fc3e7c8 100644 --- a/core/modules/tour/lib/Drupal/tour/TipPluginManager.php +++ b/core/modules/tour/lib/Drupal/tour/TipPluginManager.php @@ -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); diff --git a/core/modules/tour/tour.api.php b/core/modules/tour/tour.api.php index 4aea2c1558ba95c086239dc3cc0cf74facd98c3e..2bda3d6ca13aa15c9af1a8084db41721825da52c 100644 --- a/core/modules/tour/tour.api.php +++ b/core/modules/tour/tour.api.php @@ -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. *