3 * Zend Framework (http://framework.zend.com/)
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
10 namespace Zend\Feed\Writer;
12 use Zend\ServiceManager\AbstractPluginManager;
13 use Zend\ServiceManager\Exception\InvalidServiceException;
14 use Zend\ServiceManager\Factory\InvokableFactory;
17 * Plugin manager implementation for feed writer extensions
19 * Validation checks that we have an Entry, Feed, or Extension\AbstractRenderer.
21 class ExtensionPluginManager extends AbstractPluginManager implements ExtensionManagerInterface
24 * Aliases for default set of extension classes
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 'AtomRenderer\Feed' => Extension\Atom\Renderer\Feed::class,
33 'Atom\Renderer\Feed' => Extension\Atom\Renderer\Feed::class,
34 'contentrendererentry' => Extension\Content\Renderer\Entry::class,
35 'contentRendererEntry' => Extension\Content\Renderer\Entry::class,
36 'ContentRendererEntry' => Extension\Content\Renderer\Entry::class,
37 'ContentRenderer\Entry' => Extension\Content\Renderer\Entry::class,
38 'Content\Renderer\Entry' => Extension\Content\Renderer\Entry::class,
39 'dublincorerendererentry' => Extension\DublinCore\Renderer\Entry::class,
40 'dublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class,
41 'DublinCoreRendererEntry' => Extension\DublinCore\Renderer\Entry::class,
42 'DublinCoreRenderer\Entry' => Extension\DublinCore\Renderer\Entry::class,
43 'DublinCore\Renderer\Entry' => Extension\DublinCore\Renderer\Entry::class,
44 'dublincorerendererfeed' => Extension\DublinCore\Renderer\Feed::class,
45 'dublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class,
46 'DublinCoreRendererFeed' => Extension\DublinCore\Renderer\Feed::class,
47 'DublinCoreRenderer\Feed' => Extension\DublinCore\Renderer\Feed::class,
48 'DublinCore\Renderer\Feed' => Extension\DublinCore\Renderer\Feed::class,
49 'googleplaypodcastentry' => Extension\GooglePlayPodcast\Entry::class,
50 'googleplaypodcastEntry' => Extension\GooglePlayPodcast\Entry::class,
51 'googlePlayPodcastEntry' => Extension\GooglePlayPodcast\Entry::class,
52 'GooglePlayPodcastEntry' => Extension\GooglePlayPodcast\Entry::class,
53 'Googleplaypodcast\Entry' => Extension\GooglePlayPodcast\Entry::class,
54 'GooglePlayPodcast\Entry' => Extension\GooglePlayPodcast\Entry::class,
55 'googleplaypodcastfeed' => Extension\GooglePlayPodcast\Feed::class,
56 'googleplaypodcastFeed' => Extension\GooglePlayPodcast\Feed::class,
57 'googlePlayPodcastFeed' => Extension\GooglePlayPodcast\Feed::class,
58 'GooglePlayPodcastFeed' => Extension\GooglePlayPodcast\Feed::class,
59 'Googleplaypodcast\Feed' => Extension\GooglePlayPodcast\Feed::class,
60 'GooglePlayPodcast\Feed' => Extension\GooglePlayPodcast\Feed::class,
61 'googleplaypodcastrendererentry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
62 'googleplaypodcastRendererEntry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
63 'googlePlayPodcastRendererEntry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
64 'GooglePlayPodcastRendererEntry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
65 'GoogleplaypodcastRenderer\Entry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
66 'GooglePlayPodcast\Renderer\Entry' => Extension\GooglePlayPodcast\Renderer\Entry::class,
67 'googleplaypodcastrendererfeed' => Extension\GooglePlayPodcast\Renderer\Feed::class,
68 'googleplaypodcastRendererFeed' => Extension\GooglePlayPodcast\Renderer\Feed::class,
69 'googlePlayPodcastRendererFeed' => Extension\GooglePlayPodcast\Renderer\Feed::class,
70 'GooglePlayPodcastRendererFeed' => Extension\GooglePlayPodcast\Renderer\Feed::class,
71 'GoogleplaypodcastRenderer\Feed' => Extension\GooglePlayPodcast\Renderer\Feed::class,
72 'GooglePlayPodcast\Renderer\Feed' => Extension\GooglePlayPodcast\Renderer\Feed::class,
73 'itunesentry' => Extension\ITunes\Entry::class,
74 'itunesEntry' => Extension\ITunes\Entry::class,
75 'iTunesEntry' => Extension\ITunes\Entry::class,
76 'ItunesEntry' => Extension\ITunes\Entry::class,
77 'Itunes\Entry' => Extension\ITunes\Entry::class,
78 'ITunes\Entry' => Extension\ITunes\Entry::class,
79 'itunesfeed' => Extension\ITunes\Feed::class,
80 'itunesFeed' => Extension\ITunes\Feed::class,
81 'iTunesFeed' => Extension\ITunes\Feed::class,
82 'ItunesFeed' => Extension\ITunes\Feed::class,
83 'Itunes\Feed' => Extension\ITunes\Feed::class,
84 'ITunes\Feed' => Extension\ITunes\Feed::class,
85 'itunesrendererentry' => Extension\ITunes\Renderer\Entry::class,
86 'itunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
87 'iTunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
88 'ItunesRendererEntry' => Extension\ITunes\Renderer\Entry::class,
89 'ItunesRenderer\Entry' => Extension\ITunes\Renderer\Entry::class,
90 'ITunes\Renderer\Entry' => Extension\ITunes\Renderer\Entry::class,
91 'itunesrendererfeed' => Extension\ITunes\Renderer\Feed::class,
92 'itunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
93 'iTunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
94 'ItunesRendererFeed' => Extension\ITunes\Renderer\Feed::class,
95 'ItunesRenderer\Feed' => Extension\ITunes\Renderer\Feed::class,
96 'ITunes\Renderer\Feed' => Extension\ITunes\Renderer\Feed::class,
97 'slashrendererentry' => Extension\Slash\Renderer\Entry::class,
98 'slashRendererEntry' => Extension\Slash\Renderer\Entry::class,
99 'SlashRendererEntry' => Extension\Slash\Renderer\Entry::class,
100 'SlashRenderer\Entry' => Extension\Slash\Renderer\Entry::class,
101 'Slash\Renderer\Entry' => Extension\Slash\Renderer\Entry::class,
102 'threadingrendererentry' => Extension\Threading\Renderer\Entry::class,
103 'threadingRendererEntry' => Extension\Threading\Renderer\Entry::class,
104 'ThreadingRendererEntry' => Extension\Threading\Renderer\Entry::class,
105 'ThreadingRenderer\Entry' => Extension\Threading\Renderer\Entry::class,
106 'Threading\Renderer\Entry' => Extension\Threading\Renderer\Entry::class,
107 'wellformedwebrendererentry' => Extension\WellFormedWeb\Renderer\Entry::class,
108 'wellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class,
109 'WellFormedWebRendererEntry' => Extension\WellFormedWeb\Renderer\Entry::class,
110 'WellFormedWebRenderer\Entry' => Extension\WellFormedWeb\Renderer\Entry::class,
111 'WellFormedWeb\Renderer\Entry' => Extension\WellFormedWeb\Renderer\Entry::class,
115 * Factories for default set of extension classes
119 protected $factories = [
120 Extension\Atom\Renderer\Feed::class => InvokableFactory::class,
121 Extension\Content\Renderer\Entry::class => InvokableFactory::class,
122 Extension\DublinCore\Renderer\Entry::class => InvokableFactory::class,
123 Extension\DublinCore\Renderer\Feed::class => InvokableFactory::class,
124 Extension\GooglePlayPodcast\Entry::class => InvokableFactory::class,
125 Extension\GooglePlayPodcast\Feed::class => InvokableFactory::class,
126 Extension\GooglePlayPodcast\Renderer\Entry::class => InvokableFactory::class,
127 Extension\GooglePlayPodcast\Renderer\Feed::class => InvokableFactory::class,
128 Extension\ITunes\Entry::class => InvokableFactory::class,
129 Extension\ITunes\Feed::class => InvokableFactory::class,
130 Extension\ITunes\Renderer\Entry::class => InvokableFactory::class,
131 Extension\ITunes\Renderer\Feed::class => InvokableFactory::class,
132 Extension\Slash\Renderer\Entry::class => InvokableFactory::class,
133 Extension\Threading\Renderer\Entry::class => InvokableFactory::class,
134 Extension\WellFormedWeb\Renderer\Entry::class => InvokableFactory::class,
135 // Legacy (v2) due to alias resolution; canonical form of resolved
136 // alias is used to look up the factory, while the non-normalized
137 // resolved alias is used as the requested name passed to the factory.
138 'zendfeedwriterextensionatomrendererfeed' => InvokableFactory::class,
139 'zendfeedwriterextensioncontentrendererentry' => InvokableFactory::class,
140 'zendfeedwriterextensiondublincorerendererentry' => InvokableFactory::class,
141 'zendfeedwriterextensiondublincorerendererfeed' => InvokableFactory::class,
142 'zendfeedwriterextensiongoogleplaypodcastentry' => InvokableFactory::class,
143 'zendfeedwriterextensiongoogleplaypodcastfeed' => InvokableFactory::class,
144 'zendfeedwriterextensiongoogleplaypodcastrendererentry' => InvokableFactory::class,
145 'zendfeedwriterextensiongoogleplaypodcastrendererfeed' => InvokableFactory::class,
147 'zendfeedwriterextensionitunesentry' => InvokableFactory::class,
148 'zendfeedwriterextensionitunesfeed' => InvokableFactory::class,
149 'zendfeedwriterextensionitunesrendererentry' => InvokableFactory::class,
150 'zendfeedwriterextensionitunesrendererfeed' => InvokableFactory::class,
151 'zendfeedwriterextensionslashrendererentry' => InvokableFactory::class,
152 'zendfeedwriterextensionthreadingrendererentry' => InvokableFactory::class,
153 'zendfeedwriterextensionwellformedwebrendererentry' => InvokableFactory::class,
157 * Do not share instances (v2)
161 protected $shareByDefault = false;
164 * Do not share instances (v3)
168 protected $sharedByDefault = false;
171 * Validate the plugin (v3)
173 * Checks that the extension loaded is of a valid type.
175 * @param mixed $plugin
177 * @throws InvalidServiceException if invalid
179 public function validate($plugin)
181 if ($plugin instanceof Extension\AbstractRenderer) {
186 if ('Feed' == substr(get_class($plugin), -4)) {
191 if ('Entry' == substr(get_class($plugin), -5)) {
196 throw new InvalidServiceException(sprintf(
197 'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
198 . 'or the classname must end in "Feed" or "Entry"',
199 (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
205 * Validate plugin (v2)
207 * @param mixed $plugin
209 * @throws Exception\InvalidArgumentException when invalid
211 public function validatePlugin($plugin)
214 $this->validate($plugin);
215 } catch (InvalidServiceException $e) {
216 throw new Exception\InvalidArgumentException(sprintf(
217 'Plugin of type %s is invalid; must implement %s\Extension\RendererInterface '
218 . 'or the classname must end in "Feed" or "Entry"',
219 (is_object($plugin) ? get_class($plugin) : gettype($plugin)),