apigee_edge_test.module in Apigee Edge 8
Copyright 2018 Google Inc.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
File
tests/modules/apigee_edge_test/apigee_edge_test.moduleView source
<?php
/**
* @file
* Copyright 2018 Google Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License version 2 as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
* Helper module for the apigee_edge tests.
*/
use Drupal\apigee_edge_test\Entity\OverriddenApiProduct;
use Drupal\apigee_edge_test\Entity\OverriddenDeveloper;
use Drupal\apigee_edge_test\Entity\OverriddenDeveloperApp;
use Drupal\apigee_edge_test\Entity\Storage\DeveloperAppStorage;
/**
* Implements hook_entity_type_alter().
*/
function apigee_edge_test_entity_type_alter(array &$entity_types) {
/* @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
foreach (_apigee_edge_test_entity_class_mapping() as $entity_type => $entity_class) {
if (isset($entity_types[$entity_type])) {
$entity_types[$entity_type]
->setClass($entity_class);
}
}
$entity_types['developer_app']
->setStorageClass(DeveloperAppStorage::class);
}
/**
* A list of entity types and class overrides.
*
* @return array
* Override map.
*/
function _apigee_edge_test_entity_class_mapping() : array {
return [
'developer' => OverriddenDeveloper::class,
'developer_app' => OverriddenDeveloperApp::class,
'api_product' => OverriddenApiProduct::class,
];
}
Functions
Name | Description |
---|---|
apigee_edge_test_entity_type_alter | Implements hook_entity_type_alter(). |
_apigee_edge_test_entity_class_mapping | A list of entity types and class overrides. |