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

25 files changed

+490
-128
lines changed

src/Container.php renamed to src/AbstractContainer.php

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
* @license http://framework.zend.com/license/new-bsd New BSD License
1919
*/
2020

21-
/**
22-
* @namespace
23-
*/
2421
namespace Zend\Navigation;
2522

2623
use Countable,
@@ -32,14 +29,14 @@
3229
/**
3330
* Zend_Navigation_Container
3431
*
35-
* Container class for Zend\Navigation\Page classes.
32+
* AbstractContainer class for Zend\Navigation\Page classes.
3633
*
3734
* @category Zend
3835
* @package Zend_Navigation
3936
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
4037
* @license http://framework.zend.com/license/new-bsd New BSD License
4138
*/
42-
abstract class Container implements RecursiveIterator, Countable
39+
abstract class AbstractContainer implements RecursiveIterator, Countable
4340
{
4441
/**
4542
* Contains sub pages
@@ -112,7 +109,7 @@ public function notifyOrderUpdated()
112109
* calling {@link Page\AbstractPage::setParent()}.
113110
*
114111
* @param Page\AbstractPage|array|Traversable $page page to add
115-
* @return Container fluent interface, returns self
112+
* @return AbstractContainer fluent interface, returns self
116113
* @throws Exception\InvalidArgumentException if page is invalid
117114
*/
118115
public function addPage($page)
@@ -154,26 +151,26 @@ public function addPage($page)
154151
/**
155152
* Adds several pages at once
156153
*
157-
* @param array|Traversable|Container $pages pages to add
158-
* @return Container fluent interface, returns self
154+
* @param array|Traversable|AbstractContainer $pages pages to add
155+
* @return AbstractContainer fluent interface, returns self
159156
* @throws Exception\InvalidArgumentException if $pages is not array,
160-
* Traversable or Container
157+
* Traversable or AbstractContainer
161158
*/
162159
public function addPages($pages)
163160
{
164161
if (!is_array($pages) && !$pages instanceof Traversable) {
165162
throw new Exception\InvalidArgumentException(
166163
'Invalid argument: $pages must be an array, an '
167164
. 'instance of Traversable or an instance of '
168-
. 'Zend\Navigation\Container'
165+
. 'Zend\Navigation\AbstractContainer'
169166
);
170167
}
171168

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

@@ -188,7 +185,7 @@ public function addPages($pages)
188185
* Sets pages this container should have, removing existing pages
189186
*
190187
* @param array $pages pages to set
191-
* @return Container fluent interface, returns self
188+
* @return AbstractContainer fluent interface, returns self
192189
*/
193190
public function setPages(array $pages)
194191
{
@@ -239,7 +236,7 @@ public function removePage($page)
239236
/**
240237
* Removes all pages in container
241238
*
242-
* @return Container fluent interface, returns self
239+
* @return AbstractContainer fluent interface, returns self
243240
*/
244241
public function removePages()
245242
{
@@ -370,7 +367,7 @@ public function __call($method, $arguments)
370367
throw new Exception\BadMethodCallException(
371368
sprintf(
372369
'Bad method call: Unknown method %s::%s',
373-
get_class($this),
370+
get_called_class(),
374371
$method
375372
)
376373
);

src/Exception/BadMethodCallException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
namespace Zend\Navigation\Exception;
2323

24-
use Zend\Navigation\Exception;
25-
2624
/**
2725
* Navigation bad method call exception
2826
*
@@ -32,5 +30,7 @@
3230
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
3331
* @license http://framework.zend.com/license/new-bsd New BSD License
3432
*/
35-
class BadMethodCallException extends \BadMethodCallException implements Exception
33+
class BadMethodCallException
34+
extends \BadMethodCallException
35+
implements ExceptionInterface
3636
{}

src/Exception/DomainException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
namespace Zend\Navigation\Exception;
2323

24-
use Zend\Navigation\Exception;
25-
2624
/**
2725
* Navigation domain exception
2826
*
@@ -32,5 +30,7 @@
3230
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
3331
* @license http://framework.zend.com/license/new-bsd New BSD License
3432
*/
35-
class DomainException extends \DomainException implements Exception
33+
class DomainException
34+
extends \DomainException
35+
implements ExceptionInterface
3636
{}

src/Exception.php renamed to src/Exception/ExceptionInterface.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@
1818
* @license http://framework.zend.com/license/new-bsd New BSD License
1919
*/
2020

21-
/**
22-
* @namespace
23-
*/
24-
namespace Zend\Navigation;
21+
namespace Zend\Navigation\Exception;
2522

2623
/**
2724
* Navigation exception
@@ -31,7 +28,7 @@
3128
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
3229
* @license http://framework.zend.com/license/new-bsd New BSD License
3330
*/
34-
interface Exception
31+
interface ExceptionInterface
3532
{
3633

3734
}

src/Exception/InvalidArgumentException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
namespace Zend\Navigation\Exception;
2323

24-
use Zend\Navigation\Exception;
25-
2624
/**
2725
* Navigation invalid argument exception
2826
*
@@ -32,5 +30,7 @@
3230
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
3331
* @license http://framework.zend.com/license/new-bsd New BSD License
3432
*/
35-
class InvalidArgumentException extends \InvalidArgumentException implements Exception
33+
class InvalidArgumentException
34+
extends \InvalidArgumentException
35+
implements ExceptionInterface
3636
{}

src/Exception/OutOfBoundsException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121

2222
namespace Zend\Navigation\Exception;
2323

24-
use Zend\Navigation\Exception;
25-
2624
/**
2725
* Navigation out of bounds exception
2826
*
@@ -32,5 +30,7 @@
3230
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
3331
* @license http://framework.zend.com/license/new-bsd New BSD License
3432
*/
35-
class OutOfBoundsException extends \OutOfBoundsException implements Exception
33+
class OutOfBoundsException
34+
extends \OutOfBoundsException
35+
implements ExceptionInterface
3636
{}

src/Navigation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
3131
* @license http://framework.zend.com/license/new-bsd New BSD License
3232
*/
33-
class Navigation extends Container
33+
class Navigation extends AbstractContainer
3434
{
3535
/**
3636
* Creates a new navigation container

src/Page/AbstractPage.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
namespace Zend\Navigation\Page;
2323

2424
use Traversable,
25-
Zend\Acl\Resource as AclResource,
26-
Zend\Navigation\Container,
25+
Zend\Acl\Resource\ResourceInterface as AclResource,
26+
Zend\Navigation\AbstractContainer,
2727
Zend\Navigation\Exception,
2828
Zend\Stdlib\ArrayUtils;
2929

@@ -36,7 +36,7 @@
3636
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
3737
* @license http://framework.zend.com/license/new-bsd New BSD License
3838
*/
39-
abstract class AbstractPage extends Container
39+
abstract class AbstractPage extends AbstractContainer
4040
{
4141
/**
4242
* Page label
@@ -143,7 +143,7 @@ abstract class AbstractPage extends Container
143143
/**
144144
* Parent container
145145
*
146-
* @var \Zend\Navigation\Container|null
146+
* @var \Zend\Navigation\AbstractContainer|null
147147
*/
148148
protected $parent;
149149

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

234234
$hasUri = isset($options['uri']);
235235
$hasMvc = isset($options['action']) || isset($options['controller'])
236-
|| isset($options['module'])
237236
|| isset($options['route']);
238237

239238
if ($hasMvc) {
@@ -823,11 +822,11 @@ public function getVisible($recursive = false)
823822
/**
824823
* Sets parent container
825824
*
826-
* @param Container $parent [optional] new parent to set.
825+
* @param AbstractContainer $parent [optional] new parent to set.
827826
* Default is null which will set no parent.
828827
* @return AbstractPage fluent interface, returns self
829828
*/
830-
public function setParent(Container $parent = null)
829+
public function setParent(AbstractContainer $parent = null)
831830
{
832831
if ($parent === $this) {
833832
throw new Exception\InvalidArgumentException(
@@ -859,7 +858,7 @@ public function setParent(Container $parent = null)
859858
/**
860859
* Returns parent container
861860
*
862-
* @return Container|null parent container or null
861+
* @return AbstractContainer|null parent container or null
863862
*/
864863
public function getParent()
865864
{
@@ -887,8 +886,7 @@ public function set($property, $value)
887886

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

890-
if ($method != 'setOptions' && $method != 'setConfig'
891-
&& method_exists($this, $method)
889+
if ($method != 'setOptions' && method_exists($this, $method)
892890
) {
893891
$this->$method($value);
894892
} else {
@@ -1144,7 +1142,7 @@ public function toArray()
11441142
'privilege' => $this->getPrivilege(),
11451143
'active' => $this->isActive(),
11461144
'visible' => $this->isVisible(),
1147-
'type' => get_class($this),
1145+
'type' => get_called_class(),
11481146
'pages' => parent::toArray(),
11491147
));
11501148
}

src/Page/Mvc.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Mvc extends AbstractPage
6060
protected $params = array();
6161

6262
/**
63-
* Route name to use when assembling URL
63+
* RouteInterface name to use when assembling URL
6464
*
6565
* @see getHref()
6666
* @var string
@@ -79,7 +79,7 @@ class Mvc extends AbstractPage
7979
protected $hrefCache;
8080

8181
/**
82-
* Route matches; used for routing parameters and testing validity
82+
* RouteInterface matches; used for routing parameters and testing validity
8383
*
8484
* @var RouteMatch
8585
*/
@@ -349,6 +349,16 @@ public function getRoute()
349349
return $this->route;
350350
}
351351

352+
/**
353+
* Get the route match.
354+
*
355+
* @return \Zend\Mvc\Router\RouteMatch
356+
*/
357+
public function getRouteMatch()
358+
{
359+
return $this->routeMatch;
360+
}
361+
352362
/**
353363
* Set route match object from which parameters will be retrieved
354364
*
@@ -361,6 +371,16 @@ public function setRouteMatch(RouteMatch $matches)
361371
return $this;
362372
}
363373

374+
/**
375+
* Get the url helper.
376+
*
377+
* @return null|\Zend\View\Helper\Url
378+
*/
379+
public function getUrlHelper()
380+
{
381+
return $this->urlHelper;
382+
}
383+
364384
/**
365385
* Sets action helper for assembling URLs
366386
*

0 commit comments

Comments
 (0)