Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
f01ac2d4
Commit
f01ac2d4
authored
Dec 21, 2016
by
alexpott
Browse files
Issue
#2836381
by phenaproxima, Wim Leers: Seven's entity-add-list template omits link attributes
parent
69c23474
Changes
5
Hide whitespace changes
Inline
Side-by-side
core/modules/system/tests/modules/entity_test/src/Controller/EntityTestEntityController.php
0 → 100644
View file @
f01ac2d4
<?php
namespace
Drupal\entity_test\Controller
;
use
Drupal\Core\Entity\Controller\EntityController
;
use
Symfony\Component\HttpFoundation\Response
;
/**
* Controller for test entities based on the core EntityController.
*/
class
EntityTestEntityController
extends
EntityController
{
/**
* {@inheritdoc}
*/
public
function
addPage
(
$entity_type_id
)
{
$response
=
parent
::
addPage
(
$entity_type_id
);
if
(
$response
instanceof
Response
)
{
return
$response
;
}
foreach
(
$response
[
'#bundles'
]
as
$bundle
)
{
$bundle
[
'add_link'
]
->
getUrl
()
->
setOption
(
'attributes'
,
[
'class'
=>
[
'bundle-link'
],
]);
}
return
$response
;
}
}
core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php
View file @
f01ac2d4
...
...
@@ -21,7 +21,7 @@
* "delete" = "\Drupal\Core\Entity\EntityDeleteForm"
* },
* "route_provider" = {
* "html" = "Drupal\
Core\Entity
\Routing\
Default
HtmlRouteProvider",
* "html" = "Drupal\
entity_test
\Routing\HtmlRouteProvider",
* },
* },
* base_table = "entity_test_with_bundle",
...
...
core/modules/system/tests/modules/entity_test/src/Routing/HtmlRouteProvider.php
0 → 100644
View file @
f01ac2d4
<?php
namespace
Drupal\entity_test\Routing
;
use
Drupal\Core\Entity\EntityTypeInterface
;
use
Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
;
use
Drupal\entity_test
\
Controller\EntityTestEntityController
;
/**
* Route provider for test entities.
*/
class
HtmlRouteProvider
extends
DefaultHtmlRouteProvider
{
/**
* {@inheritdoc}
*/
protected
function
getAddPageRoute
(
EntityTypeInterface
$entity_type
)
{
return
parent
::
getAddPageRoute
(
$entity_type
)
->
setDefault
(
'_controller'
,
EntityTestEntityController
::
class
.
'::addPage'
)
->
setOption
(
'_admin_route'
,
TRUE
);
}
}
core/modules/system/tests/src/Functional/SevenBundleAddPageLinkAttributesTest.php
0 → 100644
View file @
f01ac2d4
<?php
namespace
Drupal\Tests\system\Functional
;
use
Drupal\entity_test
\
Entity\EntityTestBundle
;
use
Drupal\Tests\BrowserTestBase
;
/**
* Tests Seven's handling of link attributes on multi-bundle entity add page.
*
* @group system
*/
class
SevenBundleAddPageLinkAttributesTest
extends
BrowserTestBase
{
/**
* {@inheritdoc}
*/
public
static
$modules
=
[
'entity_test'
];
/**
* {@inheritdoc}
*/
protected
$profile
=
'standard'
;
/**
* Tests that Seven preserves attributes in multi-bundle entity add links.
*/
public
function
testSevenBundleAddPageLinkAttributes
()
{
$account
=
$this
->
drupalCreateUser
([
'administer entity_test_with_bundle content'
]);
$this
->
drupalLogin
(
$account
);
$this
->
config
(
'system.theme'
)
->
set
(
'default'
,
'seven'
)
->
save
();
for
(
$i
=
0
;
$i
<
2
;
$i
++
)
{
EntityTestBundle
::
create
([
'id'
=>
$this
->
randomMachineName
(),
'label'
=>
$this
->
randomString
(),
'description'
=>
$this
->
randomString
(),
])
->
save
();
}
$this
->
drupalGet
(
'/entity_test_with_bundle/add'
);
$this
->
assertSession
()
->
elementExists
(
'css'
,
'a.bundle-link'
);
}
}
core/themes/seven/templates/entity-add-list.html.twig
View file @
f01ac2d4
...
...
@@ -17,7 +17,7 @@
{%
if
bundles
is
not
empty
%}
<ul
class=
"admin-list"
>
{%
for
bundle
in
bundles
%}
<li
class=
"clearfix"
><a
href=
"
{{
bundle.add_link.url
}}
"
><span
class=
"label"
>
{{
bundle.label
}}
</span><div
class=
"description"
>
{{
bundle.description
}}
</div></a></li>
<li
class=
"clearfix"
><a
{{
create_attribute
(
bundle.add_link.url.options.attributes
)
}}
href=
"
{{
bundle.add_link.url
}}
"
><span
class=
"label"
>
{{
bundle.label
}}
</span><div
class=
"description"
>
{{
bundle.description
}}
</div></a></li>
{%
endfor
%}
</ul>
{%
elseif
add_bundle_message
is
not
empty
%}
...
...
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