zendframework / zend-feed

Feed component from Zend Framework
BSD 3-Clause "New" or "Revised" License
166 stars 42 forks source link

Documentation section bloc Extensions for writers is empty #86

Open gbouyge opened 6 years ago

gbouyge commented 6 years ago

After updating zend-feed to v2.10.3, it seems that the setInvokableClass to add personnal writer has changed. Giving the following error :

Method by name of setInvokableClass does not exist in Zend\Feed\Writer\ExtensionManager

I tried to find more information into your doc, but the bloc is empty with a TODOmention.

Code to reproduce the issue

extensions = Writer::getExtensionManager();
$extensions->setInvokableClass('MyEntryName','PathToMyEntryClass');
Writer::registerExtension('MyExtensionName');

Expected results

My extension well registered. And the section doc completed.

Actual results

Method by name of setInvokableClass does not exist in Zend\Feed\Writer\ExtensionManager
froschdesign commented 6 years ago

@gbouyge

After updating zend-feed to v2.10.3, it seems that the setInvokableClass to add personnal writer has changed.

This method has been gone since version 2.6.0.

You can use the following:

/** @var \Zend\Feed\Reader\StandaloneExtensionManager $extensionManager */
$extensionManager = \Zend\Feed\Writer\Writer::getExtensionManager();
$extensionManager->add('My\Entry', \My\Entry::class);
\Zend\Feed\Writer\Writer::registerExtension('My');

var_dump($extensionManager->has('My\Entry')); // true
var_dump(\Zend\Feed\Writer\Writer::getExtensions()['entry']); // array {0 => 'My\Entry'}

or use the class names:

$extensionManager->add(\My\Entry::class, \My\Entry::class);
var_dump($extensionManager->has(\My\Entry::class)); // true
weierophinney commented 4 years ago

This repository has been closed and moved to laminas/laminas-feed; a new issue has been opened at https://github.com/laminas/laminas-feed/issues/6.