|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Webino (http://webino.sk) |
|
4
|
|
|
* |
|
5
|
|
|
* @link https://github.com/webino/WebinoDraw for the canonical source repository |
|
6
|
|
|
* @copyright Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk) |
|
7
|
|
|
* @author Peter Bačinský <[email protected]> |
|
8
|
|
|
* @license BSD-3-Clause |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace WebinoDraw\Factory; |
|
12
|
|
|
|
|
13
|
|
|
use Zend\Mvc\Exception; |
|
14
|
|
|
use Zend\Mvc\Service\AbstractPluginManagerFactory as BaseAbstractPluginManagerFactory; |
|
15
|
|
|
use Zend\ServiceManager\ConfigInterface; |
|
16
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
17
|
|
|
use Zend\View\Helper\HelperInterface as ViewHelperInterface; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class AbstractPluginManagerFactory |
|
21
|
|
|
*/ |
|
22
|
|
|
abstract class AbstractPluginManagerFactory extends BaseAbstractPluginManagerFactory |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* An array of helper configuration classes to ensure are on the helper_map stack. |
|
26
|
|
|
* |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
protected $defaultHelperMapClasses = []; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Create and return the draw loop helper manager |
|
33
|
|
|
* |
|
34
|
|
|
* @param ServiceLocatorInterface $services |
|
35
|
|
|
* @return ViewHelperInterface |
|
36
|
|
|
* @throws Exception\RuntimeException |
|
37
|
|
|
*/ |
|
38
|
|
|
public function createService(ServiceLocatorInterface $services) |
|
39
|
|
|
{ |
|
40
|
|
|
$plugins = parent::createService($services); |
|
41
|
|
|
|
|
42
|
|
|
foreach ($this->defaultHelperMapClasses as $configClass) { |
|
43
|
|
|
if (!is_string($configClass) || !class_exists($configClass)) { |
|
44
|
|
|
continue; |
|
45
|
|
|
} |
|
46
|
|
|
$config = new $configClass; |
|
47
|
|
|
|
|
48
|
|
|
if (!$config instanceof ConfigInterface) { |
|
49
|
|
|
throw new Exception\RuntimeException(sprintf( |
|
50
|
|
|
'Invalid service manager configuration class provided; received "%s",' |
|
51
|
|
|
. ' expected class implementing %s', |
|
52
|
|
|
$configClass, |
|
53
|
|
|
'Zend\ServiceManager\ConfigInterface' |
|
54
|
|
|
)); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$config->configureServiceManager($plugins); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** @var \Zend\ServiceManager\ServiceManager $services */ |
|
61
|
|
|
$plugins->addPeeringServiceManager($services); |
|
62
|
|
|
return $plugins; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|