Skip to content

Commit

Permalink
Update the storage defination of App entity (#831)
Browse files Browse the repository at this point in the history
  • Loading branch information
phdhiren authored Mar 30, 2023
1 parent acc1c18 commit 56f012c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
24 changes: 24 additions & 0 deletions apigee_edge.install
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use Drupal\apigee_edge\OauthTokenFileStorage;
use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Url;
use Drupal\user\RoleInterface;
Expand Down Expand Up @@ -349,3 +350,26 @@ function apigee_edge_update_8107() {
$storage->removeTokenFile();
}
}

/**
* Update the field storage defination of Developer App.
*/
function apigee_edge_update_9001() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
/** @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $last_installed_schema_repository */
$last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository');
$entity_type_id = 'developer_app';
$entity_type = $definition_update_manager->getEntityType($entity_type_id);
$field_storage_definitions = $last_installed_schema_repository->getLastInstalledFieldStorageDefinitions($entity_type_id);

$field_storage_definitions['apiProducts'] = BaseFieldDefinition::create('string')
->setName('apiproducts')
->setTargetEntityTypeId($entity_type_id)
->setTargetBundle(NULL)
->setStorageRequired(FALSE)
->setInternal(TRUE)
->setTranslatable(FALSE)
->setRevisionable(FALSE);

$definition_update_manager->updateFieldableEntityType($entity_type, $field_storage_definitions);
}
24 changes: 23 additions & 1 deletion modules/apigee_edge_teams/apigee_edge_teams.install
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use Apigee\Edge\Utility\OrganizationFeatures;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\user\RoleInterface;
use Drupal\views\Views;

Expand Down Expand Up @@ -177,4 +178,25 @@ function apigee_edge_teams_update_8705() {
}
}


/**
* Update the field storage defination of Team App.
*/
function apigee_edge_teams_update_9001() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
/** @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $last_installed_schema_repository */
$last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository');
$entity_type_id = 'team_app';
$entity_type = $definition_update_manager->getEntityType($entity_type_id);
$field_storage_definitions = $last_installed_schema_repository->getLastInstalledFieldStorageDefinitions($entity_type_id);

$field_storage_definitions['apiProducts'] = BaseFieldDefinition::create('string')
->setName('apiproducts')
->setTargetEntityTypeId($entity_type_id)
->setTargetBundle(NULL)
->setStorageRequired(FALSE)
->setInternal(TRUE)
->setTranslatable(FALSE)
->setRevisionable(FALSE);

$definition_update_manager->updateFieldableEntityType($entity_type, $field_storage_definitions);
}
1 change: 1 addition & 0 deletions src/Entity/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {

// Hide readonly properties from Manage form display list.
$read_only_fields = [
'apiProducts',
'appId',
'appFamily',
'createdAt',
Expand Down

0 comments on commit 56f012c

Please sign in to comment.