setExtraColumns example

'revision_id',
      'langcode',
      'delta',
    ];
    foreach ($dedicated_table_definitions as $field_name => $definition) {
      $tables = [$table_mapping->getDedicatedDataTableName($definition)];
      if ($revisionable && $definition->isRevisionable()) {
        $tables[] = $table_mapping->getDedicatedRevisionTableName($definition);
      }
      foreach ($tables as $table_name) {
        $table_mapping->setFieldNames($table_name[$field_name]);
        $table_mapping->setExtraColumns($table_name$extra_columns);
      }
    }

    return $table_mapping;
  }

  /** * Gets the base table name. * * @return string * The base table name. * * @internal */
// The storage definitions are only used in getColumnNames() so we do not     // need to provide any here.     $table_mapping = new TestDefaultTableMapping($this->entityType, []);
    $this->assertSame([]$table_mapping->getTableNames());

    $table_mapping->setFieldNames('foo', []);
    $this->assertSame(['foo']$table_mapping->getTableNames());

    $table_mapping->setFieldNames('bar', []);
    $this->assertSame(['foo', 'bar']$table_mapping->getTableNames());

    $table_mapping->setExtraColumns('baz', []);
    $this->assertSame(['foo', 'bar', 'baz']$table_mapping->getTableNames());

    // Test that table names are not duplicated.     $table_mapping->setExtraColumns('foo', []);
    $this->assertSame(['foo', 'bar', 'baz']$table_mapping->getTableNames());
  }

  /** * Tests DefaultTableMapping::getAllColumns(). * * @covers ::__construct * @covers ::getAllColumns * @covers ::getFieldNames * @covers ::getColumnNames * @covers ::setFieldNames * @covers ::getExtraColumns * @covers ::setExtraColumns */
'table' => 'users',
            'columns' => ['editor_revision__target_id' => 'uid'],
          ],
        ],
      ],
    ];

    $this->setUpStorageSchema($expected);

    $table_mapping = new TestSqlContentDefaultTableMapping($this->entityType, $this->storageDefinitions);
    $table_mapping->setFieldNames('entity_test', array_keys($this->storageDefinitions));
    $table_mapping->setExtraColumns('entity_test', ['default_langcode']);

    $this->storageSchema->expects($this->any())
      ->method('getTableMapping')
      ->willReturn($table_mapping);

    $this->assertNull(
      $this->storageSchema->onEntityTypeCreate($this->entityType)
    );
  }

  /** * Tests the schema for revisionable, non-translatable entities. * * @covers ::__construct * @covers ::getEntitySchemaTables * @covers ::initializeBaseTable * @covers ::initializeRevisionTable * @covers ::addTableDefaults * @covers ::getEntityIndexName * @covers ::processIdentifierSchema */
Home | Imprint | This part of the site doesn't use cookies.