composer package updates
[openemr.git] / vendor / zendframework / zend-tag / src / Cloud / DecoratorPluginManager.php
blob1b40a40c3eb893b5b13905a43b995bd95aef8c2f
1 <?php
2 /**
3 * @see https://github.com/zendframework/zend-tag for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-tag/blob/master/LICENSE.md New BSD License
6 */
8 namespace Zend\Tag\Cloud;
10 use RuntimeException;
11 use Zend\ServiceManager\AbstractPluginManager;
12 use Zend\ServiceManager\Exception\InvalidServiceException;
13 use Zend\ServiceManager\Factory\InvokableFactory;
15 /**
16 * Plugin manager implementation for decorators.
18 * Enforces that decorators retrieved are instances of
19 * Decorator\DecoratorInterface. Additionally, it registers a number of default
20 * decorators available.
22 class DecoratorPluginManager extends AbstractPluginManager
24 protected $aliases = [
25 'htmlcloud' => Decorator\HtmlCloud::class,
26 'htmlCloud' => Decorator\HtmlCloud::class,
27 'Htmlcloud' => Decorator\HtmlCloud::class,
28 'HtmlCloud' => Decorator\HtmlCloud::class,
29 'htmltag' => Decorator\HtmlTag::class,
30 'htmlTag' => Decorator\HtmlTag::class,
31 'Htmltag' => Decorator\HtmlTag::class,
32 'HtmlTag' => Decorator\HtmlTag::class,
33 'tag' => Decorator\HtmlTag::class,
34 'Tag' => Decorator\HtmlTag::class,
37 protected $factories = [
38 Decorator\HtmlCloud::class => InvokableFactory::class,
39 Decorator\HtmlTag::class => InvokableFactory::class,
40 // Legacy (v2) due to alias resolution; canonical form of resolved
41 // alias is used to look up the factory, while the non-normalized
42 // resolved alias is used as the requested name passed to the factory.
43 'zendtagclouddecoratorhtmlcloud' => InvokableFactory::class,
44 'zendtagclouddecoratorhtmltag' => InvokableFactory::class
47 protected $instanceOf = Decorator\DecoratorInterface::class;
49 /**
50 * Validate the plugin is of the expected type (v3).
52 * Validates against `$instanceOf`.
54 * @param mixed $instance
55 * @throws InvalidServiceException
57 public function validate($instance)
59 if (! $instance instanceof $this->instanceOf) {
60 throw new InvalidServiceException(sprintf(
61 '%s can only create instances of %s; %s is invalid',
62 get_class($this),
63 $this->instanceOf,
64 (is_object($instance) ? get_class($instance) : gettype($instance))
65 ));
69 /**
70 * Validate the plugin is of the expected type (v2).
72 * Proxies to `validate()`.
74 * @param mixed $instance
75 * @throws InvalidServiceException
77 public function validatePlugin($instance)
79 try {
80 $this->validate($instance);
81 } catch (InvalidServiceException $e) {
82 throw new RuntimeException($e->getMessage(), $e->getCode(), $e);