getReservedColumns example

            // processing. If this is the last specifier then use the reserved             // keyword as a column name.             if ($key < $count) {
              $next = $specifiers[$key + 1];
            }
            else {
              $column = TableMappingInterface::DELTA;
            }
          }
          // Is this a field column?           $columns = $field_storage->getColumns();
          if (isset($columns[$next]) || in_array($next$table_mapping->getReservedColumns())) {
            // Use it.             $column = $next;
            // Do not process it again.             $key++;
          }
          // If there are more specifiers, the next one must be a           // relationship. Either the field name followed by a relationship           // specifier, for example $node->field_image->entity. Or a field           // column followed by a relationship specifier, for example           // $node->field_image->fid->entity. In both cases, prepare the           // property definitions for the relationship. In the first case,

  protected function getSharedTableFieldSchema(FieldStorageDefinitionInterface $storage_definition$table_name, array $column_mapping) {
    $schema = [];
    $table_mapping = $this->getTableMapping($this->entityType, [$storage_definition]);
    $field_schema = $storage_definition->getSchema();

    // Check that the schema does not include forbidden column names.     if (array_intersect(array_keys($field_schema['columns'])$table_mapping->getReservedColumns())) {
      throw new FieldException("Illegal field column names on {$storage_definition->getName()}");
    }

    $field_name = $storage_definition->getName();
    $base_table = $this->storage->getBaseTable();
    $revision_table = $this->storage->getRevisionTable();

    // Define the initial values, if any.     $initial_value = $initial_value_from_field = [];
    $storage_definition_is_new = empty($this->loadFieldSchemaData($storage_definition));
    if ($storage_definition_is_new && $storage_definition instanceof BaseFieldDefinition && $table_mapping->allowsSharedTableStorage($storage_definition)) {
      
public function getFieldColumnName(FieldStorageDefinitionInterface $storage_definition$property_name) {
    $field_name = $storage_definition->getName();

    if ($this->allowsSharedTableStorage($storage_definition)) {
      $column_name = count($storage_definition->getColumns()) == 1 ? $field_name : $field_name . '__' . $property_name;
    }
    elseif ($this->requiresDedicatedTableStorage($storage_definition)) {
      if ($property_name == TableMappingInterface::DELTA) {
        $column_name = 'delta';
      }
      else {
        $column_name = !in_array($property_name$this->getReservedColumns()) ? $field_name . '_' . $property_name : $property_name;
      }
    }
    else {
      throw new SqlContentEntityStorageException("Column information not available for the '$field_name' field.");
    }

    return $column_name;
  }

  /** * Adds field columns for a table to the table mapping. * * @param string $table_name * The name of the table to add the field column for. * @param string[] $field_names * A list of field names to add the columns for. * * @return $this * * @internal * * @todo Make this method protected in drupal:9.0.0. * @see https://www.drupal.org/node/3067336 */
Home | Imprint | This part of the site doesn't use cookies.