You are here

RegistrantStorageSchema.php in RNG - Events and Registrations 3.x

Same filename and directory in other branches
  1. 8.2 src/RegistrantStorageSchema.php
  2. 8 src/RegistrantStorageSchema.php

Namespace

Drupal\rng

File

src/RegistrantStorageSchema.php
View source
<?php

namespace Drupal\rng;

use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
use Drupal\Core\Field\FieldStorageDefinitionInterface;

/**
 * Defines the schema for Registrant entities.
 */
class RegistrantStorageSchema extends SqlContentEntityStorageSchema {

  /**
   * {@inheritdoc}
   */
  protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
    $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
    if ($storage_definition
      ->getName() == 'type') {

      // This field was added to the registrant entity in a hook_update_N
      // Since you cannot specifiy an initial value when installing a field,
      // and there previously was only a 'registrant' bundle, then use this
      // default value.
      // @see https://www.drupal.org/node/2346019#comment-11746237
      $schema['fields']['type']['initial'] = 'registrant';
    }
    return $schema;
  }

}

Classes

Namesort descending Description
RegistrantStorageSchema Defines the schema for Registrant entities.