Issues

ZF2-323: PluginBroker and load with alias

Issue Type: Bug Created: 2012-05-26T16:24:29.000+0000 Last Updated: 2012-08-11T10:13:31.000+0000 Status: Resolved Fix version(s): Reporter: BLANCHON Vincent (blanchon_vincent) Assignee: Maks 3w (maks3w) Tags: - Zend\Loader

Related issues: Attachments:

Description

If the first load method in PluginBroker :

<pre class="highlight">
$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;
            }
        }

With these lines i can write in my controller :

<pre class="highlight">
public function indexAction()
    {
        $manager = $this->plugin('ViewManager'));
    }

I think is not the PluginBroker job, so to fix that i propose to verify alias configuration with :

<pre class="highlight">
$class = $this->getClassLoader()->load($plugin);
if (empty($class) && !class_exists($plugin)) {
            throw new Exception\RuntimeException('Unable to locate class associated with "' . $pluginName . '"');
        }

just before the loading by alias and keep the use of servicemanager to load alias and complete class name.

Comments

Posted by Maks 3w (maks3w) on 2012-06-26T12:39:22.000+0000

You can try to use ServiceManager instead of ServiceManager like this PR https://github.com/zendframework/zf2/pull/1550

Posted by Maks 3w (maks3w) on 2012-08-11T10:13:31.000+0000

Closed because Zend\Loader\PluginBroker has been removed in favor of Zend\ServiceManager

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts