Reputation: 61
I am facing problem in overriding workbench moderation module plugin in my own custom module for administrator node edit pages of Drupal 8.4.3. Can anyone have knowledge of overriding contrib/core module plugin in custom module of Drupal 8.4.3.
Upvotes: 1
Views: 2040
Reputation: 1137
I had this type of issue using aggregator (core Drupal 8). I had to override/improve the default behavior.
Going deeper in the analyse of this module, I just saw that it does Plugin management and offers a hook api. For example I managed to make aggregator deal with enclose url image. Their are several ways to do it with Drupal 8. I used a very simple one : 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...
}
}
In this given example, using @AggregatorParser
, I allow Aggregator to detect and use another PARSER, my custom, which is extending the aggregator's default.
Do not forget to add it in the correct needed path. Here its : namespace Drupal\xxxxx_aggregator\Plugin\aggregator\parser;
Even if plugin management offers a simple way to add custom plugins and functionalities, you can also overriding the module service for deeper and more global updates. 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
Upvotes: 2
Reputation: 516
You can try patching it and then using composer patches.
https://www.drupal.org/patch https://github.com/cweagans/composer-patches
Upvotes: -2
Reputation: 61
I am managed to solve this issue by using hook_local_task_alter() in a custom module.
Upvotes: 0