summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2017-05-22 17:56:43 +0100
committerAlex Pott2017-05-22 19:34:40 +0100
commita12c564dc9a778bda535ce05c2dbe0d99ea20481 (patch)
treed521c815cfd3c5b7f32c14ba32959ea8587fa307
parent7292b48754c93a3a5dcdf6ff4a7ff322fd35de92 (diff)
Issue #2836384 by chr.fritsch, phenaproxima, Munavijayalakshmi: Field UIs operations array is broken for entities with restricted access
-rw-r--r--core/modules/field_ui/src/FieldConfigListBuilder.php8
-rw-r--r--core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module9
-rw-r--r--core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php61
3 files changed, 76 insertions, 2 deletions
diff --git a/core/modules/field_ui/src/FieldConfigListBuilder.php b/core/modules/field_ui/src/FieldConfigListBuilder.php
index 7a6960e..cb720c3 100644
--- a/core/modules/field_ui/src/FieldConfigListBuilder.php
+++ b/core/modules/field_ui/src/FieldConfigListBuilder.php
@@ -161,6 +161,9 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
'title' => $this->t('Edit'),
'weight' => 10,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-edit-form"),
+ 'attributes' => [
+ 'title' => $this->t('Edit field settings.')
+ ],
];
}
if ($entity->access('delete') && $entity->hasLinkTemplate("{$entity->getTargetEntityTypeId()}-field-delete-form")) {
@@ -168,6 +171,9 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
'title' => $this->t('Delete'),
'weight' => 100,
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-field-delete-form"),
+ 'attributes' => [
+ 'title' => $this->t('Delete field.')
+ ],
];
}
@@ -177,8 +183,6 @@ class FieldConfigListBuilder extends ConfigEntityListBuilder {
'attributes' => ['title' => $this->t('Edit storage settings.')],
'url' => $entity->urlInfo("{$entity->getTargetEntityTypeId()}-storage-edit-form"),
];
- $operations['edit']['attributes']['title'] = $this->t('Edit field settings.');
- $operations['delete']['attributes']['title'] = $this->t('Delete field.');
return $operations;
}
diff --git a/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module
index 95234f1..21b2272 100644
--- a/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module
+++ b/core/modules/field_ui/tests/modules/field_ui_test/field_ui_test.module
@@ -5,8 +5,17 @@
* Field UI test module.
*/
+use Drupal\Core\Access\AccessResult;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
+use Drupal\Core\Field\FieldConfigInterface;
+
+/**
+ * Implements hook_ENTITY_TYPE_access().
+ */
+function field_ui_test_field_config_access(FieldConfigInterface $field) {
+ return AccessResult::forbiddenIf($field->getName() == 'highlander');
+}
/**
* Implements hook_form_FORM_BASE_ID_alter().
diff --git a/core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php b/core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php
new file mode 100644
index 0000000..1c21b06
--- /dev/null
+++ b/core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Drupal\Tests\field_ui\Functional;
+
+use Drupal\Tests\BrowserTestBase;
+
+/**
+ * Tests the Manage Display page of a fieldable entity type.
+ *
+ * @group field_ui
+ */
+class ManageFieldsTest extends BrowserTestBase {
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'field_ui',
+ 'field_ui_test',
+ 'node',
+ 'text',
+ ];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp() {
+ parent::setUp();
+ $account = $this->drupalCreateUser(['administer node fields']);
+ $this->drupalLogin($account);
+ $this->config('system.logging')
+ ->set('error_level', ERROR_REPORTING_DISPLAY_ALL)
+ ->save();
+ }
+
+ public function testFieldDropButtonOperations() {
+ $node_type = $this->drupalCreateContentType();
+
+ /** @var \Drupal\field\FieldStorageConfigInterface $storage */
+ $storage = $this->container->get('entity_type.manager')
+ ->getStorage('field_storage_config')
+ ->create([
+ 'type' => 'string',
+ 'field_name' => 'highlander',
+ 'entity_type' => 'node',
+ ]);
+ $storage->save();
+
+ $this->container->get('entity_type.manager')
+ ->getStorage('field_config')
+ ->create([
+ 'field_storage' => $storage,
+ 'bundle' => $node_type->id(),
+ ])
+ ->save();
+
+ $this->drupalGet('/admin/structure/types/manage/' . $node_type->id() . '/fields');
+
+ }
+
+}