You are here

PhotosImageStorageSchema.php in Album Photos 8.5

Same filename and directory in other branches
  1. 6.0.x src/PhotosImageStorageSchema.php

Namespace

Drupal\photos

File

src/PhotosImageStorageSchema.php
View source
<?php

namespace Drupal\photos;

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

/**
 * Defines the photos image schema handler.
 */
class PhotosImageStorageSchema extends SqlContentEntityStorageSchema {

  /**
   * {@inheritdoc}
   */
  protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
    $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
    $field_name = $storage_definition
      ->getName();
    if ($table_name == 'photos_image_revision') {
      switch ($field_name) {
        case 'langcode':
          $this
            ->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
          break;
        case 'revision_uid':
          $this
            ->addSharedTableFieldForeignKey($storage_definition, $schema, 'users', 'uid');
          break;
      }
    }
    if ($table_name == 'photos_image_field_data') {
      switch ($field_name) {
        case 'status':
        case 'title':

          // Improves the performance of the indexes defined
          // in getEntitySchema().
          $schema['fields'][$field_name]['not null'] = TRUE;
          break;
        case 'ablum_id':
        case 'changed':
        case 'created':
          $this
            ->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
          break;
      }
    }
    return $schema;
  }

}

Classes

Namesort descending Description
PhotosImageStorageSchema Defines the photos image schema handler.