Mercurial > hg > isophonics-drupal-site
comparison vendor/zendframework/zend-feed/src/Writer/ExtensionPluginManager.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 use Zend\ServiceManager\AbstractPluginManager; | |
13 use Zend\ServiceManager\Exception\InvalidServiceException; | |
14 use Zend\ServiceManager\Factory\InvokableFactory; | |
15 | |
16 /** | |
17 * Plugin manager implementation for feed writer extensions | |
18 * | |
19 * Validation checks that we have an Entry, Feed, or Extension\AbstractRenderer. | |
20 */ | |
21 class ExtensionPluginManager extends AbstractPluginManager | |
22 { | |
23 /** | |
24 * Aliases for default set of extension classes | |
25 * | |
26 * @var array | |
27 */ | |
28 protected $aliases = [ | |
29 'atomrendererfeed' => Extension\Atom\Renderer\Feed::class, | |
30 'atomRendererFeed' => Extension\Atom\Renderer\Feed::class, | |
31 'AtomRendererFeed' => Extension\Atom\Renderer\Feed::class, | |
32 'contentrendererentry' => Extension\Content\Renderer\Entry::class, | |
33 'contentRendererEntry' => Extension\Content\Renderer\Entry::class, | |
34 'ContentRendererEntry' => Extension\Content\Renderer\Entry::class, | |
35 'dublincorerendererentry' => Extension\DublinCore\Renderer\Entry::class, | |
36 'dublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class, | |
37 'DublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class, | |
38 'dublincorerendererfeed' => Extension\DublinCore\Renderer\Feed::class, | |
39 'dublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class, | |
40 'DublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class, | |
41 'itunesentry' => Extension\ITunes\Entry::class, | |
42 'itunesEntry' => Extension\ITunes\Entry::class, | |
43 'iTunesEntry' => Extension\ITunes\Entry::class, | |
44 'ItunesEntry' => Extension\ITunes\Entry::class, | |
45 'itunesfeed' => Extension\ITunes\Feed::class, | |
46 'itunesFeed' => Extension\ITunes\Feed::class, | |
47 'iTunesFeed' => Extension\ITunes\Feed::class, | |
48 'ItunesFeed' => Extension\ITunes\Feed::class, | |
49 'itunesrendererentry' => Extension\ITunes\Renderer\Entry::class, | |
50 'itunesRendererEntry' => Extension\ITunes\Renderer\Entry::class, | |
51 'iTunesRendererEntry' => Extension\ITunes\Renderer\Entry::class, | |
52 'ItunesRendererEntry' => Extension\ITunes\Renderer\Entry::class, | |
53 'itunesrendererfeed' => Extension\ITunes\Renderer\Feed::class, | |
54 'itunesRendererFeed' => Extension\ITunes\Renderer\Feed::class, | |
55 'iTunesRendererFeed' => Extension\ITunes\Renderer\Feed::class, | |
56 'ItunesRendererFeed' => Extension\ITunes\Renderer\Feed::class, | |
57 'slashrendererentry' => Extension\Slash\Renderer\Entry::class, | |
58 'slashRendererEntry' => Extension\Slash\Renderer\Entry::class, | |
59 'SlashRendererEntry' => Extension\Slash\Renderer\Entry::class, | |
60 'threadingrendererentry' => Extension\Threading\Renderer\Entry::class, | |
61 'threadingRendererEntry' => Extension\Threading\Renderer\Entry::class, | |
62 'ThreadingRendererEntry' => Extension\Threading\Renderer\Entry::class, | |
63 'wellformedwebrendererentry' => Extension\WellFormedWeb\Renderer\Entry::class, | |
64 'wellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class, | |
65 'WellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class, | |
66 ]; | |
67 | |
68 /** | |
69 * Factories for default set of extension classes | |
70 * | |
71 * @var array | |
72 */ | |
73 protected $factories = [ | |
74 Extension\Atom\Renderer\Feed::class => InvokableFactory::class, | |
75 Extension\Content\Renderer\Entry::class => InvokableFactory::class, | |
76 Extension\DublinCore\Renderer\Entry::class => InvokableFactory::class, | |
77 Extension\DublinCore\Renderer\Feed::class => InvokableFactory::class, | |
78 Extension\ITunes\Entry::class => InvokableFactory::class, | |
79 Extension\ITunes\Feed::class => InvokableFactory::class, | |
80 Extension\ITunes\Renderer\Entry::class => InvokableFactory::class, | |
81 Extension\ITunes\Renderer\Feed::class => InvokableFactory::class, | |
82 Extension\Slash\Renderer\Entry::class => InvokableFactory::class, | |
83 Extension\Threading\Renderer\Entry::class => InvokableFactory::class, | |
84 Extension\WellFormedWeb\Renderer\Entry::class => InvokableFactory::class, | |
85 // Legacy (v2) due to alias resolution; canonical form of resolved | |
86 // alias is used to look up the factory, while the non-normalized | |
87 // resolved alias is used as the requested name passed to the factory. | |
88 'zendfeedwriterextensionatomrendererfeed' => InvokableFactory::class, | |
89 'zendfeedwriterextensioncontentrendererentry' => InvokableFactory::class, | |
90 'zendfeedwriterextensiondublincorerendererentry' => InvokableFactory::class, | |
91 'zendfeedwriterextensiondublincorerendererfeed' => InvokableFactory::class, | |
92 'zendfeedwriterextensionitunesentry' => InvokableFactory::class, | |
93 'zendfeedwriterextensionitunesfeed' => InvokableFactory::class, | |
94 'zendfeedwriterextensionitunesrendererentry' => InvokableFactory::class, | |
95 'zendfeedwriterextensionitunesrendererfeed' => InvokableFactory::class, | |
96 'zendfeedwriterextensionslashrendererentry' => InvokableFactory::class, | |
97 'zendfeedwriterextensionthreadingrendererentry' => InvokableFactory::class, | |
98 'zendfeedwriterextensionwellformedwebrendererentry' => InvokableFactory::class, | |
99 ]; | |
100 | |
101 /** | |
102 * Do not share instances (v2) | |
103 * | |
104 * @var bool | |
105 */ | |
106 protected $shareByDefault = false; | |
107 | |
108 /** | |
109 * Do not share instances (v3) | |
110 * | |
111 * @var bool | |
112 */ | |
113 protected $sharedByDefault = false; | |
114 | |
115 /** | |
116 * Validate the plugin (v3) | |
117 * | |
118 * Checks that the extension loaded is of a valid type. | |
119 * | |
120 * @param mixed $plugin | |
121 * @return void | |
122 * @throws InvalidServiceException if invalid | |
123 */ | |
124 public function validate($plugin) | |
125 { | |
126 if ($plugin instanceof Extension\AbstractRenderer) { | |
127 // we're okay | |
128 return; | |
129 } | |
130 | |
131 if ('Feed' == substr(get_class($plugin), -4)) { | |
132 // we're okay | |
133 return; | |
134 } | |
135 | |
136 if ('Entry' == substr(get_class($plugin), -5)) { | |
137 // we're okay | |
138 return; | |
139 } | |
140 | |
141 throw new InvalidServiceException(sprintf( | |
142 'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface ' | |
143 . 'or the classname must end in "Feed" or "Entry"', | |
144 (is_object($plugin) ? get_class($plugin) : gettype($plugin)), | |
145 __NAMESPACE__ | |
146 )); | |
147 } | |
148 | |
149 /** | |
150 * Validate plugin (v2) | |
151 * | |
152 * @param mixed $plugin | |
153 * @return void | |
154 * @throws Exception\InvalidArgumentException when invalid | |
155 */ | |
156 public function validatePlugin($plugin) | |
157 { | |
158 try { | |
159 $this->validate($plugin); | |
160 } catch (InvalidServiceException $e) { | |
161 throw new Exception\InvalidArgumentException(sprintf( | |
162 'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface ' | |
163 . 'or the classname must end in "Feed" or "Entry"', | |
164 (is_object($plugin) ? get_class($plugin) : gettype($plugin)), | |
165 __NAMESPACE__ | |
166 )); | |
167 } | |
168 } | |
169 } |