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

AbstractPluginManager::__construct now expects a Interop\Container\ContainerInterface instance representing the parent container #190

Closed
Synchro opened this issue Apr 14, 2017 · 7 comments

Comments

@Synchro
Copy link

Synchro commented Apr 14, 2017

My current code using Zend_Feed has started throwing this error. I see mentions of having to do this in #100, but the docs give no idea what I'm supposed to do, and none of the examples do it. This is my code:

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

I don't understand what's required here because I don't have a container to give to ExtensionPluginManager - the extension is attached statically to Reader. Can I make it be quiet by doing something like:

$extensions = new ExtensionPluginManager(new SomeDummyContainerClass);

BTW thanks for fixing Zend_Feed #30, which involves the same code.

@Synchro
Copy link
Author

Synchro commented Oct 10, 2017

Any pointers on this? As far as I can see it's still undocumented and I have no idea how I can create / get hold of a container to give it.

@Synchro
Copy link
Author

Synchro commented Nov 9, 2017

Any chance of some attention to this? BC breaks are fine, but undocumented BC breaks are a bit unsporting!

@weierophinney
Copy link
Member

This is covered in the changelog for 2.6.0: https://github.com/zendframework/zend-feed/releases/tag/release-2.6.0

@Synchro
Copy link
Author

Synchro commented Nov 9, 2017

Thanks, that helps a bit - but how should I pass in my extension - setInvokableClass apparently doesn't exist in StandaloneExtensionManager as it did in ExtensionPluginManager?

$extensions = new StandaloneExtensionManager;
$extensions->setInvokableClass('Media\Entry', MyApp\RSS\Media\Entry::class);
Reader::setExtensionManager(new ExtensionManager($extensions));
Reader::registerExtension('Media');

results in:

Error: Call to undefined method Zend\Feed\Reader\StandaloneExtensionManager::setInvokableClass()

The junglebooks example code in the docs still describes the old way that doesn't work.

@Xerkus
Copy link
Member

Xerkus commented Nov 9, 2017

https://docs.zendframework.com/zend-servicemanager/migration/#invokables
Invokables were removed, in v3 you should use InvokableFactory and aliases.

@Synchro
Copy link
Author

Synchro commented Nov 9, 2017

After lots of going in circles, I've got this working. The whole servicemanager thing seemed like overkill for something that should be very simple (I'm not managing a service, I'm parsing RSS), so I'm thankful I didn't need to go there.

I saw the docs comment about copy/pasting the StandaloneExtensionManager class (though make sure you get the latest as it's changed a lot since 2.6), so I've done that (in my own namespace) and added my extension into its private list manually:

namespace MyApp\RSS;

use Zend\Feed\Reader\Extension;
use Zend\Feed\Reader\ExtensionManagerInterface;

class StandaloneExtensionManager implements ExtensionManagerInterface
{
    private $extensions = [
        'Atom\Entry' => 'Zend\Feed\Reader\Extension\Atom\Entry',
        'Atom\Feed' => 'Zend\Feed\Reader\Extension\Atom\Feed',
...
        'Media\Entry' => Media\Entry::class //My extension
    ];
...

then I instantiate the manager and register the extension:

Reader::setExtensionManager(new MyApp\RSS\StandaloneExtensionManager);
Reader::registerExtension('Media');

and I'm happy to say that works. It would be great if the docs could be updated with an example like this rather than the broken one that's there now. Can you point me at the right repo for that?

@Synchro Synchro closed this as completed Nov 9, 2017
@froschdesign
Copy link
Member

@Synchro

Can you point me at the right repo for that?

See: zendframework/zend-feed#44

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

No branches or pull requests

4 participants