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
315
Merge Requests
315
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
cd74c624
Commit
cd74c624
authored
Oct 03, 2013
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2091691
by tim.plunkett: Convert test non-form page callbacks to routes and controllers.
parent
2867e5ba
Changes
56
Hide whitespace changes
Inline
Side-by-side
Showing
56 changed files
with
1542 additions
and
710 deletions
+1542
-710
core/includes/menu.inc
core/includes/menu.inc
+191
-185
core/lib/Drupal/Core/Controller/HtmlPageController.php
core/lib/Drupal/Core/Controller/HtmlPageController.php
+3
-1
core/modules/block/custom_block/custom_block.module
core/modules/block/custom_block/custom_block.module
+4
-4
core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module
.../tests/modules/custom_block_test/custom_block_test.module
+1
-4
core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml
...s/modules/custom_block_test/custom_block_test.routing.yml
+6
-0
core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php
...s/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php
+1
-1
core/modules/content_translation/content_translation.local_tasks.yml
...s/content_translation/content_translation.local_tasks.yml
+4
-0
core/modules/content_translation/lib/Drupal/content_translation/Plugin/ContentTranslationLocalTasks.php
...ntent_translation/Plugin/ContentTranslationLocalTasks.php
+41
-0
core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php
...lation/Plugin/Derivative/ContentTranslationLocalTasks.php
+92
-0
core/modules/datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
.../datetime/lib/Drupal/datetime/Tests/DatetimeFieldTest.php
+3
-3
core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php
+1
-1
core/modules/field/lib/Drupal/field/Tests/FormTest.php
core/modules/field/lib/Drupal/field/Tests/FormTest.php
+14
-14
core/modules/field/lib/Drupal/field/Tests/TranslationWebTest.php
...dules/field/lib/Drupal/field/Tests/TranslationWebTest.php
+1
-1
core/modules/forum/forum.module
core/modules/forum/forum.module
+2
-2
core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php
+5
-5
core/modules/node/node.module
core/modules/node/node.module
+3
-2
core/modules/number/lib/Drupal/number/Tests/NumberFieldTest.php
...odules/number/lib/Drupal/number/Tests/NumberFieldTest.php
+1
-1
core/modules/options/lib/Drupal/options/Tests/OptionsSelectDynamicValuesTest.php
...b/Drupal/options/Tests/OptionsSelectDynamicValuesTest.php
+1
-1
core/modules/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
...s/options/lib/Drupal/options/Tests/OptionsWidgetsTest.php
+26
-26
core/modules/system/lib/Drupal/system/Tests/Entity/EntityFormTest.php
.../system/lib/Drupal/system/Tests/Entity/EntityFormTest.php
+2
-2
core/modules/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
...es/system/lib/Drupal/system/Tests/Menu/MenuRouterTest.php
+0
-51
core/modules/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
...s/system/lib/Drupal/system/Tests/Module/ModuleApiTest.php
+0
-13
core/modules/system/system.api.php
core/modules/system/system.api.php
+6
-12
core/modules/system/tests/modules/ajax_test/ajax_test.module
core/modules/system/tests/modules/ajax_test/ajax_test.module
+11
-25
core/modules/system/tests/modules/ajax_test/ajax_test.routing.yml
...ules/system/tests/modules/ajax_test/ajax_test.routing.yml
+36
-1
core/modules/system/tests/modules/ajax_test/lib/Drupal/ajax_test/Controller/AjaxTestController.php
...st/lib/Drupal/ajax_test/Controller/AjaxTestController.php
+59
-0
core/modules/system/tests/modules/database_test/database_test.module
...s/system/tests/modules/database_test/database_test.module
+10
-20
core/modules/system/tests/modules/database_test/database_test.routing.yml
...tem/tests/modules/database_test/database_test.routing.yml
+34
-0
core/modules/system/tests/modules/database_test/lib/Drupal/database_test/Controller/DatabaseTestController.php
...rupal/database_test/Controller/DatabaseTestController.php
+50
-0
core/modules/system/tests/modules/entity_test/entity_test.module
...dules/system/tests/modules/entity_test/entity_test.module
+12
-11
core/modules/system/tests/modules/entity_test/entity_test.services.yml
...system/tests/modules/entity_test/entity_test.services.yml
+5
-0
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Controller/EntityTestController.php
...ib/Drupal/entity_test/Controller/EntityTestController.php
+31
-0
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php
..._test/lib/Drupal/entity_test/EntityTestFormController.php
+1
-1
core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php
...y_test/lib/Drupal/entity_test/Routing/RouteSubscriber.php
+56
-0
core/modules/system/tests/modules/form_test/form_test.module
core/modules/system/tests/modules/form_test/form_test.module
+4
-20
core/modules/system/tests/modules/form_test/form_test.routing.yml
...ules/system/tests/modules/form_test/form_test.routing.yml
+17
-0
core/modules/system/tests/modules/form_test/lib/Drupal/form_test/Controller/FormTestController.php
...st/lib/Drupal/form_test/Controller/FormTestController.php
+14
-0
core/modules/system/tests/modules/menu_test/lib/Drupal/menu_test/Controller/MenuTestController.php
...st/lib/Drupal/menu_test/Controller/MenuTestController.php
+43
-0
core/modules/system/tests/modules/menu_test/menu_test.local_tasks.yml
.../system/tests/modules/menu_test/menu_test.local_tasks.yml
+19
-0
core/modules/system/tests/modules/menu_test/menu_test.module
core/modules/system/tests/modules/menu_test/menu_test.module
+79
-169
core/modules/system/tests/modules/menu_test/menu_test.routing.yml
...ules/system/tests/modules/menu_test/menu_test.routing.yml
+377
-0
core/modules/system/tests/modules/module_test/lib/Drupal/module_test/Controller/ModuleTestController.php
...ib/Drupal/module_test/Controller/ModuleTestController.php
+36
-0
core/modules/system/tests/modules/module_test/module_test.module
...dules/system/tests/modules/module_test/module_test.module
+9
-22
core/modules/system/tests/modules/module_test/module_test.routing.yml
.../system/tests/modules/module_test/module_test.routing.yml
+23
-0
core/modules/system/tests/modules/system_test/lib/Drupal/system_test/Controller/SystemTestController.php
...ib/Drupal/system_test/Controller/SystemTestController.php
+69
-0
core/modules/system/tests/modules/system_test/system_test.module
...dules/system/tests/modules/system_test/system_test.module
+12
-85
core/modules/system/tests/modules/system_test/system_test.routing.yml
.../system/tests/modules/system_test/system_test.routing.yml
+68
-0
core/modules/system/tests/modules/test_page_test/lib/Drupal/test_page_test/Controller/TestPageTestController.php
...upal/test_page_test/Controller/TestPageTestController.php
+22
-0
core/modules/system/tests/modules/test_page_test/test_page_test.module
...system/tests/modules/test_page_test/test_page_test.module
+6
-6
core/modules/system/tests/modules/test_page_test/test_page_test.routing.yml
...m/tests/modules/test_page_test/test_page_test.routing.yml
+8
-0
core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
...Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
+1
-1
core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
...ules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php
+1
-1
core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php
+3
-3
core/modules/update/tests/modules/update_test/lib/Drupal/update_test/Controller/UpdateTestController.php
...ib/Drupal/update_test/Controller/UpdateTestController.php
+7
-0
core/modules/update/tests/modules/update_test/update_test.module
...dules/update/tests/modules/update_test/update_test.module
+2
-16
core/modules/update/tests/modules/update_test/update_test.routing.yml
.../update/tests/modules/update_test/update_test.routing.yml
+9
-0
No files found.
core/includes/menu.inc
View file @
cd74c624
...
...
@@ -1942,10 +1942,10 @@ function menu_navigation_links($menu_name, $level = 0) {
/**
* Collects the local tasks (tabs), action links, and the root path.
*
* @param $level
* @param
int
$level
* The level of tasks you ask for. Primary tasks are 0, secondary are 1.
*
* @return
* @return
array
* An array containing
* - tabs: Local tasks for the requested level.
* - actions: Action links for the requested level.
...
...
@@ -1965,11 +1965,6 @@ function menu_local_tasks($level = 0) {
);
if
(
!
isset
(
$data
))
{
$data
=
array
();
// Set defaults in case there are no actions or tabs.
$actions
=
$empty
[
'actions'
];
$tabs
=
array
();
// Look for route-based tabs.
$data
[
'tabs'
]
=
array
();
$data
[
'actions'
]
=
array
();
...
...
@@ -1983,202 +1978,30 @@ function menu_local_tasks($level = 0) {
}
}
// @todo Remove
the code below once the old menu router system got removed
.
// @todo Remove
when all local tasks/actions are converted to plugins
.
$router_item
=
menu_get_item
();
// If this router item points to its parent, start from the parents to
// compute tabs and actions.
if
(
$router_item
&&
(
$router_item
[
'type'
]
&
MENU_LINKS_TO_PARENT
))
{
$router_item
=
menu_get_item
(
$router_item
[
'tab_parent_href'
]);
}
// If we failed to fetch a router item or the current user doesn't have
// access to it, don't bother computing the tabs.
if
(
!
$router_item
||
!
$router_item
[
'access'
]
)
{
if
(
(
!
$route_name
&&
!
$router_item
)
||
(
$router_item
&&
!
$router_item
[
'access'
])
)
{
return
$empty
;
}
// @todo remove all code using {menu_router} and anything using MENU_*
// constants when all local actions and local tasks are converted to
// plugins. The remaining code should just invoke those managers plus do the
// invocations of hook_menu_local_tasks() and hook_menu_local_tasks_alter().
// Get all tabs (also known as local tasks) and the root page.
$result
=
db_select
(
'menu_router'
,
NULL
,
array
(
'fetch'
=>
PDO
::
FETCH_ASSOC
))
->
fields
(
'menu_router'
)
->
condition
(
'tab_root'
,
$router_item
[
'tab_root'
])
->
condition
(
'context'
,
MENU_CONTEXT_INLINE
,
'<>'
)
->
orderBy
(
'weight'
)
->
orderBy
(
'title'
)
->
execute
();
$map
=
$router_item
[
'original_map'
];
$children
=
array
();
$tasks
=
array
();
$root_path
=
$router_item
[
'path'
];
foreach
(
$result
as
$item
)
{
_menu_translate
(
$item
,
$map
,
TRUE
);
if
(
$item
[
'tab_parent'
])
{
// All tabs, but not the root page.
$children
[
$item
[
'tab_parent'
]][
$item
[
'path'
]]
=
$item
;
}
// Store the translated item for later use.
$tasks
[
$item
[
'path'
]]
=
$item
;
}
// Find all tabs below the current path.
$path
=
$router_item
[
'path'
];
// Tab parenting may skip levels, so the number of parts in the path may not
// equal the depth. Thus we use the $depth counter (offset by 1000 for ksort).
$depth
=
1001
;
$actions
=
array
();
while
(
isset
(
$children
[
$path
]))
{
$tabs_current
=
array
();
$actions_current
=
array
();
$next_path
=
''
;
$tab_count
=
0
;
$action_count
=
0
;
foreach
(
$children
[
$path
]
as
$item
)
{
// Local tasks can be normal items too, so bitmask with
// MENU_IS_LOCAL_TASK before checking.
if
(
!
(
$item
[
'type'
]
&
MENU_IS_LOCAL_TASK
))
{
// This item is not a tab, skip it.
continue
;
}
if
(
$item
[
'access'
])
{
$link
=
$item
;
// The default task is always active. As tabs can be normal items
// too, so bitmask with MENU_LINKS_TO_PARENT before checking.
if
((
$item
[
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
)
{
// Find the first parent which is not a default local task or action.
for
(
$p
=
$item
[
'tab_parent'
];
(
$tasks
[
$p
][
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
;
$p
=
$tasks
[
$p
][
'tab_parent'
]);
// Use the path of the parent instead.
$link
[
'href'
]
=
$tasks
[
$p
][
'href'
];
// Mark the link as active, if the current path happens to be the
// path of the default local task itself (i.e., instead of its
// tab_parent_href or tab_root_href). Normally, links for default
// local tasks link to their parent, but the path of default local
// tasks can still be accessed directly, in which case this link
// would not be marked as active, since l() only compares the href
// with current_path().
if
(
$link
[
'href'
]
!=
current_path
())
{
$link
[
'localized_options'
][
'attributes'
][
'class'
][]
=
'active'
;
}
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#active'
=>
TRUE
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$next_path
=
$item
[
'path'
];
$tab_count
++
;
}
else
{
// Actions can be normal items too, so bitmask with
// MENU_IS_LOCAL_ACTION before checking.
if
((
$item
[
'type'
]
&
MENU_IS_LOCAL_ACTION
)
==
MENU_IS_LOCAL_ACTION
)
{
// The item is an action, display it as such.
$actions_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_action'
,
'#link'
=>
$link
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$action_count
++
;
}
else
{
// Otherwise, it's a normal tab.
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$tab_count
++
;
}
}
}
}
$path
=
$next_path
;
$tabs
[
$depth
]
=
$tabs_current
;
$actions
=
array_merge
(
$actions
,
$actions_current
);
$depth
++
;
}
$data
[
'actions'
]
=
$actions
;
// Find all tabs at the same level or above the current one.
$parent
=
$router_item
[
'tab_parent'
];
$path
=
$router_item
[
'path'
];
$current
=
$router_item
;
$depth
=
1000
;
while
(
isset
(
$children
[
$parent
]))
{
$tabs_current
=
array
();
$next_path
=
''
;
$next_parent
=
''
;
$count
=
0
;
foreach
(
$children
[
$parent
]
as
$item
)
{
// Skip local actions.
if
(
$item
[
'type'
]
&
MENU_IS_LOCAL_ACTION
)
{
continue
;
}
if
(
$item
[
'access'
])
{
$count
++
;
$link
=
$item
;
// Local tasks can be normal items too, so bitmask with
// MENU_LINKS_TO_PARENT before checking.
if
((
$item
[
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
)
{
// Find the first parent which is not a default local task.
for
(
$p
=
$item
[
'tab_parent'
];
(
$tasks
[
$p
][
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
;
$p
=
$tasks
[
$p
][
'tab_parent'
]);
// Use the path of the parent instead.
$link
[
'href'
]
=
$tasks
[
$p
][
'href'
];
if
(
$item
[
'path'
]
==
$router_item
[
'path'
])
{
$root_path
=
$tasks
[
$p
][
'path'
];
}
}
// We check for the active tab.
if
(
$item
[
'path'
]
==
$path
)
{
// Mark the link as active, if the current path is a (second-level)
// local task of a default local task. Since this default local task
// links to its parent, l() will not mark it as active, as it only
// compares the link's href to current_path().
if
(
$link
[
'href'
]
!=
current_path
())
{
$link
[
'localized_options'
][
'attributes'
][
'class'
][]
=
'active'
;
}
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#active'
=>
TRUE
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$next_path
=
$item
[
'tab_parent'
];
if
(
isset
(
$tasks
[
$next_path
]))
{
$next_parent
=
$tasks
[
$next_path
][
'tab_parent'
];
}
}
else
{
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
}
}
}
$path
=
$next_path
;
$parent
=
$next_parent
;
$tabs
[
$depth
]
=
$tabs_current
;
$depth
--
;
if
(
$router_item
)
{
_menu_get_legacy_tasks
(
$router_item
,
$data
,
$root_path
);
}
// Sort by depth.
ksort
(
$tabs
);
// Remove the depth, we are interested only in their relative placement.
$tabs
=
array_values
(
$tabs
);
$data
[
'tabs'
]
+=
$tabs
;
// Allow modules to dynamically add further tasks.
$module_handler
=
\
Drupal
::
moduleHandler
();
foreach
(
$module_handler
->
getImplementations
(
'menu_local_tasks'
)
as
$module
)
{
$function
=
$module
.
'_menu_local_tasks'
;
$function
(
$data
,
$route
r_item
,
$root_path
);
$function
(
$data
,
$route
_name
);
}
// Allow modules to alter local tasks.
$module_handler
->
alter
(
'menu_local_tasks'
,
$data
,
$route
r_item
,
$root_path
);
$module_handler
->
alter
(
'menu_local_tasks'
,
$data
,
$route
_name
);
}
if
(
isset
(
$data
[
'tabs'
][
$level
]))
{
...
...
@@ -2194,6 +2017,189 @@ function menu_local_tasks($level = 0) {
return
$empty
;
}
/**
* Finds legacy local tasks/actions.
*
* @param array $router_item
* The current router item.
* @param array $data
* An associative array of local tasks/actions.
* @param string $root_path
*
* @deprecated Remove once all local tasks/actions are converted to plugins.
*/
function
_menu_get_legacy_tasks
(
$router_item
,
&
$data
,
&
$root_path
)
{
// Get all tabs (also known as local tasks) and the root page.
$result
=
db_select
(
'menu_router'
,
NULL
,
array
(
'fetch'
=>
PDO
::
FETCH_ASSOC
))
->
fields
(
'menu_router'
)
->
condition
(
'tab_root'
,
$router_item
[
'tab_root'
])
->
condition
(
'context'
,
MENU_CONTEXT_INLINE
,
'<>'
)
->
orderBy
(
'weight'
)
->
orderBy
(
'title'
)
->
execute
();
$map
=
$router_item
[
'original_map'
];
$children
=
array
();
$tasks
=
array
();
$root_path
=
$router_item
[
'path'
];
foreach
(
$result
as
$item
)
{
_menu_translate
(
$item
,
$map
,
TRUE
);
if
(
$item
[
'tab_parent'
])
{
// All tabs, but not the root page.
$children
[
$item
[
'tab_parent'
]][
$item
[
'path'
]]
=
$item
;
}
// Store the translated item for later use.
$tasks
[
$item
[
'path'
]]
=
$item
;
}
// Find all tabs below the current path.
$path
=
$router_item
[
'path'
];
// Tab parenting may skip levels, so the number of parts in the path may not
// equal the depth. Thus we use the $depth counter (offset by 1000 for ksort).
$depth
=
1001
;
$tabs
=
array
();
$actions
=
array
();
while
(
isset
(
$children
[
$path
]))
{
$tabs_current
=
array
();
$actions_current
=
array
();
$next_path
=
''
;
$tab_count
=
0
;
$action_count
=
0
;
foreach
(
$children
[
$path
]
as
$item
)
{
// Local tasks can be normal items too, so bitmask with
// MENU_IS_LOCAL_TASK before checking.
if
(
!
(
$item
[
'type'
]
&
MENU_IS_LOCAL_TASK
))
{
// This item is not a tab, skip it.
continue
;
}
if
(
$item
[
'access'
])
{
$link
=
$item
;
// The default task is always active. As tabs can be normal items
// too, so bitmask with MENU_LINKS_TO_PARENT before checking.
if
((
$item
[
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
)
{
// Find the first parent which is not a default local task or action.
for
(
$p
=
$item
[
'tab_parent'
];
(
$tasks
[
$p
][
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
;
$p
=
$tasks
[
$p
][
'tab_parent'
]);
// Use the path of the parent instead.
$link
[
'href'
]
=
$tasks
[
$p
][
'href'
];
// Mark the link as active, if the current path happens to be the
// path of the default local task itself (i.e., instead of its
// tab_parent_href or tab_root_href). Normally, links for default
// local tasks link to their parent, but the path of default local
// tasks can still be accessed directly, in which case this link
// would not be marked as active, since l() only compares the href
// with current_path().
if
(
$link
[
'href'
]
!=
current_path
())
{
$link
[
'localized_options'
][
'attributes'
][
'class'
][]
=
'active'
;
}
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#active'
=>
TRUE
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$next_path
=
$item
[
'path'
];
$tab_count
++
;
}
else
{
// Actions can be normal items too, so bitmask with
// MENU_IS_LOCAL_ACTION before checking.
if
((
$item
[
'type'
]
&
MENU_IS_LOCAL_ACTION
)
==
MENU_IS_LOCAL_ACTION
)
{
// The item is an action, display it as such.
$actions_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_action'
,
'#link'
=>
$link
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$action_count
++
;
}
else
{
// Otherwise, it's a normal tab.
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$tab_count
++
;
}
}
}
}
$path
=
$next_path
;
$tabs
[
$depth
]
=
$tabs_current
;
$actions
=
array_merge
(
$actions
,
$actions_current
);
$depth
++
;
}
$data
[
'actions'
]
=
$actions
;
// Find all tabs at the same level or above the current one.
$parent
=
$router_item
[
'tab_parent'
];
$path
=
$router_item
[
'path'
];
$current
=
$router_item
;
$depth
=
1000
;
while
(
isset
(
$children
[
$parent
]))
{
$tabs_current
=
array
();
$next_path
=
''
;
$next_parent
=
''
;
$count
=
0
;
foreach
(
$children
[
$parent
]
as
$item
)
{
// Skip local actions.
if
(
$item
[
'type'
]
&
MENU_IS_LOCAL_ACTION
)
{
continue
;
}
if
(
$item
[
'access'
])
{
$count
++
;
$link
=
$item
;
// Local tasks can be normal items too, so bitmask with
// MENU_LINKS_TO_PARENT before checking.
if
((
$item
[
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
)
{
// Find the first parent which is not a default local task.
for
(
$p
=
$item
[
'tab_parent'
];
(
$tasks
[
$p
][
'type'
]
&
MENU_LINKS_TO_PARENT
)
==
MENU_LINKS_TO_PARENT
;
$p
=
$tasks
[
$p
][
'tab_parent'
]);
// Use the path of the parent instead.
$link
[
'href'
]
=
$tasks
[
$p
][
'href'
];
if
(
$item
[
'path'
]
==
$router_item
[
'path'
])
{
$root_path
=
$tasks
[
$p
][
'path'
];
}
}
// We check for the active tab.
if
(
$item
[
'path'
]
==
$path
)
{
// Mark the link as active, if the current path is a (second-level)
// local task of a default local task. Since this default local task
// links to its parent, l() will not mark it as active, as it only
// compares the link's href to current_path().
if
(
$link
[
'href'
]
!=
current_path
())
{
$link
[
'localized_options'
][
'attributes'
][
'class'
][]
=
'active'
;
}
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#active'
=>
TRUE
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
$next_path
=
$item
[
'tab_parent'
];
if
(
isset
(
$tasks
[
$next_path
]))
{
$next_parent
=
$tasks
[
$next_path
][
'tab_parent'
];
}
}
else
{
$tabs_current
[
$link
[
'href'
]]
=
array
(
'#theme'
=>
'menu_local_task'
,
'#link'
=>
$link
,
'#weight'
=>
isset
(
$link
[
'weight'
])
?
$link
[
'weight'
]
:
NULL
,
);
}
}
}
$path
=
$next_path
;
$parent
=
$next_parent
;
$tabs
[
$depth
]
=
$tabs_current
;
$depth
--
;
}
// Sort by depth.
ksort
(
$tabs
);
// Remove the depth, we are interested only in their relative placement.
$tabs
=
array_values
(
$tabs
);
$data
[
'tabs'
]
+=
$tabs
;
}
/**
* Retrieves contextual links for a path based on registered local tasks.
*
...
...
core/lib/Drupal/Core/Controller/HtmlPageController.php
View file @
cd74c624
...
...
@@ -84,7 +84,9 @@ public function content(Request $request, $_content) {
}
if
(
!
is_array
(
$page_content
))
{
$page_content
=
array
(
'#markup'
=>
$page_content
,
'main'
=>
array
(
'#markup'
=>
$page_content
,
),
);
}
if
(
!
isset
(
$page_content
[
'#title'
]))
{
...
...
core/modules/block/custom_block/custom_block.module
View file @
cd74c624
...
...
@@ -30,8 +30,8 @@ function custom_block_help($path, $arg) {
/**
* Implements hook_menu_local_tasks().
*/
function
custom_block_menu_local_tasks
(
&
$data
,
$route
r_item
,
$root_path
)
{
if
(
$route
r_item
[
'route_name'
]
==
'custom_block.list'
)
{
function
custom_block_menu_local_tasks
(
&
$data
,
$route
_name
)
{
if
(
$route
_name
==
'custom_block.list'
)
{
// @todo Move to a LocalAction plugin when https://drupal.org/node/2045267
// allows local actions to work with query strings.
$item
=
menu_get_item
(
'block/add'
);
...
...
@@ -48,13 +48,13 @@ function custom_block_menu_local_tasks(&$data, $router_item, $root_path) {
$routes
=
array_map
(
function
(
$theme
)
{
return
"block.admin_display_
$theme
"
;
},
array_keys
(
list_themes
()));
if
(
in_array
(
$route
r_item
[
'route_name'
]
,
$routes
))
{
if
(
in_array
(
$route
_name
,
$routes
))
{
// @todo Move to a LocalAction plugin when https://drupal.org/node/2045267
// allows local actions to work with query strings.
$item
=
menu_get_item
(
'block/add'
);
if
(
$item
[
'access'
])
{
// Add a destination parameter.
$item
[
'localized_options'
][
'query'
][
'theme'
]
=
end
(
$router_item
[
'map'
]
);
$item
[
'localized_options'
][
'query'
][
'theme'
]
=
\
Drupal
::
request
()
->
attributes
->
get
(
'theme'
);
$data
[
'actions'
][
'block/add'
]
=
array
(
'#theme'
=>
'menu_local_action'
,
'#link'
=>
$item
,
...
...
core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module
View file @
cd74c624
...
...
@@ -92,10 +92,7 @@ function custom_block_test_menu() {
$items
[
'custom-block/%custom_block'
]
=
array
(
'title callback'
=>
'entity_page_label'
,
'title arguments'
=>
array
(
1
),
'page callback'
=>
'entity_view'
,
'page arguments'
=>
array
(
1
,
'default'
),
'access callback'
=>
'entity_page_access'
,
'access arguments'
=>
array
(
1
,
'view'
),
'route_name'
=>
'custom_block_test.custom_block_view'
,
);
return
$items
;
}
core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.routing.yml
0 → 100644
View file @
cd74c624
custom_block_test.custom_block_view
:
path
:
'
/custom-block/{custom_block}'
defaults
:
_entity_view
:
'
custom_block'
requirements
:
_entity_access
:
'
custom_block.view'
core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php
View file @
cd74c624
...
...
@@ -372,7 +372,7 @@ function testCommentFunctionality() {
$data
=
array
(
'bundle'
=>
'entity_test_render'
,
'name'
=>
$random_label
);
$new_entity
=
entity_create
(
'entity_test_render'
,
$data
);
$new_entity
->
save
();
$this
->
drupalGet
(
'entity_test_render/manage/'
.
$new_entity
->
id
()
.
'/edit'
);
$this
->
drupalGet
(
'entity_test_render/manage/'
.
$new_entity
->
id
());
$this
->
assertNoFieldChecked
(
'edit-field-foobar-0-status-1'
);
$this
->
assertFieldChecked
(
'edit-field-foobar-0-status-2'
);
$this
->
assertNoField
(
'edit-field-foobar-0-status-0'
);
...
...
core/modules/content_translation/content_translation.local_tasks.yml
0 → 100644
View file @
cd74c624
content_translation.local_tasks
:
derivative
:
'
Drupal\content_translation\Plugin\Derivative\ContentTranslationLocalTasks'
class
:
'
Drupal\content_translation\Plugin\ContentTranslationLocalTasks'
weight
:
100
core/modules/content_translation/lib/Drupal/content_translation/Plugin/ContentTranslationLocalTasks.php
0 → 100644
View file @
cd74c624
<?php
/**
* @file
* Contains \Drupal\content_translation\Plugin\ContentTranslationLocalTasks.
*/
namespace
Drupal\content_translation\Plugin
;
use
Drupal\Core\Menu\LocalTaskDefault
;
use
Symfony\Component\HttpFoundation\Request
;
/**
* Provides route parameter manipulation for content translation local tasks.
*/
class
ContentTranslationLocalTasks
extends
LocalTaskDefault
{
/**
* {@inheritdoc}
*/
public
function
getRouteParameters
(
Request
$request
)
{
$parameters
=
parent
::
getRouteParameters
(
$request
);
$entity_type
=
$this
->
pluginDefinition
[
'entity_type'
];
if
(
$raw_variables
=
$request
->
attributes
->
get
(
'_raw_variables'
))
{
// When the entity type is in the path, populate 'entity' for any dynamic
// local tasks.
if
(
$raw_variables
->
has
(
$entity_type
))
{
$entity
=
$raw_variables
->
get
(
$entity_type
);
$parameters
[
'entity'
]
=
$entity
;
}
// When 'entity' is in the path, populate the parameters with the value
// for the actual entity type.
elseif
(
$raw_variables
->
has
(
'entity'
))
{
$entity
=
$raw_variables
->
get
(
'entity'
);
$parameters
[
$entity_type
]
=
$entity
;
}
}
return
$parameters
;
}
}
core/modules/content_translation/lib/Drupal/content_translation/Plugin/Derivative/ContentTranslationLocalTasks.php
0 → 100644
View file @
cd74c624
<?php
/**
* @file
* Contains \Drupal\content_translation\Plugin\Derivative\ContentTranslationLocalTasks.
*/
namespace
Drupal\content_translation\Plugin\Derivative
;
use
Drupal\Component\Plugin\Derivative\DerivativeBase
;
use
Drupal\Core\Entity\EntityManager
;
use
Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface
;
use
Drupal\Core\Routing\RouteProviderInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Provides dynamic local tasks for content translation.
*/
class
ContentTranslationLocalTasks
extends
DerivativeBase
implements
ContainerDerivativeInterface
{
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManager
*/
protected
$entityManager
;
/**
* The route provider.
*
* @var \Drupal\Core\Routing\RouteProviderInterface
*/
protected
$routeProvider
;
<