Problem/Motivation
While looking into #2778569: REST views: Consider implementing `attachTo` method in `RestExport` display plugin, I realized that several Views style plugins have a attachTo method. In some places the docblock uses {@inheritdoc}, in other places there is no docblock. Either way, this method is not part of the ViewsPluginBase class.
This impacts the 2 feed style plugins: OPML and RSS.
Proposed resolution
Add a new interface AttachableStyle or similar, that defines this method.
The code in \Drupal\views\Plugin\views\display\Feed::attachTo() can then check if the plugins implement that interface:
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
jhedstromComment #3
jhedstromComment #4
dawehnerWhat about having a common interface for displays and styles?
Comment #5
jhedstromHmm, they currently take quite different arguments, so would that large of a refactor gain us anything? If for instance the style method had the display method's parameters, then each style plugin would need to dig into the view object to get the url, and title, etc.
Also adding the documentation tag as this impacts currently broken docblocks.
Comment #6
dawehnerIt would be nice to explain what attaching mean, so that the method is meant to change the $build to add some additional render element.
Those two should be strings
Comment #7
dawehnerComment #8
jhedstromre #6 I've made an attempt to clarify the docs here. It's a little awkward though based on how the current implementations modify both the
$buildarray and the view object itself.Comment #13
jhedstromRe-roll of #8.
Comment #14
joachim commentedReads a bit wrong. Not sure what to suggest instead though.
'Allows the style to react when attached by a display'?
Use single quotes, not backticks.
This sample code needs some sort of explanation of what it's showing.
Comment #15
jhedstromThis should address #14.
Comment #17
manuel garcia commentedDoing this makes sense to me, so +1. Also, patch still applies cleanly on 8.8.x so yay.
Took a look at the patch and it looks good, just a few minor things/nitpicks/questions:
Since they are in the same namespace, are the use statements necessary?
Should we be mentioning the feed icons on the interface?
Let's use short array syntax in the sample code.
Comment #18
jhedstromThis should address most of #17.
I was a bit uncertain what you meant here, but I did notice that
feed_iconsisn't the actual view property, it's actuallyfeedIcons(as demonstrated in the sample code block), so I've updated that comment.Comment #19
manuel garcia commentedThanks @jhedstrom changes look good. And actually after thinking a bit more, mentioning the feedIcons does make sense in there so this looks good to me. Got nothing else to complain about so RTBC++.
Comment #27
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #28
kunalgautam commentedRe-roll patch for Drupal version 10.1.x
Comment #29
kunalgautam commentedComment #30
_utsavsharma commentedFixed CCF for #29.
Comment #31
joachim commentedLGTM.
Comment #32
alexpottThis change will break quite a few modules. See https://git.drupalcode.org/search?group_id=2&repository_ref=&scope=blobs...
For example: https://git.drupalcode.org/project/xmlfeedviews/-/blob/1.0.x/src/Plugin/...
I think we need to check if the plugin implements the new interface and if not issue a deprecation but still call the method. And then in Drupal 11 do something different. I'm also not sure if silence is the correct option here. At the moment if the style plugin does not implement the attachTo() method you'll get a helpful error saying that it does not. With this patch you won't get any information as a developer that you should think about implementing this method.
Comment #34
acbramley commentedBased on our issue category definitions I don't think this should be considered a bug.