Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / entity_test.module
index cc9a09ca691bfcbf233ab9713f0d8b320ec1731f..bcf55f48b270e9b0cfbcb5c12f31275394c5185d 100644 (file)
@@ -6,6 +6,7 @@
  */
 
 use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Database\Query\AlterableInterface;
 use Drupal\Core\Entity\ContentEntityInterface;
 use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Entity\FieldableEntityInterface;
@@ -93,8 +94,8 @@ function entity_test_entity_type_alter(array &$entity_types) {
     }
   }
 
-  // Allow entity_test_with_bundle tests to override the entity type definition.
-  $entity_types['entity_test_with_bundle'] = $state->get('entity_test_with_bundle.entity_type', $entity_types['entity_test_with_bundle']);
+  // Allow entity_test_rev tests to override the entity type definition.
+  $entity_types['entity_test_rev'] = $state->get('entity_test_rev.entity_type', $entity_types['entity_test_rev']);
 
   // Enable the entity_test_new only when needed.
   if (!$state->get('entity_test_new')) {
@@ -102,17 +103,6 @@ function entity_test_entity_type_alter(array &$entity_types) {
   }
 }
 
-/**
- * Implements hook_module_implements_alter().
- */
-function entity_test_module_implements_alter(&$implementations, $hook) {
-  // Move our hook_entity_type_alter() implementation to the beginning of the
-  // list in order to run before content_moderation_entity_type_alter().
-  if ($hook === 'entity_type_alter') {
-    $implementations = ['entity_test' => $implementations['entity_test']] + $implementations;
-  }
-}
-
 /**
  * Implements hook_entity_base_field_info().
  */
@@ -793,3 +783,17 @@ function entity_test_entity_test_create_access(AccountInterface $account, $conte
   // No opinion.
   return AccessResult::neutral();
 }
+
+/**
+ * Implements hook_query_entity_test_access_alter().
+ */
+function entity_test_query_entity_test_access_alter(AlterableInterface $query) {
+  if (!\Drupal::state()->get('entity_test_query_access')) {
+    return;
+  }
+
+  /** @var \Drupal\Core\Database\Query\Select|\Drupal\Core\Database\Query\AlterableInterface $query */
+  if (!\Drupal::currentUser()->hasPermission('view all entity_test_query_access entities')) {
+    $query->condition('entity_test_query_access.name', 'published entity');
+  }
+}