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

Commit

Permalink
Zend\Navigation cleanup
Browse files Browse the repository at this point in the history
- s/Zend\Navigation\Page\Page/Zend\Navigation\AbstractPage/
- Updated code and tests to reflect above
- Enabled and debugged all Navigation view helper tests
  • Loading branch information
weierophinney committed Jul 1, 2010
1 parent 6f2ac50 commit adcd6b4
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 175 deletions.
106 changes: 53 additions & 53 deletions src/Page/Page.php → src/AbstractPage.php

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* @uses RecursiveIterator
* @uses RecursiveIteratorIterator
* @uses \Zend\Navigation\Exception
* @uses \Zend\Navigation\Page\Page
* @uses \Zend\Navigation\AbstractPage
* @category Zend
* @package Zend_Navigation
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
Expand Down Expand Up @@ -123,8 +123,8 @@ public function addPage($page)
}

if (is_array($page) || $page instanceof Config\Config) {
$page = Page\Page::factory($page);
} elseif (!$page instanceof Page\Page) {
$page = AbstractPage::factory($page);
} elseif (!$page instanceof AbstractPage) {
throw new Exception(
'Invalid argument: $page must be an instance of ' .
'Zend_Navigation_Page or Zend_Config, or an array');
Expand Down Expand Up @@ -189,7 +189,7 @@ public function setPages(array $pages)
/**
* Returns pages in the container
*
* @return array array of \Zend\Navigation\Page\Page instances
* @return array array of \Zend\Navigation\AbstractPage instances
*/
public function getPages()
{
Expand All @@ -199,14 +199,14 @@ public function getPages()
/**
* Removes the given page from the container
*
* @param \Zend\Navigation\Page\Page|int $page page to remove, either a page
* @param \Zend\Navigation\AbstractPage|int $page page to remove, either a page
* instance or a specific page order
* @return bool whether the removal was
* successful
*/
public function removePage($page)
{
if ($page instanceof Page\Page) {
if ($page instanceof AbstractPage) {
$hash = $page->hashCode();
} elseif (is_int($page)) {
$this->_sort();
Expand Down Expand Up @@ -242,12 +242,12 @@ public function removePages()
/**
* Checks if the container has the given page
*
* @param \Zend\Navigation\Page\Page $page page to look for
* @param \Zend\Navigation\AbstractPage $page page to look for
* @param bool $recursive [optional] whether to search
* recursively. Default is false.
* @return bool whether page is in container
*/
public function hasPage(Page\Page $page, $recursive = false)
public function hasPage(AbstractPage $page, $recursive = false)
{
if (array_key_exists($page->hashCode(), $this->_index)) {
return true;
Expand Down Expand Up @@ -277,7 +277,7 @@ public function hasPages()
*
* @param string $property name of property to match against
* @param mixed $value value to match property against
* @return \Zend\Navigation\Page\Page|null matching page or null
* @return \Zend\Navigation\AbstractPage|null matching page or null
*/
public function findOneBy($property, $value)
{
Expand All @@ -299,7 +299,7 @@ public function findOneBy($property, $value)
*
* @param string $property name of property to match against
* @param mixed $value value to match property against
* @return array array containing only \Zend\Navigation\Page\Page
* @return array array containing only \Zend\Navigation\AbstractPage
* instances
*/
public function findAllBy($property, $value)
Expand Down Expand Up @@ -329,7 +329,7 @@ public function findAllBy($property, $value)
* matching pages are found. If false, null will
* be returned if no matching page is found.
* Default is false.
* @return \Zend\Navigation\Page\Page|null matching page or null
* @return \Zend\Navigation\AbstractPage|null matching page or null
*/
public function findBy($property, $value, $all = false)
{
Expand Down Expand Up @@ -392,7 +392,7 @@ public function toArray()
*
* Implements RecursiveIterator interface.
*
* @return \Zend\Navigation\Page\Page current page or null
* @return \Zend\Navigation\AbstractPage current page or null
* @throws \Zend\Navigation\Exception if the index is invalid
*/
public function current()
Expand Down Expand Up @@ -479,7 +479,7 @@ public function hasChildren()
*
* Implements RecursiveIterator interface.
*
* @return \Zend\Navigation\Page\Page|null
* @return \Zend\Navigation\AbstractPage|null
*/
public function getChildren()
{
Expand Down
14 changes: 8 additions & 6 deletions src/Page/Mvc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
* @namespace
*/
namespace Zend\Navigation\Page;
use Zend\Navigation;

use Zend\Navigation\AbstractPage,
Zend\Navigation\Exception as NavigationException;

/**
* Represents a page that is defined using module, controller, action, route
Expand All @@ -40,7 +42,7 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Mvc extends Page
class Mvc extends AbstractPage
{
/**
* Action name to use when assembling URL
Expand Down Expand Up @@ -211,7 +213,7 @@ public function getHref()
public function setAction($action)
{
if (null !== $action && !is_string($action)) {
throw new Navigation\Exception(
throw new NavigationException(
'Invalid argument: $action must be a string or null');
}

Expand Down Expand Up @@ -244,7 +246,7 @@ public function getAction()
public function setController($controller)
{
if (null !== $controller && !is_string($controller)) {
throw new Navigation\Exception(
throw new NavigationException(
'Invalid argument: $controller must be a string or null');
}

Expand Down Expand Up @@ -277,7 +279,7 @@ public function getController()
public function setModule($module)
{
if (null !== $module && !is_string($module)) {
throw new Navigation\Exception(
throw new NavigationException(
'Invalid argument: $module must be a string or null');
}

Expand Down Expand Up @@ -344,7 +346,7 @@ public function getParams()
public function setRoute($route)
{
if (null !== $route && (!is_string($route) || strlen($route) < 1)) {
throw new Navigation\Exception(
throw new NavigationException(
'Invalid argument: $route must be a non-empty string or null');
}

Expand Down
7 changes: 5 additions & 2 deletions src/Page/Uri.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
*/
namespace Zend\Navigation\Page;

use Zend\Navigation\AbstractPage,
Zend\Navigation\Exception as NavigationException;

/**
* Represents a page that is defined by specifying a URI
*
Expand All @@ -36,7 +39,7 @@
* @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class Uri extends Page
class Uri extends AbstractPage
{
/**
* Page URI
Expand All @@ -55,7 +58,7 @@ class Uri extends Page
public function setUri($uri)
{
if (null !== $uri && !is_string($uri)) {
throw new \Zend\Navigation\Exception(
throw new NavigationException(
'Invalid argument: $uri must be a string or null');
}

Expand Down
Loading

0 comments on commit adcd6b4

Please sign in to comment.