Completed
Push — master ( 5ea837...9dec3c )
by Paul
9s
created

AbstractPluginManagerFactory::createService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 9
rs 9.6666
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
/**
3
 * This file is part of the PPI Framework.
4
 *
5
 * @copyright   Copyright (c) 2011-2016 Paul Dragoonis <[email protected]>
6
 * @license     http://opensource.org/licenses/mit-license.php MIT
7
 *
8
 * @link        http://www.ppi.io
9
 */
10
11
namespace PPI\Framework\ServiceManager\Factory;
12
13
use Zend\ServiceManager\AbstractPluginManager;
14
use Zend\ServiceManager\FactoryInterface;
15
use Zend\ServiceManager\ServiceLocatorInterface;
16
17
/**
18
 * AbstractPluginManagerFactory.
19
 *
20
 * @author Vítor Brandão <[email protected]>
21
 */
22
abstract class AbstractPluginManagerFactory implements FactoryInterface
23
{
24
    const PLUGIN_MANAGER_CLASS = 'AbstractPluginManager';
25
26
    /**
27
     * Create and return a plugin manager.
28
     * Classes that extend this should provide a valid class for
29
     * the PLUGIN_MANGER_CLASS constant.
30
     *
31
     * @param ServiceLocatorInterface $serviceLocator
32
     *
33
     * @return \Zend\ServiceManager\AbstractPluginManager
34
     */
35
    public function createService(ServiceLocatorInterface $serviceLocator)
36
    {
37
        $pluginManagerClass = static::PLUGIN_MANAGER_CLASS;
38
        /* @var $plugins \Zend\ServiceManager\AbstractPluginManager */
39
        $plugins = new $pluginManagerClass();
40
        $plugins->setServiceLocator($serviceLocator);
41
42
        return $plugins;
43
    }
44
}
45