diff -u b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php --- b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php +++ b/core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php @@ -23,7 +23,7 @@ * id = "field_instance_config", * label = @Translation("Field instance"), * controllers = { - * "list_builder" = "\Drupal\field_ui\FieldInstanceListBuilder", + * "list_builder" = "\Drupal\field_ui\FieldInstanceConfigListBuilder", * "storage" = "Drupal\field\FieldInstanceConfigStorage" * }, * config_prefix = "instance", reverted: --- b/core/modules/field_ui/lib/Drupal/field_ui/FieldInstanceListBuilder.php +++ /dev/null @@ -1,89 +0,0 @@ -getStorage($entity_type->id())); - $this->entityManager = $entity_manager; - } - - /** - * {@inheritdoc} - */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { - return new static($entity_type, $container->get('entity.manager')); - } - - /** - * {@inheritdoc} - */ - public function render() { - throw new \Exception('This class is only used for operations and not for building lists.'); - } - - /** - * {@inheritdoc} - */ - public function getDefaultOperations(EntityInterface $entity) { - /** @var \Drupal\field\FieldInstanceConfigInterface $entity */ - $operations = parent::getDefaultOperations($entity); - - $target_entity_type_bundle_entity_type_id = $this->entityManager->getDefinition($entity->getTargetEntityTypeId())->getBundleEntityType(); - $route_parameters = array( - $target_entity_type_bundle_entity_type_id => $entity->targetBundle(), - 'field_instance_config' => $entity->id(), - ); - $operations['edit'] = array( - 'title' => $this->t('Edit'), - 'route_name' => 'field_ui.instance_edit_' . $entity->getTargetEntityTypeId(), - 'route_parameters' => $route_parameters, - 'attributes' => array('title' => $this->t('Edit instance settings.')), - ); - $operations['field-settings'] = array( - 'title' => $this->t('Field settings'), - 'route_name' => 'field_ui.field_edit_' . $entity->getTargetEntityTypeId(), - 'route_parameters' => $route_parameters, - 'attributes' => array('title' => $this->t('Edit field settings.')), - ); - $operations['delete'] = array( - 'title' => $this->t('Delete'), - 'route_name' => 'field_ui.delete_' . $entity->getTargetEntityTypeId(), - 'route_parameters' => $route_parameters, - 'attributes' => array('title' => $this->t('Delete instance.')), - ); - - return $operations; - } - -} diff -u b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php --- b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityListBuilderTest.php @@ -121,9 +121,15 @@ $this->role->expects($this->any()) ->method('hasLinkTemplate') ->will($this->returnValue(TRUE)); + $url = $this->getMockBuilder('\Drupal\Core\Url') + ->disableOriginalConstructor() + ->getMock(); + $url->expects($this->any()) + ->method('toArray') + ->will($this->returnValue(array())); $this->role->expects($this->any()) ->method('urlInfo') - ->will($this->returnValue(array())); + ->will($this->returnValue($url)); $list = new EntityListBuilder($this->entityType, $this->roleStorage, $this->moduleHandler); $list->setTranslationManager($this->translationManager); only in patch2: unchanged: --- /dev/null +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldInstanceConfigListBuilder.php @@ -0,0 +1,92 @@ +getStorage($entity_type->id())); + $this->entityManager = $entity_manager; + } + + /** + * {@inheritdoc} + */ + public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { + return new static($entity_type, $container->get('entity.manager')); + } + + /** + * {@inheritdoc} + */ + public function render() { + // The actual field instance config overview is rendered by + // \Drupal\field_ui\FieldOverview, so we should not use this class to build + // lists. + throw new \Exception('This class is only used for operations and not for building lists.'); + } + + /** + * {@inheritdoc} + */ + public function getDefaultOperations(EntityInterface $entity) { + /** @var \Drupal\field\FieldInstanceConfigInterface $entity */ + $operations = parent::getDefaultOperations($entity); + + $target_entity_type_bundle_entity_type_id = $this->entityManager->getDefinition($entity->getTargetEntityTypeId())->getBundleEntityType(); + $route_parameters = array( + $target_entity_type_bundle_entity_type_id => $entity->targetBundle(), + 'field_instance_config' => $entity->id(), + ); + $operations['edit'] = array( + 'title' => $this->t('Edit'), + 'route_name' => 'field_ui.instance_edit_' . $entity->getTargetEntityTypeId(), + 'route_parameters' => $route_parameters, + 'attributes' => array('title' => $this->t('Edit instance settings.')), + ); + $operations['field-settings'] = array( + 'title' => $this->t('Field settings'), + 'route_name' => 'field_ui.field_edit_' . $entity->getTargetEntityTypeId(), + 'route_parameters' => $route_parameters, + 'attributes' => array('title' => $this->t('Edit field settings.')), + ); + $operations['delete'] = array( + 'title' => $this->t('Delete'), + 'route_name' => 'field_ui.delete_' . $entity->getTargetEntityTypeId(), + 'route_parameters' => $route_parameters, + 'attributes' => array('title' => $this->t('Delete instance.')), + ); + + return $operations; + } + +}