Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
We want all the discovery things for ResourcePluginManager to make it more powerful.
The first thing that comes to mind is swapping out a plugin definition. Example: I'm a contrib module and I'm really not happy how the entity:node resource plugin works, so I want to alter it because I want to treat REST requests for nodes in a more specific way.
Basically we can copy from ViewsPluginManager:
$this->discovery = new AnnotatedClassDiscovery('views', $type, $namespaces);
$this->discovery = new DerivativeDiscoveryDecorator($this->discovery);
$this->discovery = new ProcessDecorator($this->discovery, array($this, 'processDefinition'));
$this->discovery = new AlterDecorator($this->discovery, 'views_plugins_' . $type);
$this->discovery = new CacheDecorator($this->discovery, 'views:' . $type, 'views_info');
ProcessDecorator does not make sense to me, but we want the rest!
Comment | File | Size | Author |
---|---|---|---|
#5 | plugin-alter-1984626-5.patch | 2.65 KB | klausi |
#5 | plugin-alter-1984626-5-interdiff.txt | 466 bytes | klausi |
#3 | plugin-alter-1984626-3.patch | 2.65 KB | klausi |
#2 | rest-plugin-alter-1984626-2.patch | 2.49 KB | klausi |
Comments
Comment #1
tim.plunkett+1
Comment #2
klausiHere is a start that adds the AlterDecorator + api.php docs.
Not sure about the CacheDecorator, should we add our own cache bin? Do we even need a cache?
Comment #3
klausiIt looks like it is pretty easy to use the cache decorator as well with the default cache bin, so I added that here.
Comment #4
tim.plunkettShould say "Alter", api.php stuff is different
We don't put the & here
Comment #5
klausiFixed both, although the second one is not defined in the coding standards and I personally think it is very valuable information to have the reference "&" there. But anyway, if this buys me an RTBC I'll "fix" anything you say :-P
Comment #6
tim.plunkett:) this looks good.
Comment #7
alexpottContrib will thank you! No need for tests as the functionality of AlterDecorator and CacheDecorator are tested elsewhere.
Committed 34eac38 and pushed to 8.x. Thanks!