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

Commit

Permalink
Merge branch 'master' into markup
Browse files Browse the repository at this point in the history
Conflicts:
	library/Zend/Markup/Parser/Textile.php
	library/Zend/Markup/Renderer/AbstractRenderer.php
	library/Zend/Markup/Renderer/Html.php
  • Loading branch information
kokx committed Oct 30, 2010
2 parents 39d42ba + 8c442a3 commit 0eeb6ff
Show file tree
Hide file tree
Showing 19 changed files with 171 additions and 145 deletions.
90 changes: 46 additions & 44 deletions src/AbstractPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @package Zend_Navigation
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand All @@ -31,7 +30,7 @@
*
* @uses \Zend\Loader
* @uses \Zend\Navigation\Container
* @uses \Zend\Navigation\Exception
* @uses \Zend\Navigation\InvalidArgumentException
* @uses \Zend\Navigation\Page\Mvc
* @uses \Zend\Navigation\Page\Uri
* @category Zend
Expand Down Expand Up @@ -163,16 +162,19 @@ abstract class AbstractPage extends Container
*
* @param array|\Zend\Config\Config $options options used for creating page
* @return \Zend\Navigation\AbstractPage a page instance
* @throws Zend_Navigation_Exception if $options is not array/\Zend\Config\Config
* @throws \Zend\Exception if 'type' is specified and
* Zend_Loader is unable to load the
* class
* @throws \Zend\Navigation\Exception if something goes wrong during
* instantiation of the page
* @throws \Zend\Navigation\Exception if 'type' is given, and the specified
* type does not extend this class
* @throws \Zend\Navigation\Exception if unable to determine which class
* to instantiate
* @throws \Zend\Navigation\InvalidArgumentException if $options is not
* array/\Zend\Config\Config
* @throws \Zend\Navigation\InvalidArgumentException if 'type' is specified
* and Zend_Loader is unable
* to load the class
* @throws \Zend\Navigation\InvalidArgumentException if something goes wrong
* during instantiation of
* the page
* @throws \Zend\Navigation\InvalidArgumentException if 'type' is given, and
* the specified type does
* not extend this class
* @throws \Zend\Navigation\InvalidArgumentException if unable to determine
* which class to instantiate
*/
public static function factory($options)
{
Expand All @@ -181,7 +183,7 @@ public static function factory($options)
}

if (!is_array($options)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $options must be an array or Zend\Config\Config');
}

Expand All @@ -198,12 +200,12 @@ public static function factory($options)
}

if (!class_exists($type, true)) {
throw new Exception('Cannot find class ' . $type);
throw new Exception\InvalidArgumentException('Cannot find class ' . $type);
}

$page = new $type($options);
if (!$page instanceof self) {
throw new Exception(sprintf(
throw new Exception\InvalidArgumentException(sprintf(
'Invalid argument: Detected type "%s", which ' .
'is not an instance of Zend_Navigation_Page',
$type));
Expand All @@ -221,7 +223,7 @@ public static function factory($options)
} elseif ($hasUri) {
return new Page\Uri($options);
} else {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: Unable to determine class to instantiate');
}
}
Expand Down Expand Up @@ -259,7 +261,7 @@ protected function _init()
*
* @param \Zend\Config\Config $config config object to get properties from
* @return \Zend\Navigation\AbstractPage fluent interface, returns self
* @throws \Zend\Navigation\Exception if invalid options are given
* @throws \Zend\Navigation\InvalidArgumentException if invalid options are given
*/
public function setConfig(Config $config)
{
Expand All @@ -276,7 +278,7 @@ public function setConfig(Config $config)
*
* @param array $options associative array of options to set
* @return \Zend\Navigation\Page\Page fluent interface, returns self
* @throws \Zend\Navigation\Exception if invalid options are given
* @throws \Zend\Navigation\InvalidArgumentException if invalid options are given
*/
public function setOptions(array $options)
{
Expand All @@ -294,12 +296,12 @@ public function setOptions(array $options)
*
* @param string $label new page label
* @return \Zend\Navigation\Page\Page fluent interface, returns self
* @throws \Zend\Navigation\Exception if empty/no string is given
* @throws \Zend\Navigation\InvalidArgumentException if empty/no string is given
*/
public function setLabel($label)
{
if (null !== $label && !is_string($label)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $label must be a string or null');
}

Expand All @@ -323,12 +325,12 @@ public function getLabel()
* @param string|null $id [optional] id to set. Default is null,
* which sets no id.
* @return \Zend\Navigation\AbstractPage fluent interface, returns self
* @throws \Zend\Navigation\Exception if not given string or null
* @throws \Zend\Navigation\InvalidArgumentException if not given string or null
*/
public function setId($id = null)
{
if (null !== $id && !is_string($id) && !is_numeric($id)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $id must be a string, number or null');
}

Expand All @@ -353,12 +355,12 @@ public function getId()
* @param string|null $class [optional] CSS class to set. Default
* is null, which sets no CSS class.
* @return \Zend\Navigation\AbstractPage fluent interface, returns self
* @throws \Zend\Navigation\Exception if not given string or null
* @throws \Zend\Navigation\InvalidArgumentException if not given string or null
*/
public function setClass($class = null)
{
if (null !== $class && !is_string($class)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $class must be a string or null');
}

Expand All @@ -382,12 +384,12 @@ public function getClass()
* @param string $title [optional] page title. Default is
* null, which sets no title.
* @return \Zend\Navigation\AbstractPage fluent interface, returns self
* @throws \Zend\Navigation\Exception if not given string or null
* @throws \Zend\Navigation\InvalidArgumentException if not given string or null
*/
public function setTitle($title = null)
{
if (null !== $title && !is_string($title)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $title must be a non-empty string');
}

Expand All @@ -411,12 +413,12 @@ public function getTitle()
* @param string|null $target [optional] target to set. Default is
* null, which sets no target.
* @return \Zend\Navigation\AbstractPage fluent interface, returns self
* @throws \Zend\Navigation\Exception if target is not string or null
* @throws \Zend\Navigation\InvalidArgumentException if target is not string or null
*/
public function setTarget($target = null)
{
if (null !== $target && !is_string($target)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $target must be a string or null');
}

Expand Down Expand Up @@ -456,7 +458,7 @@ public function setRel($relations = null)
}

if (!is_array($relations)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $relations must be an ' .
'array or an instance of Zend\Config');
}
Expand Down Expand Up @@ -518,7 +520,7 @@ public function setRev($relations = null)
}

if (!is_array($relations)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $relations must be an ' .
'array or an instance of Zend\Config');
}
Expand Down Expand Up @@ -565,7 +567,7 @@ public function getRev($relation = null)
* Default is null, which sets no
* specific order.
* @return \Zend\Navigation\AbstractPage fluent interface, returns self
* @throws \Zend\Navigation\Exception if order is not integer or null
* @throws \Zend\Navigation\InvalidArgumentException if order is not integer or null
*/
public function setOrder($order = null)
{
Expand All @@ -577,7 +579,7 @@ public function setOrder($order = null)
}

if (null !== $order && !is_int($order)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $order must be an integer or null, ' .
'or a string that casts to an integer');
}
Expand Down Expand Up @@ -610,9 +612,9 @@ public function getOrder()
* page. Default is
* null, which sets no
* resource.
* @throws \Zend\Navigation\Exception if $resource if
* @throws \Zend\Navigation\InvalidArgumentException if $resource is
* invalid
* @return \Zend\Navigation\AbstractPage fluent interface,
* @return \Zend\Navigation\AbstractPage fluent interface,
* returns self
*/
public function setResource($resource = null)
Expand All @@ -621,7 +623,7 @@ public function setResource($resource = null)
$resource instanceof \Zend\Acl\Resource) {
$this->_resource = $resource;
} else {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $resource must be null, a string, ' .
' or an instance of Zend_Acl_Resource_Interface');
}
Expand Down Expand Up @@ -770,7 +772,7 @@ public function getVisible($recursive = false)
public function setParent(Container $parent = null)
{
if ($parent === $this) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'A page cannot have itself as a parent');
}

Expand Down Expand Up @@ -814,12 +816,12 @@ public function getParent()
* @param string $property property name
* @param mixed $value value to set
* @return \Zend\Navigation\AbstractPage fluent interface, returns self
* @throws \Zend\Navigation\Exception if property name is invalid
* @throws \Zend\Navigation\InvalidArgumentException if property name is invalid
*/
public function set($property, $value)
{
if (!is_string($property) || empty($property)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $property must be a non-empty string');
}

Expand All @@ -844,12 +846,12 @@ public function set($property, $value)
*
* @param string $property property name
* @return mixed the property's value or null
* @throws \Zend\Navigation\Exception if property name is invalid
* @throws \Zend\Navigation\InvalidArgumentException if property name is invalid
*/
public function get($property)
{
if (!is_string($property) || empty($property)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $property must be a non-empty string');
}

Expand All @@ -874,7 +876,7 @@ public function get($property)
* @param string $name property name
* @param mixed $value value to set
* @return void
* @throws \Zend\Navigation\Exception if property name is invalid
* @throws \Zend\Navigation\InvalidArgumentException if property name is invalid
*/
public function __set($name, $value)
{
Expand All @@ -888,7 +890,7 @@ public function __set($name, $value)
*
* @param string $name property name
* @return mixed property value or null
* @throws \Zend\Navigation\Exception if property name is invalid
* @throws \Zend\Navigation\InvalidArgumentException if property name is invalid
*/
public function __get($name)
{
Expand Down Expand Up @@ -924,13 +926,13 @@ public function __isset($name)
*
* @param string $name property name
* @return void
* @throws \Zend\Navigation\Exception if the property is native
* @throws \Zend\Navigation\InvalidArgumentException if the property is native
*/
public function __unset($name)
{
$method = 'set' . self::_normalizePropertyName($name);
if (method_exists($this, $method)) {
throw new Exception(sprintf(
throw new Exception\InvalidArgumentException(sprintf(
'Unsetting native property "%s" is not allowed',
$name));
}
Expand Down
22 changes: 11 additions & 11 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* @package Zend_Navigation
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @version $Id$
*/

/**
Expand All @@ -33,7 +32,7 @@
* @uses Countable
* @uses RecursiveIterator
* @uses RecursiveIteratorIterator
* @uses \Zend\Navigation\Exception
* @uses \Zend\Navigation\InvalidArgumentException
* @uses \Zend\Navigation\AbstractPage
* @category Zend
* @package Zend_Navigation
Expand Down Expand Up @@ -113,19 +112,19 @@ public function notifyOrderUpdated()
* @param Zend_Navigation_Page|array|\Zend\Config\Config $page page to add
* @return \Zend\Navigation\Container fluent interface,
* returns self
* @throws \Zend\Navigation\Exception if page is invalid
* @throws \Zend\Navigation\InvalidArgumentException if page is invalid
*/
public function addPage($page)
{
if ($page === $this) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'A page cannot have itself as a parent');
}

if (is_array($page) || $page instanceof Config\Config) {
$page = AbstractPage::factory($page);
} elseif (!$page instanceof AbstractPage) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $page must be an instance of ' .
'Zend_Navigation_Page or Zend_Config, or an array');
}
Expand Down Expand Up @@ -153,7 +152,8 @@ public function addPage($page)
*
* @param array|\Zend\Config\Config $pages pages to add
* @return \Zend\Navigation\Container fluent interface, returns self
* @throws Zend_Navigation_Exception if $pages is not array or \Zend\Config\Config
* @throws \Zend\Navigation\InvalidArgumentException if $pages is not array
* or \Zend\Config\Config
*/
public function addPages($pages)
{
Expand All @@ -162,7 +162,7 @@ public function addPages($pages)
}

if (!is_array($pages)) {
throw new Exception(
throw new Exception\InvalidArgumentException(
'Invalid argument: $pages must be an array or an ' .
'instance of Zend_Config');
}
Expand Down Expand Up @@ -353,15 +353,15 @@ public function findBy($property, $value, $all = false)
*
* @param string $method method name
* @param array $arguments method arguments
* @throws \Zend\Navigation\Exception if method does not exist
* @throws \Zend\Navigation\InvalidArgumentException if method does not exist
*/
public function __call($method, $arguments)
{
if (@preg_match('/(find(?:One|All)?By)(.+)/', $method, $match)) {
return $this->{$match[1]}($match[2], $arguments[0]);
}

throw new Exception(sprintf(
throw new Exception\BadMethodCallException(sprintf(
'Bad method call: Unknown method %s::%s',
get_class($this),
$method));
Expand Down Expand Up @@ -393,7 +393,7 @@ public function toArray()
* Implements RecursiveIterator interface.
*
* @return \Zend\Navigation\AbstractPage current page or null
* @throws \Zend\Navigation\Exception if the index is invalid
* @throws \Zend\Navigation\InvalidArgumentException if the index is invalid
*/
public function current()
{
Expand All @@ -404,7 +404,7 @@ public function current()
if (isset($this->_pages[$hash])) {
return $this->_pages[$hash];
} else {
throw new Exception(
throw new Exception\OutOfBoundsException(
'Corruption detected in container; ' .
'invalid key found in internal iterator');
}
Expand Down
Loading

0 comments on commit 0eeb6ff

Please sign in to comment.