hasCustomStorage example


  public static function createFromFieldStorageDefinition(FieldStorageDefinitionInterface $definition) {
    return static::create($definition->getType())
      ->setCardinality($definition->getCardinality())
      ->setConstraints($definition->getConstraints())
      ->setCustomStorage($definition->hasCustomStorage())
      ->setDescription($definition->getDescription())
      ->setLabel($definition->getLabel())
      ->setName($definition->getName())
      ->setProvider($definition->getProvider())
      ->setRevisionable($definition->isRevisionable())
      ->setSettings($definition->getSettings())
      ->setTargetEntityTypeId($definition->getTargetEntityTypeId())
      ->setTranslatable($definition->isTranslatable());
  }

  /** * {@inheritdoc} */
$this->assertEquals($provider$definition->getProvider());
  }

  /** * Tests custom storage. * * @covers ::hasCustomStorage * @covers ::setCustomStorage */
  public function testCustomStorage() {
    $definition = BaseFieldDefinition::create($this->fieldType);
    $this->assertFalse($definition->hasCustomStorage());
    $definition->setCustomStorage(TRUE);
    $this->assertTrue($definition->hasCustomStorage());
    $definition->setCustomStorage(FALSE);
    $this->assertFalse($definition->hasCustomStorage());
  }

  /** * Tests default value callbacks. * * @covers ::setDefaultValueCallback */
  
$revision_table && $entity_type->getRevisionTable() != $original->getRevisionTable()) ||
      (!$revision_data_table && $entity_type->getRevisionDataTable() != $original->getRevisionDataTable());
  }

  /** * {@inheritdoc} */
  public function requiresFieldStorageSchemaChanges(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
    $table_mapping = $this->getTableMapping($this->entityType);

    if (
      $storage_definition->hasCustomStorage() != $original->hasCustomStorage() ||
      $storage_definition->getSchema() != $original->getSchema() ||
      $storage_definition->isRevisionable() != $original->isRevisionable() ||
      $table_mapping->allowsSharedTableStorage($storage_definition) != $table_mapping->allowsSharedTableStorage($original) ||
      $table_mapping->requiresDedicatedTableStorage($storage_definition) != $table_mapping->requiresDedicatedTableStorage($original)
    ) {
      return TRUE;
    }

    if ($storage_definition->hasCustomStorage()) {
      // The field has custom storage, so we don't know if a schema change is       // needed or not, but since per the initial checks earlier in this
return array_keys(array_filter($this->fieldNames, function D$table_fields) use ($field_name) {
      return in_array($field_name$table_fields, TRUE);
    }));
  }

  /** * {@inheritdoc} */
  public function getColumnNames($field_name) {
    if (!isset($this->columnMapping[$field_name])) {
      $this->columnMapping[$field_name] = [];
      if (isset($this->fieldStorageDefinitions[$field_name]) && !$this->fieldStorageDefinitions[$field_name]->hasCustomStorage()) {
        foreach (array_keys($this->fieldStorageDefinitions[$field_name]->getColumns()) as $property_name) {
          $this->columnMapping[$field_name][$property_name] = $this->getFieldColumnName($this->fieldStorageDefinitions[$field_name]$property_name);
        }
      }
    }
    return $this->columnMapping[$field_name];
  }

  /** * {@inheritdoc} */
  
Home | Imprint | This part of the site doesn't use cookies.