config_test.module 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * @file
  4. * Provides Config module hook implementations for testing purposes.
  5. */
  6. require_once dirname(__FILE__) . '/config_test.hooks.inc';
  7. /**
  8. * Implements hook_cache_flush().
  9. */
  10. function config_test_cache_flush() {
  11. // Set a global value we can check in test code.
  12. $GLOBALS['hook_cache_flush'] = __FUNCTION__;
  13. }
  14. /**
  15. * Implements hook_entity_type_alter().
  16. */
  17. function config_test_entity_type_alter(array &$entity_types) {
  18. /** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
  19. // The 'translatable' entity key is not supposed to change over time. In this
  20. // case we can safely do it because we set it once and we do not change it for
  21. // all the duration of the test session.
  22. $entity_types['config_test']->set('translatable', \Drupal::service('state')->get('config_test.translatable'));
  23. // Create a clone of config_test that does not have a status.
  24. $entity_types['config_test_no_status'] = clone $entity_types['config_test'];
  25. $config_test_no_status = &$entity_types['config_test_no_status'];
  26. $config_test_no_status->setLinkTemplate('edit-form', '/admin/structure/config_test/manage/{config_test_no_status}');
  27. $config_test_no_status->setLinkTemplate('delete-form', '/admin/structure/config_test/manage/{config_test_no_status}/delete');
  28. $keys = $config_test_no_status->getKeys();
  29. unset($keys['status']);
  30. $config_test_no_status->set('id', 'config_test_no_status');
  31. $config_test_no_status->set('entity_keys', $keys);
  32. $config_test_no_status->set('config_prefix', 'no_status');
  33. if (\Drupal::service('state')->get('config_test.lookup_keys', FALSE)) {
  34. $entity_types['config_test']->set('lookup_keys', ['uuid', 'style']);
  35. }
  36. }