Group.php
00001 <?php
00012 class Dsao_Module_Menu_Group
00013 {
00017 protected $_label = null;
00018
00022 protected $_uriArray = null;
00023
00031 public function __construct($label = null, array $uriArray = array())
00032 {
00033
00034 if (null != $label)
00035 {
00036 $this->_label = 'menu_'.(string) $label;
00037 }
00038
00039
00040 $this->setFromArray($uriArray);
00041 }
00042
00048 public function __toString()
00049 {
00050 return $this->toString();
00051 }
00052
00059 public function addUri($uri)
00060 {
00061
00062 if ($uri instanceof Dsao_Uri_Http)
00063 {
00064 $this->_uriArray[$uri->toString(false)] = $uri;
00065 }
00066 else
00067 {
00068 $uri = (string) $uri;
00069
00070 $this->_uriArray[$uri] = new Dsao_Uri_Http($uri);
00071 }
00072
00073 return $this;
00074 }
00075
00081 public final function getLabel()
00082 {
00083 return $this->_label;
00084 }
00085
00092 public function removeUri($uri)
00093 {
00094 $uri = (string) $uri;
00095
00096
00097 if (isset($this->_uriArray[$uri]))
00098 {
00099 unset($this->_uriArray[$uri]);
00100 }
00101
00102 return $this;
00103 }
00104
00111 public function setFromArray(array $array = array())
00112 {
00113 $this->_uriArray = array();
00114
00115
00116 foreach ($array as $uri)
00117 {
00118 $this->addUri($uri);
00119 }
00120
00121 return $this;
00122 }
00123
00130 public function setLabel($label)
00131 {
00132 $this->_label = 'menu_'. (string) $label;
00133
00134 return $this;
00135 }
00136
00142 public function toArray()
00143 {
00144 return $this->_uriArray;
00145 }
00146
00152 public function toString()
00153 {
00154 return (string) $this->_label;
00155 }
00156 }