Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Updated to service manager 3 #3

Merged
merged 2 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"require-dev": {
"zendframework/zend-config": "~2.5",
"zendframework/zend-servicemanager": "~2.5",
"zendframework/zend-servicemanager": "dev-develop as 2.7.0",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
},
Expand Down
9 changes: 6 additions & 3 deletions src/Cloud.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
namespace Zend\Tag;

use Traversable;
use Zend\ServiceManager\ServiceManager;
use Zend\Stdlib\ArrayUtils;
use Zend\Tag\Cloud\Decorator\HtmlCloud;
use Zend\Tag\Cloud\Decorator\HtmlTag;

class Cloud
{
Expand Down Expand Up @@ -208,7 +211,7 @@ public function setCloudDecorator($decorator)
public function getCloudDecorator()
{
if (null === $this->cloudDecorator) {
$this->setCloudDecorator('htmlCloud');
$this->setCloudDecorator(HtmlCloud::class);
}
return $this->cloudDecorator;
}
Expand Down Expand Up @@ -255,7 +258,7 @@ public function setTagDecorator($decorator)
public function getTagDecorator()
{
if (null === $this->tagDecorator) {
$this->setTagDecorator('htmlTag');
$this->setTagDecorator(HtmlTag::class);
}
return $this->tagDecorator;
}
Expand All @@ -280,7 +283,7 @@ public function setDecoratorPluginManager(Cloud\DecoratorPluginManager $decorato
public function getDecoratorPluginManager()
{
if ($this->decorators === null) {
$this->decorators = new Cloud\DecoratorPluginManager();
$this->decorators = new Cloud\DecoratorPluginManager(new ServiceManager());
}

return $this->decorators;
Expand Down
42 changes: 10 additions & 32 deletions src/Cloud/DecoratorPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Zend\Tag\Cloud;

use Zend\ServiceManager\AbstractPluginManager;
use Zend\Tag\Exception;
use Zend\ServiceManager\Factory\InvokableFactory;

/**
* Plugin manager implementation for decorators.
Expand All @@ -21,38 +21,16 @@
*/
class DecoratorPluginManager extends AbstractPluginManager
{
/**
* Default set of decorators
*
* @var array
*/
protected $invokableClasses = [
'htmlcloud' => 'Zend\Tag\Cloud\Decorator\HtmlCloud',
'htmltag' => 'Zend\Tag\Cloud\Decorator\HtmlTag',
'tag' => 'Zend\Tag\Cloud\Decorator\HtmlTag',
protected $aliases = [
'htmlcloud' => Decorator\HtmlCloud::class,
'htmltag' => Decorator\HtmlTag::class,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above two should also have the aliases htmlCloud and 'htmlTag`, as those were used previously. I can do that on merge, though.

'tag' => Decorator\HtmlTag::class,
];

/**
* Validate the plugin
*
* Checks that the decorator loaded is an instance
* of Decorator\DecoratorInterface.
*
* @param mixed $plugin
* @return void
* @throws Exception\InvalidArgumentException if invalid
*/
public function validatePlugin($plugin)
{
if ($plugin instanceof Decorator\DecoratorInterface) {
// we're okay
return;
}
protected $factories = [
Decorator\HtmlCloud::class => InvokableFactory::class,
Decorator\HtmlTag::class => InvokableFactory::class,
];

throw new Exception\InvalidArgumentException(sprintf(
'Plugin of type %s is invalid; must implement %s\Decorator\DecoratorInterface',
(is_object($plugin) ? get_class($plugin) : gettype($plugin)),
__NAMESPACE__
));
}
protected $instanceOf = Decorator\DecoratorInterface::class;
}
Loading