我在我自己的自定义模块中覆盖工作台审核模块插件时遇到问题,因为Drupal 8.4.3的管理员节点编辑页面。任何人都可以在Drupal 8.4.3的自定义模块中了解覆盖的contrib / core模块插件。
答案 0 :(得分:1)
我使用聚合器(核心Drupal 8)遇到了此类问题。 我不得不重写/改善默认行为。
在深入分析此模块时,我刚刚看到它执行插件管理并提供了一个挂钩API。 例如,我设法使聚合器处理封闭的网址图片。 它们是使用Drupal 8的几种方法。我使用了一个非常简单的方法: Annotation 。
/**
* Defines a default parser implementation.
*
* Parses RSS, Atom and RDF feeds.
*
* @AggregatorParser(
* id = "xxxxx_aggregator",
* title = @Translation("XXXX parser"),
* description = @Translation("Custom parser for RSS enclosure tag.")
* )
*/
class CustomParser extends DefaultParser {
/**
* Override default parser to add the enclosure attribute to feed item
* {@inheritdoc}
*/
public function parse(FeedInterface $feed) {
parent::parse($feed);
// your code...
}
}
在此给定示例中,我使用@AggregatorParser
,允许Aggregator检测并使用另一个 PARSER ,这是我的自定义,它扩展了聚合器的默认设置。
不要忘记将其添加到正确的所需路径中。这里是:namespace Drupal\xxxxx_aggregator\Plugin\aggregator\parser;
即使插件管理提供了添加自定义插件和功能的简单方法,您也可以覆盖模块服务以进行更深入,更全面的更新。 https://www.drupal.org/docs/8/api/services-and-dependency-injection/altering-existing-services-providing-dynamic-services https://symfony.com/doc/current/service_container/service_decoration.html
答案 1 :(得分:0)
我设法通过在自定义模块中使用hook_local_task_alter()来解决此问题。
答案 2 :(得分:0)
您可以尝试对其进行修补,然后使用作曲家修补程序。
https://www.drupal.org/patch https://github.com/cweagans/composer-patches