Problem/Motivation
As discussed in #1839468: [Followup] Replace aggregator rss parsing with Zend Feed, we want to switch RSS to use Zend. Since Views is already using Serializer::serialize to get serialized data, it would be good for the RSS output in Views to use the same pipeline.
Proposed resolution
Create a thin wrapper around the Zend framework's RSS library so that the REST Export can be used to output RSS as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2003108-07-views-rss.patch | 12.78 KB | linclark |
| #5 | 2003108-05-views-rss.patch | 12.78 KB | linclark |
Comments
Comment #1
linclark commentedtagging.
Comment #2
linclark commentedIn talking about this with Crell and Damian, it seems that the best way to implement collections like RSS is to have an EntityCollection object which Views populates and then passes to Serializer. This object would have setters for common required properties such as title, but would not have setters for properties which aren't in the other spec.
Required feed-level properties from RSS are:
Required feed-level properties from Atom are:
HAL collections should have the link URI.
Comment #3
damiankloip commentedMissing the most important tag ;)
Comment #4
ParisLiakos commentedrelated #2025643: Add proxy services to Zend\Reader and Zend\Writer for better DX
Comment #5
linclark commentedI attempted this. My approach was to add the RSS support to the Serializer service that we register in the container. This would make requests with an
application/rss+xmlaccept header return RSS, both within Views and outside of Views.I'm attaching a patch which demonstrates this pipeline. The patch adds an EntityCollection class and an RssEncoder. The RssEncoder is NormalizationAware because we are using the ZendFeed Writer to assemble the RSS, rather than passing around arrays as the Normalizer interface expects. For a similar example, look at Symfony's XmlEncoder.
The end goal would be to replace the logic in all of the various Views RSS plugins with simple calls to
Serializer::serialize(). There are two ways to do this.Least disruptive
Remove the rows plugins, such as RssFields. Move the form for custom mappings which is in
RssFields::defineOptionsto the RSS style plugin. Then, replace the hardcoded RSS row plugins for things like Node with style plugins. These entity-type-specific style plugins would extend the RSS style plugin, only providing default mappings.Better
Provide a mapping layer for RSS in general. This would make the mappings available to the serializer even if
serializeis not being called from Views.To be honest, I don't think that we can finish this by API freeze, so if this is considered an API change, I think it will have to be D9.
Comment #7
linclark commentedReroll.
Comment #8
dawehnerHow much do you think has to be done to at least allow maybe contrib to provide a proper implementation?
The rss style plugined had a getDescription() method back in the days, not sure whether this is still the case. Maybe getting the collection should be moved to a separate method so it can be easily overridden in a subclass. I guess we need a subclass anyway ?
Is there a reason why this is not a unit test?
Comment #9
linclark commentedI'm not familiar enough with Views to know for sure. However, I believe that consolidating all of the various plugins into the RSS style plugin, and then subclassing that to provide default mappings for node, etc, would be the way to do this.
I didn't check to see whether there was a getDescription method, I can check.
Do you have an example of using the TypedData API from a PHPUnit test? My impression was that if you were using Entity API, you couldn't use PHP Unit.
Comment #11
dawehnerMaybe I just got confused because the test didn't added any kind of entity into the collection.
Comment #12
eric_a commentedI'm guessing the fatal error is related to this:
Comment #13
linclark commentedThanks for taking a look. This issue is not yet at the point where we need to work on making the tests pass because we still need to hash out the architecture.
Comment #14
linclark commentedI created a separate issue to handle the EntityCollection stuff, #2100637: REST views: add special handling for collections.
Comment #15
damiankloip commentedGood plan Lin, I like the sound of that.
Comment #16
Crell commentedI don't think the committers would approve this for 8.0 at this point, but it feels 8.1-friendly. There's no functionality change, just changes to the internal implementation, which should be fine for 8.1.
Comment #17
mikeker commentedBased on #16, moving this to Postponed. Also added a related issue: #2296885: Remove format_xml_elements().
Comment #23
andypostComment #25
vacho commentedThe last patch for this issues is very old. So I write by now the changes that is need to update in code for update the last patch.
/core/modules/rest/lib/Drupal/rest/Plugin/views/style/Serializer.php
Has been moved to /core/modules/rest/src/Plugin/views/style/Serializer.php
/core/modules/rest/lib/Drupal/rest/Tests/Views/RssTest.php
Is a new file, currently exist similar but in deep diferent code /core/modules/taxonomy/tests/src/Functional/RssTest.php
/core/modules/serialization/lib/Drupal/serialization/Encoder/RssEncoder.php
/core/modules/serialization/lib/Drupal/serialization/EntityCollection.php
/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
/core/modules/serialization/lib/Drupal/serialization/Tests/RssEntitySerializationTest.php
Is a New file. Now lib folter is missing for all modules it is a old structure.
/core/modules/serialization/serialization.services.yml
Needs update with new service for RssEncoder
/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.php
Has been moved to /core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php
Comment #30
xjmWe may be deprecating our dependency on Laminas (formerly Zend) Feed; if so, this issue should be marked wontfix. Postponing for now on #3118154: [meta] Deprecate dependencies, libraries, modules, and themes that will be removed from Drupal 10 core by 9.4.0-beta1.
Comment #33
alexpottWe've deprecated the writer service - #2919215: Deprecate feed.bridge.writer. This would depend on the service so it looks like we won't do this. Updating status accordingly.