Back to Toolbar class

Method __call

public \Joomla\CMS\Toolbar\ToolbarButton
__call
(mixed $name, mixed $args)
Magic method proxy.
Parameters
  • string $name The method name.
  • array $args The method arguments.
Returns
  • \Joomla\CMS\Toolbar\ToolbarButton
Since
  • 4.0.0
-
  • \Exception
Class: Toolbar
Project: Joomla

Method __call - Source code

/**
 * Magic method proxy.
 *
 * @param   string  $name  The method name.
 * @param   array   $args  The method arguments.
 *
 * @return  ToolbarButton
 *
 * @throws  \Exception
 *
 * @since   4.0.0
 */
public function __call($name, $args)
{
    if (strtolower(substr($name, -6)) === 'button') {
        $type = substr($name, 0, -6);
        $button = $this->factory->createButton($this, $type);
        $button->name($args[0] ?? '')->text($args[1] ?? '')->task($args[2] ?? '');
        return $this->appendButton($button);
    }
    throw new \BadMethodCallException(sprintf('Method %s() not found in class: %s', $name, static::class));
}