interface LocalTaskManagerInterface implements PluginManagerInterface (View source)

Manages discovery and instantiation of menu local task plugins.

This manager finds plugins that are rendered as local tasks (usually tabs). Derivatives are supported for modules that wish to generate multiple tabs on behalf of something else.

Methods

mixed
getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)

Gets a specific plugin definition.

array
getDefinitions()

Gets the definition of all plugins for this type.

bool
hasDefinition(string $plugin_id)

Indicates if a specific plugin definition exists.

object
createInstance(string $plugin_id, array $configuration = [])

Creates a pre-configured instance of a plugin.

object|false
getInstance(array $options)

Gets a preconfigured instance of a plugin.

string
getTitle(LocalTaskInterface $local_task)

Gets the title for a local task.

array
getLocalTasksForRoute(string $route_name)

Find all local tasks that appear on a named route.

array
getTasksBuild(string $current_route_name, RefinableCacheableDependencyInterface $cacheability)

Gets the render array for all local tasks.

array
getLocalTasks(string $route_name, int $level = 0)

Renders the local tasks (tabs) for the given route.

Details

mixed getDefinition(string $plugin_id, bool $exception_on_invalid = TRUE)

Gets a specific plugin definition.

Parameters

string $plugin_id

A plugin id.

bool $exception_on_invalid

(optional) If TRUE, an invalid plugin ID will throw an exception.

Return Value

mixed

A plugin definition, or NULL if the plugin ID is invalid and $exception_on_invalid is FALSE.

Exceptions

PluginNotFoundException

array getDefinitions()

Gets the definition of all plugins for this type.

Return Value

array

An array of plugin definitions (empty array if no definitions were found). Keys are plugin IDs.

See also

FilteredPluginManagerInterface::getFilteredDefinitions

bool hasDefinition(string $plugin_id)

Indicates if a specific plugin definition exists.

Parameters

string $plugin_id

A plugin ID.

Return Value

bool

TRUE if the definition exists, FALSE otherwise.

object createInstance(string $plugin_id, array $configuration = [])

Creates a pre-configured instance of a plugin.

Parameters

string $plugin_id

The ID of the plugin being instantiated.

array $configuration

An array of configuration relevant to the plugin instance.

Return Value

object

A fully configured plugin instance.

Exceptions

PluginException

object|false getInstance(array $options)

Gets a preconfigured instance of a plugin.

Parameters

array $options

An array of options that can be used to determine a suitable plugin to instantiate and how to configure it.

Return Value

object|false

A fully configured plugin instance. The interface of the plugin instance will depend on the plugin type. If no instance can be retrieved, FALSE will be returned.

string getTitle(LocalTaskInterface $local_task)

Gets the title for a local task.

Parameters

LocalTaskInterface $local_task

A local task plugin instance to get the title for.

Return Value

string

The localized title.

array getLocalTasksForRoute(string $route_name)

Find all local tasks that appear on a named route.

Parameters

string $route_name

The route for which to find local tasks.

Return Value

array

Returns an array of task levels. Each task level contains instances of local tasks (LocalTaskInterface) which appear on the tab route. The array keys are the depths and the values are arrays of plugin instances.

array getTasksBuild(string $current_route_name, RefinableCacheableDependencyInterface $cacheability)

Gets the render array for all local tasks.

Parameters

string $current_route_name

The route for which to make renderable local tasks.

RefinableCacheableDependencyInterface $cacheability

The cacheability metadata for the local tasks.

Return Value

array

A render array as expected by menu-local-tasks.html.twig.

array getLocalTasks(string $route_name, int $level = 0)

Renders the local tasks (tabs) for the given route.

Parameters

string $route_name

The route for which to make renderable local tasks.

int $level

The level of tasks you ask for. Primary tasks are 0, secondary are 1.

Return Value

array

An array containing

  • tabs: Local tasks render array for the requested level.
  • route_name: The route name for the current page used to collect the local tasks.

See also

hook_menu_local_tasks_alter()