*/
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;
}
}
- // 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')) {
}
}
-/**
- * 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().
*/
// 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');
+ }
+}