Back to AbstractMenu class

Method __construct

public
__construct
(mixed $options = array())
Class constructor
Parameters
  • array $options An array of configuration options.
Since
  • 1.5
Class: AbstractMenu
Project: Joomla

Method __construct - Source code

/**
 * Class constructor
 *
 * @param   array  $options  An array of configuration options.
 *
 * @since   1.5
 */
public function __construct($options = array())
{
    /**
     * It is preferred NOT to inject and store the user when constructing the menu object,
     * at least for the Menu object used by Joomla.
     * The menu object can be built very early in the request, from an onAfterInitialise event
     * but the user can be updated later (by the Remember me plugin for instance). As the stored
     * user object is not updated, the menu will render incorrectly, not complying with
     * menu items access levels.
     *
     * @see https://github.com/joomla/joomla-cms/issues/11541
     */
    $this->storedUser = isset($options['user']) && $options['user'] instanceof User ? $options['user'] : null;
}