[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\Menu; 11 12 use Joomla\CMS\Tree\NodeInterface; 13 use Joomla\CMS\Tree\NodeTrait; 14 use Joomla\Registry\Registry; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('JPATH_PLATFORM') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Object representing a menu item 22 * 23 * @since 3.7.0 24 */ 25 class MenuItem implements NodeInterface 26 { 27 use NodeTrait; 28 29 /** 30 * Primary key 31 * 32 * @var integer 33 * @since 3.7.0 34 */ 35 public $id; 36 37 /** 38 * The type of menu this item belongs to 39 * 40 * @var integer 41 * @since 3.7.0 42 */ 43 public $menutype; 44 45 /** 46 * The display title of the menu item 47 * 48 * @var string 49 * @since 3.7.0 50 */ 51 public $title; 52 53 /** 54 * The SEF alias of the menu item 55 * 56 * @var string 57 * @since 3.7.0 58 */ 59 public $alias; 60 61 /** 62 * A note associated with the menu item 63 * 64 * @var string 65 * @since 3.7.0 66 */ 67 public $note; 68 69 /** 70 * The computed path of the menu item based on the alias field, this is populated from the `path` field in the `#__menu` table 71 * 72 * @var string 73 * @since 3.7.0 74 */ 75 public $route; 76 77 /** 78 * The actual link the menu item refers to 79 * 80 * @var string 81 * @since 3.7.0 82 */ 83 public $link; 84 85 /** 86 * The type of link 87 * 88 * @var string 89 * @since 3.7.0 90 */ 91 public $type; 92 93 /** 94 * The relative level in the tree 95 * 96 * @var integer 97 * @since 3.7.0 98 */ 99 public $level; 100 101 /** 102 * The assigned language for this item 103 * 104 * @var string 105 * @since 3.7.0 106 */ 107 public $language; 108 109 /** 110 * The click behaviour of the link 111 * 112 * @var integer 113 * @since 3.7.0 114 */ 115 public $browserNav; 116 117 /** 118 * The access level required to view the menu item 119 * 120 * @var integer 121 * @since 3.7.0 122 */ 123 public $access; 124 125 /** 126 * The menu item parameters 127 * 128 * @var string|Registry 129 * @since 3.7.0 130 * @note This field is protected to require reading this field to proxy through the getter to convert the params to a Registry instance 131 */ 132 protected $params; 133 134 /** 135 * Indicates if this menu item is the home or default page 136 * 137 * @var integer 138 * @since 3.7.0 139 */ 140 public $home; 141 142 /** 143 * The image of the menu item 144 * 145 * @var string 146 * @since 3.7.0 147 */ 148 public $img; 149 150 /** 151 * The optional template style applied to this menu item 152 * 153 * @var integer 154 * @since 3.7.0 155 */ 156 public $template_style_id; 157 158 /** 159 * The extension ID of the component this menu item is for 160 * 161 * @var integer 162 * @since 3.7.0 163 */ 164 public $component_id; 165 166 /** 167 * The parent menu item in the menu tree 168 * 169 * @var integer 170 * @since 3.7.0 171 */ 172 public $parent_id; 173 174 /** 175 * The name of the component this menu item is for 176 * 177 * @var string 178 * @since 3.7.0 179 */ 180 public $component; 181 182 /** 183 * The tree of parent menu items 184 * 185 * @var array 186 * @since 3.7.0 187 */ 188 public $tree = array(); 189 190 /** 191 * An array of the query string values for this item 192 * 193 * @var array 194 * @since 3.7.0 195 */ 196 public $query = array(); 197 198 /** 199 * Class constructor 200 * 201 * @param array $data The menu item data to load 202 * 203 * @since 3.7.0 204 */ 205 public function __construct($data = array()) 206 { 207 foreach ((array) $data as $key => $value) { 208 $this->$key = $value; 209 } 210 } 211 212 /** 213 * Returns the menu item parameters 214 * 215 * @return Registry 216 * 217 * @since 3.7.0 218 */ 219 public function getParams() 220 { 221 if (!($this->params instanceof Registry)) { 222 try { 223 $this->params = new Registry($this->params); 224 } catch (\RuntimeException $e) { 225 /* 226 * Joomla shipped with a broken sample json string for 4 years which caused fatals with new 227 * error checks. So for now we catch the exception here - but one day we should remove it and require 228 * valid JSON. 229 */ 230 $this->params = new Registry(); 231 } 232 } 233 234 return $this->params; 235 } 236 237 /** 238 * Sets the menu item parameters 239 * 240 * @param Registry|string $params The data to be stored as the parameters 241 * 242 * @return void 243 * 244 * @since 3.7.0 245 */ 246 public function setParams($params) 247 { 248 $this->params = $params; 249 } 250 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |