src/Plugin/PluginManager.php
private function createPluginInstances($plugins, $init=false) {
        $pluginList = array();
        foreach ($plugins['pluginClasses'] as $key => $newPlugin) {
            //Load the concrete plugin directory
            $this->autoloader->addNewAutoloadPath($plugins['pluginDirectories'][$key], true);

            //Create new plugin instance

            if(class_exists($newPlugin)) {
                $newPluginInstantiation = new $newPlugin($this->parameters,
                                                        $this->autoloader,
                                                        $this->eventManager);
            } else {
                throw new PluginException('Plugin Manager: '
                        . 'Unable to instantiate the plugin with '
                        . 'name ('. $newPlugin. ') and path ('.
                        $plugins['pluginDirectories'][$key].')');
            }

            //Call Init function of the plugin
            if($init) {
                $newPluginInstantiation->init();
            }
            //Add the plugin instance into the plugin list
            $pluginList[] = ['plugin'=>$newPluginInstantiation,
                                  'enabled'=>$plugins['pluginEnabled'][$key]];
        }
        return $pluginList;
    }
private function createPluginInstances($plugins, $init=false) {
        $pluginList = array();
        foreach ($plugins['pluginClasses'] as $key => $newPlugin) {
            //Load the concrete plugin directory
            $this->autoloader->addNewAutoloadPath($plugins['pluginDirectories'][$key], true);

            //Create new plugin instance

            if(class_exists($newPlugin)) {
                $newPluginInstantiation = new $newPlugin($this->parameters,
                                                        $this->autoloader,
                                                        $this->eventManager);
            } else {
                throw new PluginException('Plugin Manager: '
                        . 'Unable to instantiate the plugin with '
                        . 'name ('. $newPlugin. ') and path ('.
                        $plugins['pluginDirectories'][$key].')');
            }

            //Call Init function of the plugin
            if($init) {
                $newPluginInstantiation->init();
            }
            //Add the plugin instance into the plugin list
            $pluginList[] = ['plugin'=>$newPluginInstantiation,
                                  'enabled'=>$plugins['pluginEnabled'][$key]];
        }
        return $pluginList;
    }
Instantiate the plugins from pluginLocator and if is true the $init var,
it creates the plugin. The expected return value is a array of tuples
of plugin and if it's enabled or not.

@param array      $plugins
@param bool|false $init

@return array
@throws \PluginException