Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297078

Add proxy services to Zend\Reader and Zend\Writer for better DX

$
0
0

Updated: Comment #29

Problem/Motivation

Using the Zend Reader/Writer added in #1839468: [Followup] Replace aggregator rss parsing with Zend Feed is non-obvious unless you look at the implementation in Aggregator. It's also ugly.

<?php
Reader::setExtensionManager(\Drupal::service('feed.bridge.reader'));
$channel = Reader::importString($feed->source_string);
?>

There are other problems with this. Only a subset of methods from \Zend\Feed\Reader\Reader can actually be used. Some require dependencies that we don't have.

Proposed resolution

Create a Reader and Writer class that wraps \Zend\Feed\Reader\Reader, and \Zend\Feed\Writer\Writer and provide it as a service. This will take care of setting the extension manager, and provides a handy place to document the parts that we support.

The above code becomes:

<?php
\Drupal::service('feed.reader')->importString($feed->source_string);
?>

Remaining tasks

This probably needs a change notice, since it's adding a new API.

User interface changes

None

API changes

This is an API addition. Using \Zend\Feed\Reader and Zend\Feed\Writer directly still works fine.

#1839468: [Followup] Replace aggregator rss parsing with Zend Feed
#2003108: Switch Views RSS to use Serializer/Zend


Viewing all articles
Browse latest Browse all 297078

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>