title: ZF2 Get ServiceManager from Controller Plugin Factory
body: <p>I'm trying to create a new Controller Plugin using a factory to inject a dependency.</p>
  
  <pre><code>public function createService(ServiceLocatorInterface $serviceLocator) {
  
      $services = $serviceLocator-&gt;getServiceLocator();
      /** @var \Zend\Mvc\Controller\PluginManager */
  
      $plugin = new MyPlugin();
  
      if ($services-&gt;has('my_service')) {
          $plugin-&gt;setService($services-&gt;get('my_service'));
      }
  
      return $plugin;
  }
  </code></pre>
  
  <p>The problem is $services can't find 'my_service'</p>
  
  <p>I've added the proper configurations in my service manager</p>
  
  <pre><code>'services' =&gt; array(
      'invokables' =&gt; array(
          'my_service' =&gt; 'Application\Service\MyService'
      )
  ),
  'controller_plugins' =&gt; array(
      'factories' =&gt; array(
          'my_plugin' =&gt; 'Application\Controller\Plugin\Factory\MyPlugin'
      )
  )
  </code></pre>
  
  <p>My thinking is it's a bug in the PluginManager where it isn't injecting the service manager properly.</p>