Skip to content
Snippets Groups Projects
Select Git revision
  • project-update-bot-only
  • 8.x-1.x default
  • 3433816-automated-drupal-11
  • 3433816-manual-drupal-11
  • 7.x-1.x
  • previous/3433816-automated-drupal-11/2024-07-28
  • previous/project-update-bot-only/2024-06-18
  • previous/project-update-bot-only/2024-06-08
  • previous/project-update-bot-only/2024-06-02
  • previous/project-update-bot-only/2024-05-30
  • 8.x-1.17
  • 8.x-1.16
  • 8.x-1.15
  • 8.x-1.14
  • 8.x-1.13
  • 8.x-1.12
  • 8.x-1.11
  • 8.x-1.10
  • 8.x-1.9
  • 8.x-1.8
  • 8.x-1.7
  • 8.x-1.6
  • 8.x-1.5
  • 8.x-1.4
  • 8.x-1.3
25 results

ParagraphStorageSchema.php

Blame
  • CharlieChXNegyesi's avatar
    Issue #3094806 by amateescu, Charlie ChX Negyesi: parent_fields index is...
    ghost of drupal past authored and Sascha Grossenbacher committed
    Issue #3094806 by amateescu, Charlie ChX Negyesi: parent_fields index is missing from the revisions table
    e0c07fa3
    History
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ParagraphStorageSchema.php 1.53 KiB
    <?php
    
    namespace Drupal\paragraphs;
    
    use Drupal\Core\Entity\ContentEntityTypeInterface;
    use Drupal\Core\Entity\Sql\SqlContentEntityStorageSchema;
    use Drupal\Core\Field\FieldStorageDefinitionInterface;
    
    /**
     * Extends the paragraphs schema handler.
     */
    class ParagraphStorageSchema extends SqlContentEntityStorageSchema {
    
      /**
       * {@inheritdoc}
       */
      protected function getEntitySchema(ContentEntityTypeInterface $entity_type, $reset = FALSE) {
        $schema = parent::getEntitySchema($entity_type, $reset);
    
        $schema[$this->storage->getDataTable()]['indexes'] += array(
          'paragraphs__parent_fields' => array('parent_type', 'parent_id', 'parent_field_name'),
        );
        $schema[$this->storage->getRevisionDataTable()]['indexes'] += array(
          'paragraphs__parent_fields' => array('parent_type', 'parent_id', 'parent_field_name'),
        );
    
        return $schema;
      }
    
      /**
       * {@inheritdoc}
       */
      protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition, $table_name, array $column_mapping) {
        // Setting the initial value to 1 when we add a 'status' field.
        // @todo this is a workaround for https://www.drupal.org/node/2346019
        $schema = parent::getSharedTableFieldSchema($storage_definition, $table_name, $column_mapping);
        if ($storage_definition->getName() == 'status') {
          $schema['fields']['status']['initial'] = 1;
        }
    
        if ($storage_definition->getName() == 'behavior_settings') {
          $schema['fields']['behavior_settings']['initial'] = serialize([]);
        }
        return $schema;
      }
    }