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 rfc/escaper
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 25 changed files with 490 additions and 128 deletions.
25 changes: 11 additions & 14 deletions src/Container.php → src/AbstractContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Navigation;

use Countable,
Expand All @@ -32,14 +29,14 @@
/**
* Zend_Navigation_Container
*
* Container class for Zend\Navigation\Page classes.
* AbstractContainer class for Zend\Navigation\Page classes.
*
* @category Zend
* @package Zend_Navigation
* @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 Container implements RecursiveIterator, Countable
abstract class AbstractContainer implements RecursiveIterator, Countable
{
/**
* Contains sub pages
Expand Down Expand Up @@ -112,7 +109,7 @@ public function notifyOrderUpdated()
* calling {@link Page\AbstractPage::setParent()}.
*
* @param Page\AbstractPage|array|Traversable $page page to add
* @return Container fluent interface, returns self
* @return AbstractContainer fluent interface, returns self
* @throws Exception\InvalidArgumentException if page is invalid
*/
public function addPage($page)
Expand Down Expand Up @@ -154,26 +151,26 @@ public function addPage($page)
/**
* Adds several pages at once
*
* @param array|Traversable|Container $pages pages to add
* @return Container fluent interface, returns self
* @param array|Traversable|AbstractContainer $pages pages to add
* @return AbstractContainer fluent interface, returns self
* @throws Exception\InvalidArgumentException if $pages is not array,
* Traversable or Container
* Traversable or AbstractContainer
*/
public function addPages($pages)
{
if (!is_array($pages) && !$pages instanceof Traversable) {
throw new Exception\InvalidArgumentException(
'Invalid argument: $pages must be an array, an '
. 'instance of Traversable or an instance of '
. 'Zend\Navigation\Container'
. 'Zend\Navigation\AbstractContainer'
);
}

// Because adding a page to a container removes it from the original
// (see {@link Page\AbstractPage::setParent()}), iteration of the
// original container will break. As such, we need to iterate the
// container into an array first.
if ($pages instanceof Container) {
if ($pages instanceof AbstractContainer) {
$pages = iterator_to_array($pages);
}

Expand All @@ -188,7 +185,7 @@ public function addPages($pages)
* Sets pages this container should have, removing existing pages
*
* @param array $pages pages to set
* @return Container fluent interface, returns self
* @return AbstractContainer fluent interface, returns self
*/
public function setPages(array $pages)
{
Expand Down Expand Up @@ -239,7 +236,7 @@ public function removePage($page)
/**
* Removes all pages in container
*
* @return Container fluent interface, returns self
* @return AbstractContainer fluent interface, returns self
*/
public function removePages()
{
Expand Down Expand Up @@ -370,7 +367,7 @@ public function __call($method, $arguments)
throw new Exception\BadMethodCallException(
sprintf(
'Bad method call: Unknown method %s::%s',
get_class($this),
get_called_class(),
$method
)
);
Expand Down
6 changes: 3 additions & 3 deletions src/Exception/BadMethodCallException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

namespace Zend\Navigation\Exception;

use Zend\Navigation\Exception;

/**
* Navigation bad method call exception
*
Expand All @@ -32,5 +30,7 @@
* @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 BadMethodCallException extends \BadMethodCallException implements Exception
class BadMethodCallException
extends \BadMethodCallException
implements ExceptionInterface
{}
6 changes: 3 additions & 3 deletions src/Exception/DomainException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

namespace Zend\Navigation\Exception;

use Zend\Navigation\Exception;

/**
* Navigation domain exception
*
Expand All @@ -32,5 +30,7 @@
* @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 DomainException extends \DomainException implements Exception
class DomainException
extends \DomainException
implements ExceptionInterface
{}
7 changes: 2 additions & 5 deletions src/Exception.php → src/Exception/ExceptionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Navigation;
namespace Zend\Navigation\Exception;

/**
* Navigation exception
Expand All @@ -31,7 +28,7 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception
interface ExceptionInterface
{

}
6 changes: 3 additions & 3 deletions src/Exception/InvalidArgumentException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

namespace Zend\Navigation\Exception;

use Zend\Navigation\Exception;

/**
* Navigation invalid argument exception
*
Expand All @@ -32,5 +30,7 @@
* @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 InvalidArgumentException extends \InvalidArgumentException implements Exception
class InvalidArgumentException
extends \InvalidArgumentException
implements ExceptionInterface
{}
6 changes: 3 additions & 3 deletions src/Exception/OutOfBoundsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

namespace Zend\Navigation\Exception;

use Zend\Navigation\Exception;

/**
* Navigation out of bounds exception
*
Expand All @@ -32,5 +30,7 @@
* @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 OutOfBoundsException extends \OutOfBoundsException implements Exception
class OutOfBoundsException
extends \OutOfBoundsException
implements ExceptionInterface
{}
2 changes: 1 addition & 1 deletion src/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @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 Navigation extends Container
class Navigation extends AbstractContainer
{
/**
* Creates a new navigation container
Expand Down
22 changes: 10 additions & 12 deletions src/Page/AbstractPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
namespace Zend\Navigation\Page;

use Traversable,
Zend\Acl\Resource as AclResource,
Zend\Navigation\Container,
Zend\Acl\Resource\ResourceInterface as AclResource,
Zend\Navigation\AbstractContainer,
Zend\Navigation\Exception,
Zend\Stdlib\ArrayUtils;

Expand All @@ -36,7 +36,7 @@
* @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 AbstractPage extends Container
abstract class AbstractPage extends AbstractContainer
{
/**
* Page label
Expand Down Expand Up @@ -143,7 +143,7 @@ abstract class AbstractPage extends Container
/**
* Parent container
*
* @var \Zend\Navigation\Container|null
* @var \Zend\Navigation\AbstractContainer|null
*/
protected $parent;

Expand All @@ -168,7 +168,7 @@ abstract class AbstractPage extends Container
* If 'type' is not given, the type of page to construct will be determined
* by the following rules:
* - If $options contains either of the keys 'action', 'controller',
* 'module', or 'route', a Zend_Navigation_Page_Mvc page will be created.
* or 'route', a Zend_Navigation_Page_Mvc page will be created.
* - If $options contains the key 'uri', a Zend_Navigation_Page_Uri page
* will be created.
*
Expand Down Expand Up @@ -233,7 +233,6 @@ public static function factory($options)

$hasUri = isset($options['uri']);
$hasMvc = isset($options['action']) || isset($options['controller'])
|| isset($options['module'])
|| isset($options['route']);

if ($hasMvc) {
Expand Down Expand Up @@ -823,11 +822,11 @@ public function getVisible($recursive = false)
/**
* Sets parent container
*
* @param Container $parent [optional] new parent to set.
* @param AbstractContainer $parent [optional] new parent to set.
* Default is null which will set no parent.
* @return AbstractPage fluent interface, returns self
*/
public function setParent(Container $parent = null)
public function setParent(AbstractContainer $parent = null)
{
if ($parent === $this) {
throw new Exception\InvalidArgumentException(
Expand Down Expand Up @@ -859,7 +858,7 @@ public function setParent(Container $parent = null)
/**
* Returns parent container
*
* @return Container|null parent container or null
* @return AbstractContainer|null parent container or null
*/
public function getParent()
{
Expand Down Expand Up @@ -887,8 +886,7 @@ public function set($property, $value)

$method = 'set' . self::normalizePropertyName($property);

if ($method != 'setOptions' && $method != 'setConfig'
&& method_exists($this, $method)
if ($method != 'setOptions' && method_exists($this, $method)
) {
$this->$method($value);
} else {
Expand Down Expand Up @@ -1144,7 +1142,7 @@ public function toArray()
'privilege' => $this->getPrivilege(),
'active' => $this->isActive(),
'visible' => $this->isVisible(),
'type' => get_class($this),
'type' => get_called_class(),
'pages' => parent::toArray(),
));
}
Expand Down
24 changes: 22 additions & 2 deletions src/Page/Mvc.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Mvc extends AbstractPage
protected $params = array();

/**
* Route name to use when assembling URL
* RouteInterface name to use when assembling URL
*
* @see getHref()
* @var string
Expand All @@ -79,7 +79,7 @@ class Mvc extends AbstractPage
protected $hrefCache;

/**
* Route matches; used for routing parameters and testing validity
* RouteInterface matches; used for routing parameters and testing validity
*
* @var RouteMatch
*/
Expand Down Expand Up @@ -349,6 +349,16 @@ public function getRoute()
return $this->route;
}

/**
* Get the route match.
*
* @return \Zend\Mvc\Router\RouteMatch
*/
public function getRouteMatch()
{
return $this->routeMatch;
}

/**
* Set route match object from which parameters will be retrieved
*
Expand All @@ -361,6 +371,16 @@ public function setRouteMatch(RouteMatch $matches)
return $this;
}

/**
* Get the url helper.
*
* @return null|\Zend\View\Helper\Url
*/
public function getUrlHelper()
{
return $this->urlHelper;
}

/**
* Sets action helper for assembling URLs
*
Expand Down
Loading

0 comments on commit 7b0843e

Please sign in to comment.