|
Perforce Chronicle 2012.2/486814
API Documentation
|
This model is used to normalize P4Cms_Menu and Zend_Navigation_Page classes into a unifom model allowing them to be listed together. More...
Public Member Functions | |
| getDepth () | |
| Returns the depth of this item in the heigharchy. | |
| getId () | |
| Get the id of this record. | |
| getLabel () | |
| Return the label for this model. | |
| getMenu () | |
| Return the menu associated with this instance. | |
| getMenuId () | |
| Returns the ID off of the menu if one has been set. | |
| getMenuItem () | |
| Return the menu item associated with this instance. | |
| getMenuItemId () | |
| Returns the ID off of the menu item if one has been set. | |
| getNextMenuItem () | |
| Returns the nexdt menu item that lives at the same level as this models menu item. | |
| getParentContainer () | |
| Return the parent container for this menu item be it another page or a menu. | |
| getParentId () | |
| Return the parent P4Cms_Menu_Mixed id if any. | |
| getParentMenuItem () | |
| The Zend_Navigation_Page based object which is our parent or null. | |
| getPreviousMenuItem () | |
| Returns the previous menu item that lives at the same level as this models menu item. | |
| getType () | |
| Retrieve the identifier for this menu or menu item type. | |
| hasMenu () | |
| Determine if this instance has a menu object set on it. | |
| hasMenuItem () | |
| Determine if this instance has a menu item object set on it. | |
| hasParentMenuItem () | |
| Determine if this instance has a parent menu item object set on it. | |
| setDepth ($depth) | |
| Set the depth of this item. | |
| setMenu (P4Cms_Menu $menu=null) | |
| Set a menu on this instance. | |
| setMenuItem (Zend_Navigation_Page $menuItem=null) | |
| Set a menu item on this instance. | |
| setParentMenuItem (Zend_Navigation_Page $menuItem=null) | |
| Set a new parent menu item on this instance or null. | |
Protected Attributes | |
| $_menu = null | |
| $_menuItem = null | |
| $_parentMenuItem = null | |
Static Protected Attributes | |
| static | $_fields |
| static | $_idField = 'id' |
This model is used to normalize P4Cms_Menu and Zend_Navigation_Page classes into a unifom model allowing them to be listed together.
Please note a number of the fields in this model are read only: id, menuId, menuItemId, label
All of these are derived from the assiciated Menu and, optionally, Menu Item.
| P4Cms_Menu_Mixed::getDepth | ( | ) |
Returns the depth of this item in the heigharchy.
It is intended all Menu's will be a depth of 0 and all Menu Items will be a depth of >= 1. In practice implementors could violate this intent.
{
return $this->_getValue('depth');
}
| P4Cms_Menu_Mixed::getId | ( | ) |
Get the id of this record.
Extends parent to dynamically generate the ID based on the Menu and Menu Item.
This is a read only field calculated off of the menu and menu item.
Reimplemented from P4Cms_Model.
{
if (!$this->hasMenu() || !$this->getMenuId()) {
return null;
}
if (!$this->hasMenuItem()) {
return $this->getMenuId();
}
return $this->getMenuId() . '/' . $this->getMenuItemId();
}
| P4Cms_Menu_Mixed::getLabel | ( | ) |
Return the label for this model.
If a menu item has been set the label is returned from that. Otherwise, we fall back to the menu's name and lastly empty string.
This is a read only field calculated off of the menu item or menu.
{
if ($this->hasMenuItem()) {
return $this->getMenuItem()->getLabel();
}
if ($this->hasMenu()) {
return $this->getMenu()->getLabel();
}
return '';
}
| P4Cms_Menu_Mixed::getMenu | ( | ) |
Return the menu associated with this instance.
{
return $this->_menu;
}
| P4Cms_Menu_Mixed::getMenuId | ( | ) |
| P4Cms_Menu_Mixed::getMenuItem | ( | ) |
Return the menu item associated with this instance.
{
return $this->_menuItem;
}
| P4Cms_Menu_Mixed::getMenuItemId | ( | ) |
Returns the ID off of the menu item if one has been set.
Safe to call even if no menu item has been set.
This is a read only field calculated off of the menu item.
{
if (!$this->hasMenuItem()) {
return null;
}
return $this->getMenuItem()->uuid;
}
| P4Cms_Menu_Mixed::getNextMenuItem | ( | ) |
Returns the nexdt menu item that lives at the same level as this models menu item.
For non-menu item mixed models or when no next item exists null is returned.
{
$container = $this->getParentContainer();
if (!$container || !$this->hasMenuItem()) {
return null;
}
foreach ($container as $page) {
if ($page->uuid == $this->getMenuItem()->uuid) {
break;
}
}
$container->next();
if (!$container->valid()) {
return null;
}
$next = $container->current();
$mixed = new static;
$mixed->setMenu($this->getMenu())
->setParentMenuItem($this->getParentMenuItem())
->setMenuItem($next);
return $mixed;
}
| P4Cms_Menu_Mixed::getParentContainer | ( | ) |
Return the parent container for this menu item be it another page or a menu.
Falls back to returning null for non-menu items or items where parent cannot be determined.
{
if ($this->hasParentMenuItem()) {
return $this->getParentMenuItem();
}
if ($this->hasMenu()) {
return $this->getMenu()->getContainer();
}
return null;
}
| P4Cms_Menu_Mixed::getParentId | ( | ) |
Return the parent P4Cms_Menu_Mixed id if any.
This is a read only field calculated off of the parent menu item, menu item and menu.
{
if ($this->hasParentMenuItem() && $this->hasMenu()) {
return $this->getMenuId() . '/' . $this->getParentMenuItem()->uuid;
}
if ($this->hasMenu() && $this->hasMenuItem()) {
return $this->getMenuId();
}
return null;
}
| P4Cms_Menu_Mixed::getParentMenuItem | ( | ) |
The Zend_Navigation_Page based object which is our parent or null.
{
return $this->_parentMenuItem;
}
| P4Cms_Menu_Mixed::getPreviousMenuItem | ( | ) |
Returns the previous menu item that lives at the same level as this models menu item.
For non-menu item mixed models or when no previous item exists null is returned.
{
$container = $this->getParentContainer();
if (!$container || !$this->hasMenuItem()) {
return null;
}
$previous = null;
foreach ($container as $page) {
if ($page->uuid == $this->getMenuItem()->uuid) {
break;
}
$previous = $page;
}
if (!$previous) {
return null;
}
$mixed = new static;
$mixed->setMenu($this->getMenu())
->setParentMenuItem($this->getParentMenuItem())
->setMenuItem($previous);
return $mixed;
}
| P4Cms_Menu_Mixed::getType | ( | ) |
Retrieve the identifier for this menu or menu item type.
The class name is used to id the type of each entry.
{
if ($this->hasMenuItem()) {
return get_class($this->getMenuItem());
} else if ($this->hasMenu()) {
return get_class($this->getMenu());
}
return null;
}
| P4Cms_Menu_Mixed::hasMenu | ( | ) |
Determine if this instance has a menu object set on it.
{
return $this->_menu !== null;
}
| P4Cms_Menu_Mixed::hasMenuItem | ( | ) |
Determine if this instance has a menu item object set on it.
{
return $this->_menuItem !== null;
}
| P4Cms_Menu_Mixed::hasParentMenuItem | ( | ) |
Determine if this instance has a parent menu item object set on it.
{
return $this->_parentMenuItem !== null;
}
| P4Cms_Menu_Mixed::setDepth | ( | $ | depth | ) |
Set the depth of this item.
See getDepth for more details.
| int | $depth | The depth to use |
{
if (!is_int($depth)) {
throw new InvalidArgumentException('Depth must be an int');
}
return $this->_setValue('depth', $depth);
}
| P4Cms_Menu_Mixed::setMenu | ( | P4Cms_Menu $ | menu = null | ) |
Set a menu on this instance.
| P4Cms_Menu | null | $menu | A menu or null. |
{
$this->_menu = $menu;
return $this;
}
| P4Cms_Menu_Mixed::setMenuItem | ( | Zend_Navigation_Page $ | menuItem = null | ) |
Set a menu item on this instance.
| Zend_Navigation_Page | null | $menuItem | A menu item or null. |
{
$this->_menuItem = $menuItem;
}
| P4Cms_Menu_Mixed::setParentMenuItem | ( | Zend_Navigation_Page $ | menuItem = null | ) |
Set a new parent menu item on this instance or null.
| Zend_Navigation_Page | null | $menuItem | The parent menu item or null |
{
$this->_parentMenuItem = $menuItem;
return $this;
}
P4Cms_Menu_Mixed::$_fields [static, protected] |
Reimplemented from P4Cms_Model.
P4Cms_Menu_Mixed::$_idField = 'id' [static, protected] |
Reimplemented from P4Cms_Model.
P4Cms_Menu_Mixed::$_menu = null [protected] |
P4Cms_Menu_Mixed::$_menuItem = null [protected] |
P4Cms_Menu_Mixed::$_parentMenuItem = null [protected] |