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

Methods of CoreExtensions expected in own writer extension #87

Open
av3 opened this issue Aug 7, 2018 · 5 comments
Open

Methods of CoreExtensions expected in own writer extension #87

av3 opened this issue Aug 7, 2018 · 5 comments
Labels

Comments

@av3
Copy link

av3 commented Aug 7, 2018

Thank you for your writer example, froschdesign. I tested it and am getting an error message. This time I created a separate issue, because it's not related to the documentation ;)

I created an Entry class (extends Extension\AbstractRenderer) and registered it in my handler. But the output of my atom feed fails (using the export method). I get the error message:

call_user_func_array() expects parameter 1 to be a valid callback, class 'Webfeed\Writer\Renderer\Entry' does not have a method 'getItunesAuthors'

I can see that $authors = $this->getDataContainer()->getItunesAuthors(); of Writer/Extension/ITunes/Renderer/Entry.php is executed, before it fails. Why should my own Renderer need getItunesAuthors?

I assume on reason is that registerCoreExtensions() is called in the AbstractFeed constructor. Unfortunately I can't see a method to unregister the extension. When removing iTunes in the registerCoreExtensions method, the method getPlayPodcastBlock is expected. It would work if I remove everything except Atom.

Is this an unexpected behavior or am I doing something wrong?

@froschdesign
Copy link
Member

I assume on reason is that registerCoreExtensions() is called in the AbstractFeed constructor.

I think that's the same problem as deregistering an extension.

@froschdesign
Copy link
Member

Please look at #90 and my idea for an improvement. I think this should help also for you problem – remove core extension and add a custom extension.

@av3
Copy link
Author

av3 commented Mar 5, 2019

Thank's for the info. Fortunately I kept an old branch with my attempts. I modified the code:

        /** @var \Zend\Feed\Writer\StandaloneExtensionManager $em */
        $em = \Zend\Feed\Writer\Writer::getExtensionManager();
        $em->remove('ITunes\Renderer\Feed');
        $em->remove('GooglePlayPodcast\Renderer\Feed');

        $em->add(
            'Webfeed\Renderer\Feed',
            \Webfeed\Writer\Renderer\Feed::class
        );

        Writer::setExtensionManager($em);
        Writer::registerExtension('Webfeed');

With the removal of ITunes\Renderer\Feed the error class 'Webfeed\Writer\Feed' does not have a method 'getItunesAuthors' was fixed and with the removal of GooglePlayPodcast\Renderer\Feed the error class 'Webfeed\Writer\Feed' does not have a method 'getPlayPodcastAuthors' disappeared. I didn't make any changed to the registerCoreExtensions method, you mentioned, so I could use it with zend-feed 2.11

@froschdesign
Copy link
Member

@av3
Thanks for the feedback!

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-feed; a new issue has been opened at laminas/laminas-feed#5.

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

No branches or pull requests

3 participants