Back to Toolbar class

Method __construct

public
__construct
(mixed $name = 'toolbar', \Joomla\CMS\Toolbar\ToolbarFactoryInterface $factory = null)
Constructor
Parameters
  • string $name The toolbar name.
  • \Joomla\CMS\Toolbar\ToolbarFactoryInterface $factory The toolbar factory.
Since
  • 1.5
Class: Toolbar
Project: Joomla

Method __construct - Source code

/**
 * Constructor
 *
 * @param   string                   $name     The toolbar name.
 * @param   ToolbarFactoryInterface  $factory  The toolbar factory.
 *
 * @since   1.5
 */
public function __construct($name = 'toolbar', ToolbarFactoryInterface $factory = null)
{
    $this->_name = $name;
    // At 5.0, require the factory to be injected
    if (!$factory) {
        @trigger_error(sprintf('As of Joomla! 5.0, a %1$s must be provided to a %2$s object when creating it.', ToolbarFactoryInterface::class, \get_class($this)), E_USER_DEPRECATED);
        $factory = new ContainerAwareToolbarFactory();
        $factory->setContainer(Factory::getContainer());
    }
    $this->setFactory($factory);
    // Set base path to find buttons.
    $this->_buttonPath[] = __DIR__ . '/Button';
}