|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Copyright 2023 Google Inc. |
| 5 | + * |
| 6 | + * This program is free software; you can redistribute it and/or |
| 7 | + * modify it under the terms of the GNU General Public License |
| 8 | + * version 2 as published by the Free Software Foundation. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program; if not, write to the Free Software |
| 17 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
| 18 | + * MA 02110-1301, USA. |
| 19 | + */ |
| 20 | + |
| 21 | +namespace Drupal\apigee_edge_teams\Entity\Storage; |
| 22 | + |
| 23 | +use Drupal\Core\Entity\ContentEntityTypeInterface; |
| 24 | +use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema; |
| 25 | + |
| 26 | +/** |
| 27 | + * Entity storage class for team member role entities. |
| 28 | + */ |
| 29 | +class TeamMemberRoleStorageSchema extends SqlContentEntityStorageSchema { |
| 30 | + |
| 31 | + /** |
| 32 | + * {@inheritdoc} |
| 33 | + */ |
| 34 | + protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) { |
| 35 | + $schema = parent::getEntitySchema($entity_type, $reset); |
| 36 | + // For JSONAPI uuid added in entity_keys, but because it, duplicate |
| 37 | + // uuid field is generated, which cause error while installing team_member table. |
| 38 | + if (!empty($schema['team_member_role']['fields']['uuid'])) { |
| 39 | + foreach ($schema['team_member_role']['fields']['uuid'] as $key => $value) { |
| 40 | + $schema['team_member_role']['fields']['uuid'][$key] = is_array($value) ? $value[0] : $value; |
| 41 | + } |
| 42 | + // Fix to remove duplicate UUID field in primary key. |
| 43 | + if (!empty($schema['team_member_role']['unique keys']['team_member_role_field__uuid__value'][1]) && $schema['team_member_role']['unique keys']['team_member_role_field__uuid__value'][1] == 'uuid') { |
| 44 | + unset($schema['team_member_role']['unique keys']['team_member_role_field__uuid__value'][1]); |
| 45 | + } |
| 46 | + } |
| 47 | + return $schema; |
| 48 | + } |
| 49 | + |
| 50 | +} |
0 commit comments