diff --git a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php index 60748c8..3dbbb39 100644 --- a/core/lib/Drupal/Core/Entity/Annotation/EntityType.php +++ b/core/lib/Drupal/Core/Entity/Annotation/EntityType.php @@ -229,7 +229,7 @@ class EntityType extends Plugin { * * @var string (optional) */ - public $bundle_entity_type; + public $bundle_entity_type = 'bundle'; /** * Link templates using the URI template syntax. diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 2f0e03a..221d4ee 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -302,10 +302,7 @@ public function getAdminPath($entity_type, $bundle) { $entity_info = $this->getDefinition($entity_type); // Check for an entity type's admin base path. if (isset($entity_info['links']['admin-form'])) { - $route_parameters = array('bundle' => $bundle); - if (isset($entity_info['bundle_entity_type'])) { - $route_parameters[$entity_info['bundle_entity_type']] = $bundle; - } + $route_parameters[$entity_info['bundle_entity_type']] = $bundle; $admin_path = \Drupal::urlGenerator()->getPathFromRoute($entity_info['links']['admin-form'], $route_parameters); } @@ -317,11 +314,10 @@ public function getAdminPath($entity_type, $bundle) { */ public function getAdminRouteInfo($entity_type, $bundle) { $entity_info = $this->getDefinition($entity_type); - $bundle_arg = isset($entity_info['bundle_entity_type']) ? $entity_info['bundle_entity_type'] : 'bundle'; return array( 'route_name' => "field_ui.overview_$entity_type", 'route_parameters' => array( - $bundle_arg => $bundle, + $entity_info['bundle_entity_type'] => $bundle, ) ); } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php index 80e4855..f7cfd76 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php @@ -229,11 +229,11 @@ function testCommentFunctionality() { )); $this->drupalLogin($limited_user); // Test that default field exists. - $this->drupalGet('admin/structure/entity-test/manage/entity_test/fields'); + $this->drupalGet('entity_test/structure/entity_test/fields'); $this->assertText(t('Comment settings')); - $this->assertLinkByHref('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment'); + $this->assertLinkByHref('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); // Test widget hidden option is not visible when there's no comments. - $this->drupalGet('admin/structure/entity-test/manage/entity_test/entity-test/fields/entity_test.entity_test.comment'); + $this->drupalGet('entity_test/structure/entity_test/entity-test/fields/entity_test.entity_test.comment'); $this->assertNoField('edit-default-value-input-comment-und-0-status-0'); $this->drupalLogin($this->admin_user); @@ -343,20 +343,20 @@ function testCommentFunctionality() { 'administer entity_test content', )); $this->drupalLogin($limited_user); - $this->drupalGet('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment'); + $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-1'); $this->assertFieldChecked('edit-default-value-input-comment-0-status-2'); // Test comment option change in field settings. $edit = array('default_value_input[comment][0][status]' => COMMENT_CLOSED); $this->drupalPostForm(NULL, $edit, t('Save settings')); - $this->drupalGet('admin/structure/entity-test/manage/entity_test/fields/entity_test.entity_test.comment'); + $this->drupalGet('entity_test/structure/entity_test/fields/entity_test.entity_test.comment'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-0'); $this->assertFieldChecked('edit-default-value-input-comment-0-status-1'); $this->assertNoFieldChecked('edit-default-value-input-comment-0-status-2'); // Add a new comment field. - $this->drupalGet('admin/structure/entity-test/manage/entity_test/fields'); + $this->drupalGet('entity_test/structure/entity_test/fields'); $edit = array( 'fields[_add_new_field][label]' => 'Foobar', 'fields[_add_new_field][field_name]' => 'foobar', diff --git a/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php b/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php index ce4f1be..be497e4 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/ConfigFieldInstanceMapper.php @@ -23,13 +23,10 @@ class ConfigFieldInstanceMapper extends ConfigEntityMapper { */ public function getBaseRouteParameters() { $parameters = parent::getBaseRouteParameters(); - // @todo All core content entity path placeholders can be fully filled in - // with an additional {bundle} value in their paths, but a more - // predictable solution would be ideal. See - // https://drupal.org/node/2134871 + $base_entity_info = $this->entityManager->getDefinition($this->pluginDefinition['base_entity_type']); // @todo Field instances have no method to return the bundle the instance is // attached to. See https://drupal.org/node/2134861 - $parameters['bundle'] = $this->entity->bundle; + $parameters[$base_entity_info['bundle_entity_type']] = $this->entity->bundle; return $parameters; } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 8dc30ba..eefc199 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -247,7 +247,7 @@ function field_ui_entity_operation_alter(array &$operations, EntityInterface $en */ function field_ui_form_node_type_form_submit($form, &$form_state) { if ($form_state['triggering_element']['#parents'][0] === 'save_continue') { - $form_state['redirect_route'] = $this->entityManager->getAdminRouteInfo('node', $form_state['values']['type']); + $form_state['redirect_route'] = \Drupal::entityManager()->getAdminRouteInfo('node', $form_state['values']['type']); } } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php index ea00aab..8a7650f 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php @@ -207,10 +207,11 @@ public function delete(array &$form, array &$form_state) { $destination = drupal_get_destination(); $request->query->remove('destination'); } + $entity_info = $this->entityManager->getDefinition($this->instance->entity_type); $form_state['redirect_route'] = array( 'route_name' => 'field_ui.delete_' . $this->instance->entity_type, 'route_parameters' => array( - 'bundle' => $this->instance->bundle, + $entity_info['bundle_entity_type'] => $this->instance->bundle, 'field_instance' => $this->instance->id(), ), 'options' => array( diff --git a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php index 8114efd..aad6599 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/OverviewBase.php @@ -74,13 +74,16 @@ public static function create(ContainerInterface $container) { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state, $entity_type = NULL, $bundle = NULL) { - $entity_info = $this->entityManager->getDefinition($entity_type); + if (!isset($form_state['bundle'])) { + if (!$bundle) { + $entity_info = $this->entityManager->getDefinition($entity_type); + $bundle = $this->getRequest()->attributes->get('_raw_variables')->get($entity_info['bundle_entity_type']); + } + $form_state['bundle'] = $bundle; + } $this->entity_type = $entity_type; - if (!$bundle) { - $bundle = $this->getRequest()->attributes->get('_raw_variables')->get($entity_info['bundle_entity_type']); - } - $this->bundle = $bundle; + $this->bundle = $form_state['bundle']; $this->adminPath = $this->entityManager->getAdminPath($this->entity_type, $this->bundle); // When displaying the form, make sure the list of fields is up-to-date.