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
220
Merge Requests
220
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
a078c238
Commit
a078c238
authored
Jun 02, 2013
by
catch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#1987114
by thedavidmeister: Allow l() to accept a renderable array for $text.
parent
81ed3ecb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
11 deletions
+13
-11
core/includes/common.inc
core/includes/common.inc
+4
-5
core/includes/theme.inc
core/includes/theme.inc
+2
-4
core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
...modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
+7
-2
No files found.
core/includes/common.inc
View file @
a078c238
...
...
@@ -1631,8 +1631,8 @@ function drupal_http_header_attributes(array $attributes = array()) {
* This keeps the context of the link title ('settings' in the example) for
* translators.
*
* @param string $text
* The
translated link text for the anchor tag
.
* @param string
|array
$text
* The
link text for the anchor tag as a translated string or render array
.
* @param string $path
* The internal path or external URL being linked to, such as "node/34" or
* "http://example.com/foo". After the url() function is called to construct
...
...
@@ -1665,10 +1665,9 @@ function drupal_http_header_attributes(array $attributes = array()) {
* @see theme_link()
*/
function
l
(
$text
,
$path
,
array
$options
=
array
())
{
// Build a variables array to keep the structure of the alter consistent with
// theme_link().
// Start building a structured representation of our link to be altered later.
$variables
=
array
(
'text'
=>
$text
,
'text'
=>
is_array
(
$text
)
?
drupal_render
(
$text
)
:
$text
,
'path'
=>
$path
,
'options'
=>
$options
,
);
...
...
core/includes/theme.inc
View file @
a078c238
...
...
@@ -1673,14 +1673,12 @@ function theme_status_messages($variables) {
*
* @param $variables
* An associative array containing the keys 'text', 'path', and 'options'.
* See the l() function for information about these variables. However, unlike
* 'text' in l(), both render arrays and strings are supported here.
* See the l() function for information about these variables.
*
* @see l()
*/
function
theme_link
(
$variables
)
{
$rendered_text
=
is_array
(
$variables
[
'text'
])
?
drupal_render
(
$variables
[
'text'
])
:
$variables
[
'text'
];
return
l
(
$rendered_text
,
$variables
[
'path'
],
$variables
[
'options'
]);
return
l
(
$variables
[
'text'
],
$variables
[
'path'
],
$variables
[
'options'
]);
}
/**
...
...
core/modules/system/lib/Drupal/system/Tests/Common/UrlTest.php
View file @
a078c238
...
...
@@ -134,12 +134,17 @@ function testLinkCustomClass() {
}
/**
* Tests that
theme_link() supports render arrays in 'text' parameter
.
* Tests that
link functions support render arrays as 'text'
.
*/
function
testLink
NestedRenderArrays
()
{
function
testLink
RenderArrayText
()
{
// Build a link with l() for reference.
$l
=
l
(
'foo'
,
'http://drupal.org'
);
// Test a renderable array passed to l().
$renderable_text
=
array
(
'#markup'
=>
'foo'
);
$l_renderable_text
=
l
(
$renderable_text
,
'http://drupal.org'
);
$this
->
assertEqual
(
$l_renderable_text
,
$l
);
// Test a themed link with plain text 'text'.
$theme_link_plain_array
=
array
(
'#theme'
=>
'link'
,
...
...
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