Skip to content
Snippets Groups Projects
Select Git revision
  • 24e3c5d154040104d76d84b54fffdb7c29982809
  • 11.x default protected
  • 10.5.x protected
  • 10.6.x protected
  • 11.2.x protected
  • 11.1.x protected
  • 10.4.x protected
  • 11.0.x protected
  • 10.3.x protected
  • 7.x protected
  • 10.2.x protected
  • 10.1.x protected
  • 9.5.x protected
  • 10.0.x protected
  • 9.4.x protected
  • 9.3.x protected
  • 9.2.x protected
  • 9.1.x protected
  • 8.9.x protected
  • 9.0.x protected
  • 8.8.x protected
  • 10.5.1 protected
  • 11.2.2 protected
  • 11.2.1 protected
  • 11.2.0 protected
  • 10.5.0 protected
  • 11.2.0-rc2 protected
  • 10.5.0-rc1 protected
  • 11.2.0-rc1 protected
  • 10.4.8 protected
  • 11.1.8 protected
  • 10.5.0-beta1 protected
  • 11.2.0-beta1 protected
  • 11.2.0-alpha1 protected
  • 10.4.7 protected
  • 11.1.7 protected
  • 10.4.6 protected
  • 11.1.6 protected
  • 10.3.14 protected
  • 10.4.5 protected
  • 11.0.13 protected
41 results

config_test.module

Blame
  • Alex Pott's avatar
    Issue #2083615 by Gábor Hojtsy, YesCT: Use links annotation for config entity...
    Alex Pott authored
    Issue #2083615 by Gábor Hojtsy, YesCT: Use links annotation for config entity URI like for content entities.
    24e3c5d1
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    config_test.module 2.61 KiB
    <?php
    
    /**
     * @file
     * Provides Config module hook implementations for testing purposes.
     */
    
    use Drupal\config_test\Entity\ConfigTest;
    use Symfony\Component\HttpFoundation\RedirectResponse;
    
    require_once dirname(__FILE__) . '/config_test.hooks.inc';
    
    /**
     * Implements hook_menu().
     */
    function config_test_menu() {
      $items['admin/structure/config_test'] = array(
        'title' => 'Test configuration',
        'route_name' => 'config_test.list_page',
      );
      $items['admin/structure/config_test/add'] = array(
        'title' => 'Add test configuration',
        'route_name' => 'config_test.entity_add',
        'type' => MENU_SIBLING_LOCAL_TASK,
      );
      $items['admin/structure/config_test/manage/%config_test'] = array(
        'route_name' => 'config_test.entity',
      );
      $items['admin/structure/config_test/manage/%config_test/edit'] = array(
        'title' => 'Edit',
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
      $items['admin/structure/config_test/manage/%config_test/delete'] = array(
        'title' => 'Delete',
        'route_name' => 'config_test.entity_delete',
      );
      $items['admin/structure/config_test/manage/%config_test/enable'] = array(
        'title' => 'Enable',
        'route_name' => 'config_test.entity_enable',
      );
      $items['admin/structure/config_test/manage/%config_test/disable'] = array(
        'title' => 'Disable',
        'route_name' => 'config_test.entity_disable',
      );
      return $items;
    }
    
    /**
     * Loads a ConfigTest object.
     *
     * @param string $id
     *   The ID of the ConfigTest object to load.
     */
    function config_test_load($id) {
      return entity_load('config_test', $id);
    }
    
    /**
     * Implements hook_cache_flush().
     */
    function config_test_cache_flush() {
      // Set a global value we can check in test code.
      $GLOBALS['hook_cache_flush'] = __FUNCTION__;
    }
    
    /**
     * Implements hook_ENTITY_TYPE_create().
     */
    function config_test_config_test_create(ConfigTest $config_test) {
      if (\Drupal::state()->get('config_test.prepopulate')) {
        $config_test->set('foo', 'baz');
      }
    }
    
    /**
     * Implements hook_entity_info_alter().
     */
    function config_test_entity_info_alter(&$entity_info) {
      // The 'translatable' entity key is not supposed to change over time. In this
      // case we can safely do it because we set it once and we do not change it for
      // all the duration of the test session.
      $entity_info['config_test']['translatable'] = \Drupal::service('state')->get('config_test.translatable');
    
      // Create a clone of config_test that does not have a status.
      $entity_info['config_test_no_status'] = $entity_info['config_test'];
      unset($entity_info['config_test_no_status']['entity_keys']['status']);
      $entity_info['config_test_no_status']['config_prefix'] = 'config_test.no_status';
    }