Chris@0
|
1 <?php
|
Chris@0
|
2 /**
|
Chris@0
|
3 * Zend Framework (http://framework.zend.com/)
|
Chris@0
|
4 *
|
Chris@0
|
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
|
Chris@0
|
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
Chris@0
|
7 * @license http://framework.zend.com/license/new-bsd New BSD License
|
Chris@0
|
8 */
|
Chris@0
|
9
|
Chris@0
|
10 namespace Zend\Feed\Writer;
|
Chris@0
|
11
|
Chris@0
|
12 /**
|
Chris@0
|
13 * Default implementation of ExtensionManagerInterface
|
Chris@0
|
14 *
|
Chris@0
|
15 * Decorator for an ExtensionManagerInstance.
|
Chris@0
|
16 */
|
Chris@0
|
17 class ExtensionManager implements ExtensionManagerInterface
|
Chris@0
|
18 {
|
Chris@0
|
19 protected $pluginManager;
|
Chris@0
|
20
|
Chris@0
|
21 /**
|
Chris@0
|
22 * Constructor
|
Chris@0
|
23 *
|
Chris@0
|
24 * Seeds the extension manager with a plugin manager; if none provided,
|
Chris@0
|
25 * creates and decorates an instance of StandaloneExtensionManager.
|
Chris@0
|
26 *
|
Chris@0
|
27 * @param null|ExtensionManagerInterface $pluginManager
|
Chris@0
|
28 */
|
Chris@0
|
29 public function __construct(ExtensionManagerInterface $pluginManager = null)
|
Chris@0
|
30 {
|
Chris@0
|
31 if (null === $pluginManager) {
|
Chris@0
|
32 $pluginManager = new StandaloneExtensionManager();
|
Chris@0
|
33 }
|
Chris@0
|
34 $this->pluginManager = $pluginManager;
|
Chris@0
|
35 }
|
Chris@0
|
36
|
Chris@0
|
37 /**
|
Chris@0
|
38 * Method overloading
|
Chris@0
|
39 *
|
Chris@0
|
40 * Proxy to composed ExtensionManagerInterface instance.
|
Chris@0
|
41 *
|
Chris@0
|
42 * @param string $method
|
Chris@0
|
43 * @param array $args
|
Chris@0
|
44 * @return mixed
|
Chris@0
|
45 * @throws Exception\BadMethodCallException
|
Chris@0
|
46 */
|
Chris@0
|
47 public function __call($method, $args)
|
Chris@0
|
48 {
|
Chris@12
|
49 if (! method_exists($this->pluginManager, $method)) {
|
Chris@0
|
50 throw new Exception\BadMethodCallException(sprintf(
|
Chris@0
|
51 'Method by name of %s does not exist in %s',
|
Chris@0
|
52 $method,
|
Chris@0
|
53 __CLASS__
|
Chris@0
|
54 ));
|
Chris@0
|
55 }
|
Chris@0
|
56 return call_user_func_array([$this->pluginManager, $method], $args);
|
Chris@0
|
57 }
|
Chris@0
|
58
|
Chris@0
|
59 /**
|
Chris@0
|
60 * Get the named extension
|
Chris@0
|
61 *
|
Chris@0
|
62 * @param string $name
|
Chris@0
|
63 * @return Extension\AbstractRenderer
|
Chris@0
|
64 */
|
Chris@0
|
65 public function get($name)
|
Chris@0
|
66 {
|
Chris@0
|
67 return $this->pluginManager->get($name);
|
Chris@0
|
68 }
|
Chris@0
|
69
|
Chris@0
|
70 /**
|
Chris@0
|
71 * Do we have the named extension?
|
Chris@0
|
72 *
|
Chris@0
|
73 * @param string $name
|
Chris@0
|
74 * @return bool
|
Chris@0
|
75 */
|
Chris@0
|
76 public function has($name)
|
Chris@0
|
77 {
|
Chris@0
|
78 return $this->pluginManager->has($name);
|
Chris@0
|
79 }
|
Chris@0
|
80 }
|