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

Commit

Permalink
Merge branch 'feature/3693' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Page/AbstractPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,13 @@ abstract class AbstractPage extends AbstractContainer
*/
protected $privilege;

/**
* Permission associated with this page
*
* @var string|null
*/
protected $permission;

/**
* Whether this page should be considered active
*
Expand Down Expand Up @@ -700,6 +707,31 @@ public function getPrivilege()
return $this->privilege;
}

/**
* Sets permission associated with this page
*
* @param string|null $permission [optional] permission to associate
* with this page. Default is null, which
* sets no permission.
*
* @return AbstractPage fluent interface, returns self
*/
public function setPermission($permission = null)
{
$this->permission = is_string($permission) ? $permission : null;
return $this;
}

/**
* Returns permission associated with this page
*
* @return string|null permission or null
*/
public function getPermission()
{
return $this->permission;
}

/**
* Sets whether page should be considered active or not
*
Expand Down Expand Up @@ -1127,6 +1159,7 @@ public function toArray()
'order' => $this->getOrder(),
'resource' => $this->getResource(),
'privilege' => $this->getPrivilege(),
'permission' => $this->getPermission(),
'active' => $this->isActive(),
'visible' => $this->isVisible(),
'type' => get_called_class(),
Expand Down
1 change: 1 addition & 0 deletions test/Page/MvcTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ public function testToArrayMethod()

$options['privilege'] = null;
$options['resource'] = null;
$options['permission'] = null;
$options['pages'] = array();
$options['type'] = 'Zend\Navigation\Page\Mvc';

Expand Down
3 changes: 3 additions & 0 deletions test/Page/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,7 @@ public function testToArrayMethod()

'resource' => 'joker',
'privilege' => null,
'permission' => null,

'foo' => 'bar',
'meaning' => 42,
Expand All @@ -1117,6 +1118,7 @@ public function testToArrayMethod()
'order' => null,
'resource' => null,
'privilege' => null,
'permission' => null,
'active' => null,
'visible' => 1,
'pages' => array(),
Expand All @@ -1136,6 +1138,7 @@ public function testToArrayMethod()
'order' => null,
'resource' => null,
'privilege' => null,
'permission' => null,
'active' => null,
'visible' => 1,
'pages' => array(),
Expand Down

0 comments on commit af2d845

Please sign in to comment.