ZF2-351: Factories name and plugin name
Description
I defined factory in Application\Module :
public function getServiceConfiguration()
{
return array(
'factories' => array(
'Navigation' => 'ZFBook\Navigation\Service\NavigationFactory',
)
);
}
But, in my view, when i write :
echo $this->navigation()->breadcrumbs()->setMinDepth(0)->setLinkLast(true)->setPartial('bloc/breadcrumbs')->render();
Plugin name 'navigation' don't call the view helper, but my factory. Because in Zend\Loader\PluginBroker :
$locator = $this->getServiceLocator();
// Pulling by alias
if ($locator) {
try {
$instance = $locator->get($plugin);
} catch (ServiceManagerException $e) {
// not returning an instance is okay; there are other ways to
// retrieve the plugin later
$instance = false;
}
if ($instance) {
if ($this->getRegisterPluginsOnLoad()) {
$this->register($pluginName, $instance);
}
return $instance;
}
}
$class = $this->getClassLoader()->load($plugin);
if (empty($class) && !class_exists($plugin)) {
throw new Exception\RuntimeException('Unable to locate class associated with "' . $pluginName . '"');
}
if (empty($class) && class_exists($plugin)) {
$class = $plugin;
}
I think, we must resolved the short name in first, and try with service manager in second, no ?
Comments
Posted by Matthew Weier O'Phinney (matthew) on 2012-06-12T13:40:59.000+0000
No.
Or, rather, we're trying to figure out what to do here.
The SM duplicates a lot of functionality present in the Plugin Broker/Loader ecosystem: aliasing, instance creation and management, initialization checks, etc. In some ways, it may make sense to simply replace the broker/loader system with context-specific SMs (scoped containers, basically). For now, one of the easiest ways to handle a plugin that has dependencies is to simply add a factory to the SM using the same service name as the plugin name -- this solves a long-standing problem we've had with plugins like the Url plugin, the basePath plugin, navigation plugin, etc.
I'll leave this open for now, as what you're seeing is definitely a "WTF" type of issue; however, we should resolve this in time for beta5 to remove any problems like this that arise.
Posted by Maks 3w (maks3w) on 2012-08-11T10:12:22.000+0000
Zend\Loader\PluginBroker not longer exists in RC versions of ZF2. Is it still happening?
Posted by Maks 3w (maks3w) on 2012-08-11T10:14:44.000+0000
By the moment I'll close this issue. Feel free to reopen it if ServiceManager ZF2 RC versions don't fix your issue.
Posted by BLANCHON Vincent (blanchon_vincent) on 2012-08-11T10:16:05.000+0000
No, problem resolved with new plugin manager