comparison vendor/zendframework/zend-feed/src/Writer/ExtensionManager.php @ 0:4c8ae668cc8c

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