summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2017-02-24 15:33:42 (GMT)
committerxjm2017-02-24 15:33:42 (GMT)
commitd85cf06daaae8ba47ddef522011ab7b691bddc87 (patch)
treeed5af37aa0df075ca89db6f020f9c8e5afbd574d
parent55dc41fe1001654bc813a3572dae985249b24eb1 (diff)
Issue #2267621 by tameeshb, Wim Leers, himanshu-dixit, mpdonadio, xjm, Alan Evans, tim.plunkett: Deprecate and rename EditEntityFieldAccessCheck now that the module is named Quick Edit
-rw-r--r--core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php6
-rw-r--r--core/modules/quickedit/quickedit.services.yml2
-rw-r--r--core/modules/quickedit/src/Access/EditEntityFieldAccessCheck.php56
-rw-r--r--core/modules/quickedit/src/Access/EditEntityFieldAccessCheckInterface.php19
-rw-r--r--core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheck.php62
-rw-r--r--core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheckInterface.php25
-rw-r--r--core/modules/quickedit/src/MetadataGenerator.php8
-rw-r--r--core/modules/quickedit/tests/modules/src/MockEditEntityFieldAccessCheck.php14
-rw-r--r--core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php20
-rw-r--r--core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php6
-rw-r--r--core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php (renamed from core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php)12
11 files changed, 130 insertions, 100 deletions
diff --git a/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php b/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php
index d62cb68..c04fe2d 100644
--- a/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php
+++ b/core/modules/editor/tests/src/Kernel/QuickEditIntegrationTest.php
@@ -9,7 +9,7 @@ use Drupal\editor\Entity\Editor;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\quickedit\MetadataGenerator;
use Drupal\Tests\quickedit\Kernel\QuickEditTestBase;
-use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
+use Drupal\quickedit_test\MockQuickEditEntityFieldAccessCheck;
use Drupal\editor\EditorController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
@@ -52,7 +52,7 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
/**
* The access checker object to be used by the metadata generator object.
*
- * @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
+ * @var \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface
*/
protected $accessChecker;
@@ -165,7 +165,7 @@ class QuickEditIntegrationTest extends QuickEditTestBase {
*/
public function testMetadata() {
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
- $this->accessChecker = new MockEditEntityFieldAccessCheck();
+ $this->accessChecker = new MockQuickEditEntityFieldAccessCheck();
$this->editorSelector = $this->container->get('quickedit.editor.selector');
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
diff --git a/core/modules/quickedit/quickedit.services.yml b/core/modules/quickedit/quickedit.services.yml
index 692ba2f..3d7d934 100644
--- a/core/modules/quickedit/quickedit.services.yml
+++ b/core/modules/quickedit/quickedit.services.yml
@@ -3,7 +3,7 @@ services:
class: Drupal\quickedit\Plugin\InPlaceEditorManager
parent: default_plugin_manager
access_check.quickedit.entity_field:
- class: Drupal\quickedit\Access\EditEntityFieldAccessCheck
+ class: Drupal\quickedit\Access\QuickEditEntityFieldAccessCheck
tags:
- { name: access_check, applies_to: _access_quickedit_entity_field }
quickedit.editor.selector:
diff --git a/core/modules/quickedit/src/Access/EditEntityFieldAccessCheck.php b/core/modules/quickedit/src/Access/EditEntityFieldAccessCheck.php
index 7b38838..f937908 100644
--- a/core/modules/quickedit/src/Access/EditEntityFieldAccessCheck.php
+++ b/core/modules/quickedit/src/Access/EditEntityFieldAccessCheck.php
@@ -2,61 +2,9 @@
namespace Drupal\quickedit\Access;
-use Drupal\Core\Access\AccessResult;
-use Drupal\Core\Routing\Access\AccessInterface;
-use Drupal\Core\Session\AccountInterface;
-use Drupal\Core\Entity\EntityInterface;
-
/**
- * Access check for editing entity fields.
+ * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0.
*/
-class EditEntityFieldAccessCheck implements AccessInterface, EditEntityFieldAccessCheckInterface {
-
- /**
- * Checks Quick Edit access to the field.
- *
- * @param \Drupal\Core\Entity\EntityInterface $entity
- * The entity containing the field.
- * @param string $field_name
- * The field name.
- * @param string $langcode
- * The langcode.
- * @param \Drupal\Core\Session\AccountInterface $account
- * The currently logged in account.
- *
- * @return \Drupal\Core\Access\AccessResultInterface
- * The access result.
- *
- * @todo Use the $account argument: https://www.drupal.org/node/2266809.
- */
- public function access(EntityInterface $entity, $field_name, $langcode, AccountInterface $account) {
- if (!$this->validateRequestAttributes($entity, $field_name, $langcode)) {
- return AccessResult::forbidden();
- }
-
- return $this->accessEditEntityField($entity, $field_name);
- }
-
- /**
- * {@inheritdoc}
- */
- public function accessEditEntityField(EntityInterface $entity, $field_name) {
- return $entity->access('update', NULL, TRUE)->andIf($entity->get($field_name)->access('edit', NULL, TRUE));
- }
-
- /**
- * Validates request attributes.
- */
- protected function validateRequestAttributes(EntityInterface $entity, $field_name, $langcode) {
- // Validate the field name and language.
- if (!$field_name || !$entity->hasField($field_name)) {
- return FALSE;
- }
- if (!$langcode || !$entity->hasTranslation($langcode)) {
- return FALSE;
- }
-
- return TRUE;
- }
+class EditEntityFieldAccessCheck extends QuickEditEntityFieldAccessCheck {
}
diff --git a/core/modules/quickedit/src/Access/EditEntityFieldAccessCheckInterface.php b/core/modules/quickedit/src/Access/EditEntityFieldAccessCheckInterface.php
index c7f14e2..cfdb32d 100644
--- a/core/modules/quickedit/src/Access/EditEntityFieldAccessCheckInterface.php
+++ b/core/modules/quickedit/src/Access/EditEntityFieldAccessCheckInterface.php
@@ -2,24 +2,9 @@
namespace Drupal\quickedit\Access;
-use Drupal\Core\Entity\EntityInterface;
-
/**
- * Access check for editing entity fields.
+ * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0.
*/
-interface EditEntityFieldAccessCheckInterface {
-
- /**
- * Checks access to edit the requested field of the requested entity.
- *
- * @param \Drupal\Core\Entity\EntityInterface $entity
- * The entity.
- * @param string $field_name
- * The field name.
- *
- * @return \Drupal\Core\Access\AccessResultInterface
- * The access result.
- */
- public function accessEditEntityField(EntityInterface $entity, $field_name);
+interface EditEntityFieldAccessCheckInterface extends QuickEditEntityFieldAccessCheckInterface {
}
diff --git a/core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheck.php b/core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheck.php
new file mode 100644
index 0000000..5404b04
--- /dev/null
+++ b/core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheck.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Drupal\quickedit\Access;
+
+use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Routing\Access\AccessInterface;
+use Drupal\Core\Session\AccountInterface;
+use Drupal\Core\Entity\EntityInterface;
+
+/**
+ * Access check for in-place editing entity fields.
+ */
+class QuickEditEntityFieldAccessCheck implements AccessInterface, QuickEditEntityFieldAccessCheckInterface {
+
+ /**
+ * Checks Quick Edit access to the field.
+ *
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ * The entity containing the field.
+ * @param string $field_name
+ * The field name.
+ * @param string $langcode
+ * The langcode.
+ * @param \Drupal\Core\Session\AccountInterface $account
+ * The currently logged in account.
+ *
+ * @return \Drupal\Core\Access\AccessResultInterface
+ * The access result.
+ *
+ * @todo Use the $account argument: https://www.drupal.org/node/2266809.
+ */
+ public function access(EntityInterface $entity, $field_name, $langcode, AccountInterface $account) {
+ if (!$this->validateRequestAttributes($entity, $field_name, $langcode)) {
+ return AccessResult::forbidden();
+ }
+
+ return $this->accessEditEntityField($entity, $field_name);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function accessEditEntityField(EntityInterface $entity, $field_name) {
+ return $entity->access('update', NULL, TRUE)->andIf($entity->get($field_name)->access('edit', NULL, TRUE));
+ }
+
+ /**
+ * Validates request attributes.
+ */
+ protected function validateRequestAttributes(EntityInterface $entity, $field_name, $langcode) {
+ // Validate the field name and language.
+ if (!$field_name || !$entity->hasField($field_name)) {
+ return FALSE;
+ }
+ if (!$langcode || !$entity->hasTranslation($langcode)) {
+ return FALSE;
+ }
+
+ return TRUE;
+ }
+
+}
diff --git a/core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheckInterface.php b/core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheckInterface.php
new file mode 100644
index 0000000..1428b48
--- /dev/null
+++ b/core/modules/quickedit/src/Access/QuickEditEntityFieldAccessCheckInterface.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Drupal\quickedit\Access;
+
+use Drupal\Core\Entity\EntityInterface;
+
+/**
+ * Access check for in-place editing entity fields.
+ */
+interface QuickEditEntityFieldAccessCheckInterface {
+
+ /**
+ * Checks access to edit the requested field of the requested entity.
+ *
+ * @param \Drupal\Core\Entity\EntityInterface $entity
+ * The entity.
+ * @param string $field_name
+ * The field name.
+ *
+ * @return \Drupal\Core\Access\AccessResultInterface
+ * The access result.
+ */
+ public function accessEditEntityField(EntityInterface $entity, $field_name);
+
+}
diff --git a/core/modules/quickedit/src/MetadataGenerator.php b/core/modules/quickedit/src/MetadataGenerator.php
index a22bf65..06f0daf 100644
--- a/core/modules/quickedit/src/MetadataGenerator.php
+++ b/core/modules/quickedit/src/MetadataGenerator.php
@@ -5,7 +5,7 @@ namespace Drupal\quickedit;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldItemListInterface;
-use Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface;
+use Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
/**
@@ -16,7 +16,7 @@ class MetadataGenerator implements MetadataGeneratorInterface {
/**
* An object that checks if a user has access to edit a given entity field.
*
- * @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
+ * @var \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface
*/
protected $accessChecker;
@@ -37,14 +37,14 @@ class MetadataGenerator implements MetadataGeneratorInterface {
/**
* Constructs a new MetadataGenerator.
*
- * @param \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface $access_checker
+ * @param \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface $access_checker
* An object that checks if a user has access to edit a given field.
* @param \Drupal\quickedit\EditorSelectorInterface $editor_selector
* An object that determines which editor to attach to a given field.
* @param \Drupal\Component\Plugin\PluginManagerInterface $editor_manager
* The manager for editor plugins.
*/
- public function __construct(EditEntityFieldAccessCheckInterface $access_checker, EditorSelectorInterface $editor_selector, PluginManagerInterface $editor_manager) {
+ public function __construct(QuickEditEntityFieldAccessCheckInterface $access_checker, EditorSelectorInterface $editor_selector, PluginManagerInterface $editor_manager) {
$this->accessChecker = $access_checker;
$this->editorSelector = $editor_selector;
$this->editorManager = $editor_manager;
diff --git a/core/modules/quickedit/tests/modules/src/MockEditEntityFieldAccessCheck.php b/core/modules/quickedit/tests/modules/src/MockEditEntityFieldAccessCheck.php
index b5d9456..7596aa8 100644
--- a/core/modules/quickedit/tests/modules/src/MockEditEntityFieldAccessCheck.php
+++ b/core/modules/quickedit/tests/modules/src/MockEditEntityFieldAccessCheck.php
@@ -2,19 +2,9 @@
namespace Drupal\quickedit_test;
-use Drupal\Core\Entity\EntityInterface;
-use Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface;
-
/**
- * Access check for editing entity fields.
+ * @deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.0.
*/
-class MockEditEntityFieldAccessCheck implements EditEntityFieldAccessCheckInterface {
-
- /**
- * {@inheritdoc}
- */
- public function accessEditEntityField(EntityInterface $entity, $field_name) {
- return TRUE;
- }
+class MockEditEntityFieldAccessCheck extends MockQuickEditEntityFieldAccessCheck {
}
diff --git a/core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php b/core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php
new file mode 100644
index 0000000..2459c50
--- /dev/null
+++ b/core/modules/quickedit/tests/modules/src/MockQuickEditEntityFieldAccessCheck.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Drupal\quickedit_test;
+
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface;
+
+/**
+ * Access check for in-place editing entity fields.
+ */
+class MockQuickEditEntityFieldAccessCheck implements QuickEditEntityFieldAccessCheckInterface {
+
+ /**
+ * {@inheritdoc}
+ */
+ public function accessEditEntityField(EntityInterface $entity, $field_name) {
+ return TRUE;
+ }
+
+}
diff --git a/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php b/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php
index 7fdc8fb..28480f4 100644
--- a/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php
+++ b/core/modules/quickedit/tests/src/Kernel/MetadataGeneratorTest.php
@@ -5,7 +5,7 @@ namespace Drupal\Tests\quickedit\Kernel;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\quickedit\EditorSelector;
use Drupal\quickedit\MetadataGenerator;
-use Drupal\quickedit_test\MockEditEntityFieldAccessCheck;
+use Drupal\quickedit_test\MockQuickEditEntityFieldAccessCheck;
use Drupal\filter\Entity\FilterFormat;
/**
@@ -44,7 +44,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
/**
* The access checker object to be used by the metadata generator object.
*
- * @var \Drupal\quickedit\Access\EditEntityFieldAccessCheckInterface
+ * @var \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheckInterface
*/
protected $accessChecker;
@@ -52,7 +52,7 @@ class MetadataGeneratorTest extends QuickEditTestBase {
parent::setUp();
$this->editorManager = $this->container->get('plugin.manager.quickedit.editor');
- $this->accessChecker = new MockEditEntityFieldAccessCheck();
+ $this->accessChecker = new MockQuickEditEntityFieldAccessCheck();
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
$this->metadataGenerator = new MetadataGenerator($this->accessChecker, $this->editorSelector, $this->editorManager);
}
diff --git a/core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php b/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php
index d7ceb59..9f35057 100644
--- a/core/modules/quickedit/tests/src/Unit/Access/EditEntityFieldAccessCheckTest.php
+++ b/core/modules/quickedit/tests/src/Unit/Access/QuickEditEntityFieldAccessCheckTest.php
@@ -5,21 +5,21 @@ namespace Drupal\Tests\quickedit\Unit\Access;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\Context\CacheContextsManager;
use Drupal\Core\DependencyInjection\Container;
-use Drupal\quickedit\Access\EditEntityFieldAccessCheck;
+use Drupal\quickedit\Access\QuickEditEntityFieldAccessCheck;
use Drupal\Tests\UnitTestCase;
use Drupal\Core\Language\LanguageInterface;
/**
- * @coversDefaultClass \Drupal\quickedit\Access\EditEntityFieldAccessCheck
+ * @coversDefaultClass \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheck
* @group Access
* @group quickedit
*/
-class EditEntityFieldAccessCheckTest extends UnitTestCase {
+class QuickEditEntityFieldAccessCheckTest extends UnitTestCase {
/**
* The tested access checker.
*
- * @var \Drupal\quickedit\Access\EditEntityFieldAccessCheck
+ * @var \Drupal\quickedit\Access\QuickEditEntityFieldAccessCheck
*/
protected $editAccessCheck;
@@ -27,7 +27,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->editAccessCheck = new EditEntityFieldAccessCheck();
+ $this->editAccessCheck = new QuickEditEntityFieldAccessCheck();
$cache_contexts_manager = $this->prophesize(CacheContextsManager::class);
$cache_contexts_manager->assertValidTokens()->willReturn(TRUE);
@@ -40,7 +40,7 @@ class EditEntityFieldAccessCheckTest extends UnitTestCase {
/**
* Provides test data for testAccess().
*
- * @see \Drupal\Tests\edit\Unit\quickedit\Access\EditEntityFieldAccessCheckTest::testAccess()
+ * @see \Drupal\Tests\edit\Unit\quickedit\Access\QuickEditEntityFieldAccessCheckTest::testAccess()
*/
public function providerTestAccess() {
$data = array();