FeedStorageSchema.php 1.09 KB
Newer Older
1 2 3 4 5 6 7 8 9
<?php

/**
 * @file
 * Contains \Drupal\aggregator\FeedStorageSchema.
 */

namespace Drupal\aggregator;

10
use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
11
use Drupal\Core\Field\FieldStorageDefinitionInterface;
12 13 14 15 16 17 18 19 20

/**
 * Defines the feed schema handler.
 */
class FeedStorageSchema extends SqlContentEntityStorageSchema {

  /**
   * {@inheritdoc}
   */
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
  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 == 'aggregator_feed') {
      switch ($field_name) {
        case 'url':
          $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE, 255);
          break;

        case 'queued':
          $this->addSharedTableFieldIndex($storage_definition, $schema, TRUE);
          break;

        case 'title':
          $this->addSharedTableFieldUniqueKey($storage_definition, $schema);
          break;
      }
    }
40 41 42 43 44

    return $schema;
  }

}