public \Joomla\CMS\Menu\MenuItem|\Joomla\CMS\Menu\MenuItem[]
getItems
(mixed $attributes, mixed $values, mixed $firstonly = false)
/**
* Gets menu items by attribute
*
* @param string $attributes The field name
* @param string $values The value of the field
* @param boolean $firstonly If true, only returns the first item found
*
* @return MenuItem|MenuItem[] An array of menu item objects or a single object if the $firstonly parameter is true
*
* @since 1.6
*/
public function getItems($attributes, $values, $firstonly = false)
{
$attributes = (array) $attributes;
$values = (array) $values;
if ($this->app->isClient('site')) {
// Filter by language if not set
if (($key = array_search('language', $attributes)) === false) {
if (Multilanguage::isEnabled()) {
$attributes[] = 'language';
$values[] = array(Factory::getLanguage()->getTag(), '*');
}
} elseif ($values[$key] === null) {
unset($attributes[$key], $values[$key]);
}
// Filter by access level if not set
if (($key = array_search('access', $attributes)) === false) {
$attributes[] = 'access';
$values[] = $this->user->getAuthorisedViewLevels();
} elseif ($values[$key] === null) {
unset($attributes[$key], $values[$key]);
}
}
// Reset arrays or we get a notice if some values were unset
$attributes = array_values($attributes);
$values = array_values($values);
return parent::getItems($attributes, $values, $firstonly);
}