Back to AbstractMenu class

Method setActive

public \Joomla\CMS\Menu\MenuItem|void
setActive
(mixed $id)
Set the default item by id
Parameters
  • int $id The item id
Returns
  • \Joomla\CMS\Menu\MenuItem|void The menu item representing the given ID if present or null otherwise
Since
  • 1.5
Class: AbstractMenu
Project: Joomla

Method setActive - Source code

/**
 * Set the default item by id
 *
 * @param   integer  $id  The item id
 *
 * @return  MenuItem|void  The menu item representing the given ID if present or null otherwise
 *
 * @since   1.5
 */
public function setActive($id)
{
    if (isset($this->getMenu()[$id])) {
        $this->active = $id;
        return $this->getMenu()[$id];
    }
}