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

Commit

Permalink
Merge branch 'develop' of git://github.com/zendframework/zf2 into string
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 28 changed files with 606 additions and 719 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"homepage": "https://github.com/zendframework/zend-tag",
"autoload": {
"psr-4": {
"Zend\\Tag": "src/"
"Zend\\Tag\\": "src/"
}
},
"require": {
Expand Down
80 changes: 31 additions & 49 deletions src/Cloud.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?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;
Expand All @@ -27,45 +16,43 @@
/**
* @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
{
/**
* DecoratorInterface for the cloud
*
* @var Cloud
* @var Cloud\Decorator\AbstractCloud
*/
protected $_cloudDecorator = null;
protected $cloudDecorator = null;

/**
* DecoratorInterface for the tags
*
* @var Tag
* @var Cloud\Decorator\AbstractTag
*/
protected $_tagDecorator = null;
protected $tagDecorator = null;

/**
* List of all tags
*
* @var ItemList
*/
protected $_tags = null;
protected $tags = null;

/**
* Plugin manager for decorators
*
* @var Cloud\DecoratorPluginManager
*/
protected $_decorators = null;
protected $decorators = null;

/**
* Option keys to skip when calling setOptions()
*
* @var array
*/
protected $_skipOptions = array(
protected $skipOptions = array(
'options',
'config',
);
Expand Down Expand Up @@ -93,17 +80,12 @@ public function __construct($options = null)
*/
public function setOptions(array $options)
{
if (isset($options['prefixPath'])) {
$this->addPrefixPaths($options['prefixPath']);
unset($options['prefixPath']);
}

foreach ($options as $key => $value) {
if (in_array(strtolower($key), $this->_skipOptions)) {
if (in_array(strtolower($key), $this->skipOptions)) {
continue;
}

$method = 'set' . ucfirst($key);
$method = 'set' . $key;
if (method_exists($this, $method)) {
$this->$method($value);
}
Expand Down Expand Up @@ -147,7 +129,7 @@ public function appendTag($tag)
if ($tag instanceof TaggableInterface) {
$tags[] = $tag;
return $this;
}
}

if (!is_array($tag)) {
throw new Exception\InvalidArgumentException(sprintf(
Expand All @@ -170,7 +152,7 @@ public function appendTag($tag)
*/
public function setItemList(ItemList $itemList)
{
$this->_tags = $itemList;
$this->tags = $itemList;
return $this;
}

Expand All @@ -183,10 +165,10 @@ public function setItemList(ItemList $itemList)
*/
public function getItemList()
{
if (null === $this->_tags) {
if (null === $this->tags) {
$this->setItemList(new ItemList());
}
return $this->_tags;
return $this->tags;
}

/**
Expand Down Expand Up @@ -218,22 +200,22 @@ public function setCloudDecorator($decorator)
throw new Exception\InvalidArgumentException('DecoratorInterface is no instance of Cloud\Decorator\AbstractCloud');
}

$this->_cloudDecorator = $decorator;
$this->cloudDecorator = $decorator;

return $this;
}

/**
* Get the decorator for the cloud
*
* @return Cloud
* @return Cloud\Decorator\AbstractCloud
*/
public function getCloudDecorator()
{
if (null === $this->_cloudDecorator) {
if (null === $this->cloudDecorator) {
$this->setCloudDecorator('htmlCloud');
}
return $this->_cloudDecorator;
return $this->cloudDecorator;
}

/**
Expand Down Expand Up @@ -262,25 +244,25 @@ public function setTagDecorator($decorator)
}

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

$this->_tagDecorator = $decorator;
$this->tagDecorator = $decorator;

return $this;
}

/**
* Get the decorator for the tags
*
* @return Tag
* @return Cloud\Decorator\AbstractTag
*/
public function getTagDecorator()
{
if (null === $this->_tagDecorator) {
if (null === $this->tagDecorator) {
$this->setTagDecorator('htmlTag');
}
return $this->_tagDecorator;
return $this->tagDecorator;
}

/**
Expand All @@ -291,7 +273,7 @@ public function getTagDecorator()
*/
public function setDecoratorPluginManager(Cloud\DecoratorPluginManager $decorators)
{
$this->_decorators = $decorators;
$this->decorators = $decorators;
return $this;
}

Expand All @@ -302,11 +284,11 @@ public function setDecoratorPluginManager(Cloud\DecoratorPluginManager $decorato
*/
public function getDecoratorPluginManager()
{
if ($this->_decorators === null) {
$this->_decorators = new Cloud\DecoratorPluginManager();
if ($this->decorators === null) {
$this->decorators = new Cloud\DecoratorPluginManager();
}

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

/**
Expand Down
75 changes: 6 additions & 69 deletions src/Cloud/Decorator/AbstractCloud.php
Original file line number Diff line number Diff line change
@@ -1,84 +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\Cloud\Decorator;

use Traversable;
use Zend\Stdlib\ArrayUtils;
use Zend\Tag\Cloud\Decorator\DecoratorInterface as Decorator;

/**
* Abstract class for cloud decorators
*
* @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
*/
abstract class AbstractCloud implements Decorator
abstract class AbstractCloud extends AbstractDecorator
{
/**
* Option keys to skip when calling setOptions()
*
* @var array
*/
protected $_skipOptions = array(
'options',
'config',
);

/**
* Create a new cloud decorator with options
*
* @param array|Traversable $options
*/
public function __construct($options = null)
{
if ($options instanceof Traversable) {
$options = ArrayUtils::iteratorToArray($options);
}
if (is_array($options)) {
$this->setOptions($options);
}
}

/**
* Set options from array
*
* @param array $options Configuration for the decorator
* @return AbstractCloud
*/
public function setOptions(array $options)
{
foreach ($options as $key => $value) {
if (in_array(strtolower($key), $this->_skipOptions)) {
continue;
}

$method = 'set' . $key;
if (method_exists($this, $method)) {
$this->$method($value);
}
}

return $this;
}
}
Loading

0 comments on commit 608988f

Please sign in to comment.