Issue #1986888 by tim.plunkett, agentrickard: Fixed Field UI integration for entity types is brittle.

8.0.x
Alex Pott 2013-05-07 21:44:57 +01:00
parent 19e6c2c0ae
commit a371a7b58d
5 changed files with 109 additions and 0 deletions

View File

@ -49,6 +49,7 @@ class RouteSubscriber implements EventSubscriberInterface {
public function routes(RouteBuildEvent $event) {
$collection = $event->getRouteCollection();
foreach ($this->manager->getDefinitions() as $entity_type => $entity_info) {
$defaults = array();
if ($entity_info['fieldable'] && isset($entity_info['route_base_path'])) {
$path = $entity_info['route_base_path'];

View File

@ -0,0 +1,55 @@
<?php
/**
* @file
* Contains \Drupal\field_ui\Tests\FieldUIRouteTest.
*/
namespace Drupal\field_ui\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Tests the functionality of the Field UI route subscriber.
*/
class FieldUIRouteTest extends WebTestBase {
/**
* Modules to enable.
*/
public static $modules = array('field_ui_test', 'node');
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Field UI routes',
'description' => 'Tests the functionality of the Field UI route subscriber.',
'group' => 'Field UI',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
$this->drupalLogin($this->root_user);
}
/**
* Ensures that entity types with bundles do not break following entity types.
*/
public function testFieldUIRoutes() {
$this->drupalGet('field-ui-test-no-bundle/manage/fields');
$this->assertText('No fields are present yet.');
$this->drupalGet('admin/structure/types/manage/article/fields');
$this->assertTitle('Article | Drupal');
}
}

View File

@ -0,0 +1,10 @@
name: "Field UI tests"
type: module
description: "Support module for Field UI testing."
package: Testing
version: VERSION
core: 8.x
hidden: TRUE
dependencies:
- field_ui

View File

@ -0,0 +1,6 @@
<?php
/**
* @file
* Field UI test module.
*/

View File

@ -0,0 +1,37 @@
<?php
/**
* @file
* Contains \Drupal\field_ui_test\Plugin\Core\Entity\FieldUITestNoBundle.
*/
namespace Drupal\field_ui_test\Plugin\Core\Entity;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Entity\Annotation\EntityType;
use Drupal\Core\Annotation\Translation;
/**
* Defines the test Field UI class.
*
* @EntityType(
* id = "field_ui_test_no_bundle",
* label = @Translation("Test Field UI entity, no bundle"),
* module = "field_ui_test",
* controllers = {
* "storage" = "Drupal\Core\Entity\DatabaseStorageController"
* },
* fieldable = TRUE,
* route_base_path = "field-ui-test-no-bundle/manage"
* )
*/
class FieldUITestNoBundle extends Entity {
/**
* The entity ID.
*
* @var int
*/
public $id;
}