diff --git a/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicDefaultPlugin.php b/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicDefaultPlugin.php index ae99d447af..697197be79 100644 --- a/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicDefaultPlugin.php +++ b/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicDefaultPlugin.php @@ -51,14 +51,14 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function getLabel() { - return new TranslatableMarkup(parent::getLabel(), [], []); + return new TranslatableMarkup(parent::getLabel()); } /** * {@inheritdoc} */ public function getBody() { - return new TranslatableMarkup(parent::getBody(), [], []); + return new TranslatableMarkup(parent::getBody()); } } diff --git a/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicPluginManager.php b/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicPluginManager.php index e5aab0c96c..aaf873f981 100644 --- a/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicPluginManager.php +++ b/core/modules/help_topics/src/Plugin/HelpTopic/HelpTopicPluginManager.php @@ -134,11 +134,22 @@ protected function getFactory() { } /** - * {@inheritdoc} + * Checks to see if cached plugin definitions exist. + * If they do, then it returns the cached definitions. + * Otherwise, findDefinitions() is called. + * + * @see \Drupal\Core\Plugin\DefaultPluginManager::findDefinitions() + * + * @return array|\mixed[]|null */ public function getDefinitions() { - // Since this function is called rarely, instantiate the discovery here. - // This finds all the help_topic plugins in theme and module directories. + return parent::getDefinitions(); + } + + /** + * {@inheritdoc} + */ + protected function findDefinitions() { $definitions = $this->getDiscovery()->getDefinitions(); foreach ($definitions as $plugin_id => &$definition) { @@ -146,6 +157,16 @@ public function getDefinitions() { $this->processDefinition($definition, $plugin_id); } + $this->definitions = $definitions; + return $definitions; + } + + /** + * Checks to see if plugin is provided by an uninstalled module or theme. + */ + public function alterDefinitions(&$definitions) { + parent::alterDefinitions($definitions); + // If this plugin was provided by a module that does not exist, remove the // plugin definition. // @todo Address what to do with an invalid plugin. @@ -156,8 +177,6 @@ public function getDefinitions() { unset($definitions[$plugin_id]); } } - $this->definitions = $definitions; - return $definitions; } /** @@ -169,7 +188,6 @@ public function getTopLevelTopics() { foreach ($this->getDefinitions() as $definition) { if ($definition['top_level']) { /* @var \Drupal\help_topics\Plugin\HelpTopic\HelpTopicPluginInterface $topic */ - $topic = $this->createInstance($definition['id']); $label = (string) $topic->getLabel(); $topics[$label] = $topic;