Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
304
Merge Requests
304
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
cd240fd2
Commit
cd240fd2
authored
Aug 25, 2014
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2312077
by dawehner: Provide interfaces for the local task and action manager.
parent
a4b6e3b1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
54 deletions
+111
-54
core/lib/Drupal/Core/Menu/LocalActionManager.php
core/lib/Drupal/Core/Menu/LocalActionManager.php
+4
-24
core/lib/Drupal/Core/Menu/LocalActionManagerInterface.php
core/lib/Drupal/Core/Menu/LocalActionManagerInterface.php
+46
-0
core/lib/Drupal/Core/Menu/LocalTaskManager.php
core/lib/Drupal/Core/Menu/LocalTaskManager.php
+5
-30
core/lib/Drupal/Core/Menu/LocalTaskManagerInterface.php
core/lib/Drupal/Core/Menu/LocalTaskManagerInterface.php
+56
-0
No files found.
core/lib/Drupal/Core/Menu/LocalActionManager.php
View file @
cd240fd2
...
...
@@ -21,14 +21,9 @@
use
Drupal\Core\Session\AccountInterface
;
/**
* Manages discovery and instantiation of menu local action plugins.
*
* Menu local actions are links that lead to actions like "add new". The plugin
* format allows them (if needed) to dynamically generate a title or the path
* they link to. The annotation on the plugin provides the default title,
* and the list of routes where the action should be rendered.
* Provides the default local action manager using YML as primary definition.
*/
class
LocalActionManager
extends
DefaultPluginManager
{
class
LocalActionManager
extends
DefaultPluginManager
implements
LocalActionManagerInterface
{
/**
* Provides some default values for all local action plugins.
...
...
@@ -133,16 +128,7 @@ public function __construct(ControllerResolverInterface $controller_resolver, Re
}
/**
* Gets the title for a local action.
*
* @param \Drupal\Core\Menu\LocalActionInterface $local_action
* An object to get the title from.
*
* @return string
* The title (already localized).
*
* @throws \BadMethodCallException
* If the plugin does not implement the getTitle() method.
* {@inheritdoc}
*/
public
function
getTitle
(
LocalActionInterface
$local_action
)
{
$controller
=
array
(
$local_action
,
'getTitle'
);
...
...
@@ -151,13 +137,7 @@ public function getTitle(LocalActionInterface $local_action) {
}
/**
* Finds all local actions that appear on a named route.
*
* @param string $route_appears
* The route name for which to find local actions.
*
* @return array
* An array of link render arrays.
* {@inheritdoc}
*/
public
function
getActionsForRoute
(
$route_appears
)
{
if
(
!
isset
(
$this
->
instances
[
$route_appears
]))
{
...
...
core/lib/Drupal/Core/Menu/LocalActionManagerInterface.php
0 → 100644
View file @
cd240fd2
<?php
/**
* @file
* Contains \Drupal\Core\Menu\LocalActionManagerInterface.
*/
namespace
Drupal\Core\Menu
;
use
Drupal\Component\Plugin\PluginManagerInterface
;
/**
* Manages discovery and instantiation of menu local action plugins.
*
* Menu local actions are links that lead to actions like "add new". The plugin
* format allows them (if needed) to dynamically generate a title or the path
* they link to. The annotation on the plugin provides the default title,
* and the list of routes where the action should be rendered.
*/
interface
LocalActionManagerInterface
extends
PluginManagerInterface
{
/**
* Gets the title for a local action.
*
* @param \Drupal\Core\Menu\LocalActionInterface $local_action
* An object to get the title from.
*
* @return string
* The title (already localized).
*
* @throws \BadMethodCallException
* If the plugin does not implement the getTitle() method.
*/
public
function
getTitle
(
LocalActionInterface
$local_action
);
/**
* Finds all local actions that appear on a named route.
*
* @param string $route_appears
* The route name for which to find local actions.
*
* @return array
* An array of link render arrays.
*/
public
function
getActionsForRoute
(
$route_appears
);
}
core/lib/Drupal/Core/Menu/LocalTaskManager.php
View file @
cd240fd2
...
...
@@ -24,13 +24,9 @@
use
Symfony\Component\HttpFoundation\RequestStack
;
/**
* 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.
* Provides the default local task manager using YML as primary definition.
*/
class
LocalTaskManager
extends
DefaultPluginManager
{
class
LocalTaskManager
extends
DefaultPluginManager
implements
LocalTaskManagerInterface
{
/**
* {@inheritdoc}
...
...
@@ -154,13 +150,7 @@ public function processDefinition(&$definition, $plugin_id) {
}
/**
* Gets the title for a local task.
*
* @param \Drupal\Core\Menu\LocalTaskInterface $local_task
* A local task plugin instance to get the title for.
*
* @return string
* The localized title.
* {@inheritdoc}
*/
public
function
getTitle
(
LocalTaskInterface
$local_task
)
{
$controller
=
array
(
$local_task
,
'getTitle'
);
...
...
@@ -187,16 +177,7 @@ public function getDefinitions() {
}
/**
* Find all local tasks that appear on a named route.
*
* @param string $route_name
* The route for which to find local tasks.
*
* @return 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.
* {@inheritdoc}
*/
public
function
getLocalTasksForRoute
(
$route_name
)
{
if
(
!
isset
(
$this
->
instances
[
$route_name
]))
{
...
...
@@ -290,13 +271,7 @@ public function getLocalTasksForRoute($route_name) {
}
/**
* Gets the render array for all local tasks.
*
* @param string $current_route_name
* The route for which to make renderable local tasks.
*
* @return array
* A render array as expected by theme_menu_local_tasks.
* {@inheritdoc}
*/
public
function
getTasksBuild
(
$current_route_name
)
{
$tree
=
$this
->
getLocalTasksForRoute
(
$current_route_name
);
...
...
core/lib/Drupal/Core/Menu/LocalTaskManagerInterface.php
0 → 100644
View file @
cd240fd2
<?php
/**
* @file
* Contains \Drupal\Core\Menu\LocalTaskManagerInterface.
*/
namespace
Drupal\Core\Menu
;
use
Drupal\Component\Plugin\PluginManagerInterface
;
/**
* 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.
*/
interface
LocalTaskManagerInterface
extends
PluginManagerInterface
{
/**
* Gets the title for a local task.
*
* @param \Drupal\Core\Menu\LocalTaskInterface $local_task
* A local task plugin instance to get the title for.
*
* @return string
* The localized title.
*/
public
function
getTitle
(
LocalTaskInterface
$local_task
);
/**
* Find all local tasks that appear on a named route.
*
* @param string $route_name
* The route for which to find local tasks.
*
* @return 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.
*/
public
function
getLocalTasksForRoute
(
$route_name
);
/**
* Gets the render array for all local tasks.
*
* @param string $current_route_name
* The route for which to make renderable local tasks.
*
* @return array
* A render array as expected by theme_menu_local_tasks.
*/
public
function
getTasksBuild
(
$current_route_name
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment