Commit 91c4c928 authored by alexpott's avatar alexpott

Revert "Issue #2836381 by phenaproxima, Wim Leers: Seven's entity-add-list...

Revert "Issue #2836381 by phenaproxima, Wim Leers: Seven's entity-add-list template omits link attributes"

This reverts commit f01ac2d4.
parent d2e8cbdc
<?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;
}
}
......@@ -21,7 +21,7 @@
* "delete" = "\Drupal\Core\Entity\EntityDeleteForm"
* },
* "route_provider" = {
* "html" = "Drupal\entity_test\Routing\HtmlRouteProvider",
* "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
* },
* },
* base_table = "entity_test_with_bundle",
......
<?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);
}
}
<?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');
}
}
......@@ -17,7 +17,7 @@
{% if bundles is not empty %}
<ul class="admin-list">
{% for bundle in bundles %}
<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>
<li class="clearfix"><a 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 %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment