Back to Toolbar class

Method addButtonPath

public void
addButtonPath
(mixed $path)
Add a directory where Toolbar should search for button types in LIFO order.
Parameters
  • mixed $path Directory or directories to search.
Returns
  • void
Since
  • 1.5
Deprecated
  • 5.0
Class: Toolbar
Project: Joomla

Method addButtonPath - Source code

/**
 * Add a directory where Toolbar should search for button types in LIFO order.
 *
 * You may either pass a string or an array of directories.
 *
 * Toolbar will be searching for an element type in the same order you
 * added them. If the parameter type cannot be found in the custom folders,
 * it will look in libraries/joomla/html/toolbar/button.
 *
 * @param   mixed  $path  Directory or directories to search.
 *
 * @return  void
 *
 * @since       1.5
 * @deprecated  5.0  ToolbarButton classes should be autoloaded
 */
public function addButtonPath($path)
{
    @trigger_error(sprintf('Registering lookup paths for toolbar buttons is deprecated and will be removed in Joomla 5.0.' . ' %1$s objects should be autoloaded or a custom %2$s implementation supporting path lookups provided.', ToolbarButton::class, ToolbarFactoryInterface::class), E_USER_DEPRECATED);
    // Loop through the path directories.
    foreach ((array) $path as $dir) {
        // No surrounding spaces allowed!
        $dir = trim($dir);
        // Add trailing separators as needed.
        if (substr($dir, -1) !== DIRECTORY_SEPARATOR) {
            // Directory
            $dir .= DIRECTORY_SEPARATOR;
        }
        // Add to the top of the search dirs.
        array_unshift($this->_buttonPath, $dir);
    }
}