Back to AbstractMenu class

Method getInstance

public static \Joomla\CMS\Menu\AbstractMenu
getInstance
(mixed $client, mixed $options = array())
Returns a Menu object
Parameters
  • string $client The name of the client
  • array $options An associative array of options
Returns
  • \Joomla\CMS\Menu\AbstractMenu A menu object.
Since
  • 1.5
Deprecated
  • 5.0
-
  • \Exception
Class: AbstractMenu
Project: Joomla

Method getInstance - Source code

/**
 * Returns a Menu object
 *
 * @param   string  $client   The name of the client
 * @param   array   $options  An associative array of options
 *
 * @return  AbstractMenu  A menu object.
 *
 * @since       1.5
 *
 * @throws      \Exception
 *
 * @deprecated  5.0 Use the MenuFactoryInterface from the container instead
 */
public static function getInstance($client, $options = array())
{
    if (!$client) {
        throw new \Exception(Text::sprintf('JLIB_APPLICATION_ERROR_MENU_LOAD', $client), 500);
    }
    if (empty(self::$instances[$client])) {
        self::$instances[$client] = Factory::getContainer()->get(MenuFactoryInterface::class)->createMenu($client, $options);
    }
    return self::$instances[$client];
}