Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Reader extension: Non-working example in documentation #44

Closed
halfpastfouram opened this issue Aug 29, 2017 · 1 comment
Closed

Reader extension: Non-working example in documentation #44

halfpastfouram opened this issue Aug 29, 2017 · 1 comment

Comments

@halfpastfouram
Copy link

When reading the docs I stumbled upon a problem. In the section Writing Zend\Feed\Reader Extensions an example is given on how to use the ExtensionPluginManager in order to register an extension to the reader.

The example given is as follows:

use My\FeedReader\Extension\JungleBooks;
use Zend\Feed\Reader\ExtensionManager;
use Zend\Feed\Reader\ExtensionPluginManager;
use Zend\Feed\Reader\Reader;

$extensions = new ExtensionPluginManager();
$extensions->setInvokableClass('JungleBooks\Entry', JungleBooks\Entry::class);
Reader::setExtensionManager(new ExtensionManager($extensions));
Reader::registerExtension('JungleBooks');

$feed = Reader::import('http://example.com/junglebooks/rss');

// ISBN for whatever book the first entry in the feed was concerned with
$firstIsbn = $feed->current()->getIsbn();

This example won't work because the following exception will be thrown:

Deprecated: Zend\ServiceManager\AbstractPluginManager::__construct now expects a Interop\Container\ContainerInterface instance representing the parent container; please update your code in /vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 85

Call Stack:
    0.0006     363936   1. {main}() /index.php:0
    0.0012     386160   2. Zend\Feed\Reader\ExtensionPluginManager->__construct() /index.php:9
    0.0013     389096   3. trigger_error() /vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php:85

Please see to this issue by updating the docs.

@Xerkus
Copy link
Member

Xerkus commented Nov 16, 2017

Instructions are still valid for zend-servicemanager v2, however for v3 it needs to be changed to

$extensions = new ExtensionPluginManager(new ServiceManager());
$extensions->setFactory(JungleBooks\Entry::class, \Zend\ServiceManager\Factory\InvokableFactory::class);
Reader::setExtensionManager($extensions);
Reader::registerExtension('JungleBooks');

See https://docs.zendframework.com/zend-servicemanager/migration/#invokables

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants