Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / content_translation / tests / modules / content_translation_test / content_translation_test.module
index e2318079c99a44ff50ff9308e28d48cee6ef7e3a..50495a8c799b202413954134d27803e6f8fc89ca 100644 (file)
@@ -5,7 +5,39 @@
  * Helper module for the Content Translation tests.
  */
 
+use Drupal\Core\Access\AccessResult;
+use Drupal\Core\Entity\EntityInterface;
 use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Session\AccountInterface;
+
+/**
+ * Implements hook_entity_bundle_info_alter().
+ */
+function content_translation_test_entity_bundle_info_alter(&$bundles) {
+  // Store the initial status of the "translatable" property for the
+  // "entity_test_mul" bundle.
+  $translatable = !empty($bundles['entity_test_mul']['entity_test_mul']['translatable']);
+  \Drupal::state()->set('content_translation_test.translatable', $translatable);
+  // Make it translatable if Content Translation did not. This will make the
+  // entity object translatable even if it is disabled in Content Translation
+  // settings.
+  if (!$translatable) {
+    $bundles['entity_test_mul']['entity_test_mul']['translatable'] = TRUE;
+  }
+}
+
+/**
+ * Implements hook_entity_access().
+ */
+function content_translation_test_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
+  $access = \Drupal::state()->get('content_translation.entity_access.' . $entity->getEntityTypeId());
+  if (!empty($access[$operation])) {
+    return AccessResult::allowed();
+  }
+  else {
+    return AccessResult::neutral();
+  }
+}
 
 /**
  * Implements hook_form_BASE_FORM_ID_alter().