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

Commit

Permalink
Merge branch 'master' into acceptHandling
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Mvc/Controller/RestfulController.php
  • Loading branch information
Show file tree
Hide file tree
Showing 31 changed files with 291 additions and 676 deletions.
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

14 changes: 0 additions & 14 deletions .travis/run-tests.sh

This file was deleted.

7 changes: 0 additions & 7 deletions .travis/skipped-components

This file was deleted.

61 changes: 0 additions & 61 deletions .travis/tested-components

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zendframework/zend-tag",
"description": "Zend\\Tag component",
"description": "a component suite which provides a facility to work with taggable Items",
"license": "BSD-3-Clause",
"keywords": [
"zf2",
Expand All @@ -9,11 +9,11 @@
"homepage": "https://github.com/zendframework/zend-tag",
"autoload": {
"psr-4": {
"Zend\\Tag\\": "src/"
"Zend\\Tag": "src/"
}
},
"require": {
"php": ">=5.3.23",
"php": ">=5.3.3",
"zendframework/zend-escaper": "self.version",
"zendframework/zend-stdlib": "self.version"
},
Expand Down
123 changes: 53 additions & 70 deletions src/Cloud.php
Original file line number Diff line number Diff line change
@@ -1,36 +1,21 @@
<?php
/**
* Zend Framework
* Zend Framework (http://framework.zend.com/)
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@zend.com so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Tag
* @subpackage Cloud
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Tag
*/

namespace Zend\Tag;

use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Tag\Exception\InvalidArgumentException,
Zend\Loader\Broker;

/**
* @category Zend
* @package Zend_Tag
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Cloud
{
Expand All @@ -51,16 +36,16 @@ class Cloud
/**
* List of all tags
*
* @var \Zend\Tag\ItemList
* @var ItemList
*/
protected $_tags = null;

/**
* Plugin broker for decorators
* Plugin manager for decorators
*
* @var \Zend\Loader\Broker
* @var Cloud\DecoratorPluginManager
*/
protected $_decoratorBroker = null;
protected $_decorators = null;

/**
* Option keys to skip when calling setOptions()
Expand Down Expand Up @@ -90,8 +75,8 @@ public function __construct($options = null)
/**
* Set options from array
*
* @param array $options Configuration for \Zend\Tag\Cloud
* @return \Zend\Tag\Cloud
* @param array $options Configuration for Cloud
* @return Cloud
*/
public function setOptions(array $options)
{
Expand Down Expand Up @@ -124,53 +109,51 @@ public function setOptions(array $options)
* decorators.
*
* @param array $tags
* @throws \Zend\Tag\Exception\InvalidArgumentException
* @return \Zend\Tag\Cloud
* @throws Exception\InvalidArgumentException
* @return Cloud
*/
public function setTags(array $tags)
{
// Validate and cleanup the tags
$itemList = $this->getItemList();

foreach ($tags as $tag) {
if ($tag instanceof TaggableInterface) {
$itemList[] = $tag;
} else if (is_array($tag)) {
$itemList[] = new Item($tag);
} else {
throw new InvalidArgumentException('Tag must be an instance of Zend\Tag\TaggableInterface or an array');
}
$this->appendTag($tag);
}

return $this;
}

/**
* Append a single tag to the cloud
*
* @param \Zend\Tag\TaggableInterface|array $tag
* @throws \Zend\Tag\Exception\InvalidArgumentException
* @return \Zend\Tag\Cloud
* @param TaggableInterface|array $tag
* @throws Exception\InvalidArgumentException
* @return Cloud
*/
public function appendTag($tag)
{
$tags = $this->getItemList();

if ($tag instanceof TaggableInterface) {
$tags[] = $tag;
} else if (is_array($tag)) {
$tags[] = new Item($tag);
} else {
throw new InvalidArgumentException('Tag must be an instance of Zend\Tag\TaggableInterface or an array');
return $this;
}

if (!is_array($tag)) {
throw new Exception\InvalidArgumentException(sprintf(
'Tag must be an instance of %s\TaggableInterface or an array; received "%s"',
__NAMESPACE__,
(is_object($tag) ? get_class($tag) : gettype($tag))
));
}

$tags[] = new Item($tag);

return $this;
}

/**
* Set the item list
*
* @param \Zend\Tag\ItemList $itemList
* @return \Zend\Tag\Cloud
* @param ItemList $itemList
* @return Cloud
*/
public function setItemList(ItemList $itemList)
{
Expand All @@ -183,7 +166,7 @@ public function setItemList(ItemList $itemList)
*
* If item list is undefined, creates one.
*
* @return \Zend\Tag\ItemList
* @return ItemList
*/
public function getItemList()
{
Expand All @@ -197,8 +180,8 @@ public function getItemList()
* Set the decorator for the cloud
*
* @param mixed $decorator
* @throws \Zend\Tag\Exception\InvalidArgumentException
* @return \Zend\Tag\Cloud
* @throws Exception\InvalidArgumentException
* @return Cloud
*/
public function setCloudDecorator($decorator)
{
Expand All @@ -215,11 +198,11 @@ public function setCloudDecorator($decorator)
}

if (is_string($decorator)) {
$decorator = $this->getDecoratorBroker()->load($decorator, $options);
$decorator = $this->getDecoratorPluginManager()->get($decorator, $options);
}

if (!($decorator instanceof Cloud\Decorator\Cloud)) {
throw new InvalidArgumentException('DecoratorInterface is no instance of Zend\Tag\Cloud\Decorator\Cloud');
if (!($decorator instanceof Cloud\Decorator\AbstractCloud)) {
throw new Exception\InvalidArgumentException('DecoratorInterface is no instance of Cloud\Decorator\AbstractCloud');
}

$this->_cloudDecorator = $decorator;
Expand All @@ -244,8 +227,8 @@ public function getCloudDecorator()
* Set the decorator for the tags
*
* @param mixed $decorator
* @throws \Zend\Tag\Exception\InvalidArgumentException
* @return \Zend\Tag\Cloud
* @throws Exception\InvalidArgumentException
* @return Cloud
*/
public function setTagDecorator($decorator)
{
Expand All @@ -262,11 +245,11 @@ public function setTagDecorator($decorator)
}

if (is_string($decorator)) {
$decorator = $this->getDecoratorBroker()->load($decorator, $options);
$decorator = $this->getDecoratorPluginManager()->get($decorator, $options);
}

if (!($decorator instanceof Cloud\Decorator\Tag)) {
throw new InvalidArgumentException('DecoratorInterface is no instance of Zend\Tag\Cloud\Decorator\Tag');
if (!($decorator instanceof Cloud\Decorator\AbstractTag)) {
throw new Exception\InvalidArgumentException('DecoratorInterface is no instance of Cloud\Decorator\Tag');
}

$this->_tagDecorator = $decorator;
Expand All @@ -288,29 +271,29 @@ public function getTagDecorator()
}

/**
* Set plugin broker for use with decorators
* Set plugin manager for use with decorators
*
* @param \Zend\Loader\Broker $broker
* @return \Zend\Tag\Cloud
* @param Cloud\DecoratorPluginManager $decorators
* @return Cloud
*/
public function setDecoratorBroker(Broker $broker)
public function setDecoratorPluginManager(Cloud\DecoratorPluginManager $decorators)
{
$this->_decoratorBroker = $broker;
$this->_decorators = $decorators;
return $this;
}

/**
* Get the plugin broker for decorators
* Get the plugin manager for decorators
*
* @return \Zend\Loader\Broker
* @return Cloud\DecoratorPluginManager
*/
public function getDecoratorBroker()
public function getDecoratorPluginManager()
{
if ($this->_decoratorBroker === null) {
$this->_decoratorBroker = new Cloud\DecoratorBroker();
if ($this->_decorators === null) {
$this->_decorators = new Cloud\DecoratorPluginManager();
}

return $this->_decoratorBroker;
return $this->_decorators;
}

/**
Expand Down
Loading

0 comments on commit 8d7b1b5

Please sign in to comment.