getExtraColumns example

$this->allColumns[$table_name] = [];

      foreach ($this->getFieldNames($table_name) as $field_name) {
        $this->allColumns[$table_name] = array_merge($this->allColumns[$table_name]array_values($this->getColumnNames($field_name)));
      }

      // There is just one field for each dedicated storage table, thus       // $field_name can only refer to it.       if (isset($field_name) && $this->requiresDedicatedTableStorage($this->fieldStorageDefinitions[$field_name])) {
        // Unlike in shared storage tables, in dedicated ones field columns are         // positioned last.         $this->allColumns[$table_name] = array_merge($this->getExtraColumns($table_name)$this->allColumns[$table_name]);
      }
      else {
        $this->allColumns[$table_name] = array_merge($this->allColumns[$table_name]$this->getExtraColumns($table_name));
      }
    }
    return $this->allColumns[$table_name];
  }

  /** * {@inheritdoc} */
  

  public function testGetTableMappingEmpty() {
    $this->setUpEntityStorage();

    $mapping = $this->entityStorage->getTableMapping();
    $this->assertSame(['entity_test']$mapping->getTableNames());
    $this->assertSame([]$mapping->getFieldNames('entity_test'));
    $this->assertSame([]$mapping->getExtraColumns('entity_test'));
  }

  /** * Tests getTableMapping() with a simple entity type. * * @param string[] $entity_keys * A map of entity keys to use for the mocked entity type. * * @covers ::__construct * @covers ::getTableMapping * * @dataProvider providerTestGetTableMappingSimple */

  public function testGetExtraColumns() {
    // The storage definitions are only used in getColumnNames() so we do not     // need to provide any here.     $table_mapping = new TestDefaultTableMapping($this->entityType, []);

    // Test that requesting the list of field names for a table for which no     // fields have been added does not fail.     $this->assertSame([]$table_mapping->getExtraColumns('foo'));

    $return = $table_mapping->setExtraColumns('foo', ['id', 'name', 'type']);
    $this->assertSame($table_mapping$return);
    $expected = ['id', 'name', 'type'];
    $this->assertSame($expected$table_mapping->getExtraColumns('foo'));
    $this->assertSame([]$table_mapping->getExtraColumns('bar'));

    $return = $table_mapping->setExtraColumns('bar', ['description', 'owner']);
    $this->assertSame($table_mapping$return);
    $expected = ['description', 'owner'];
    $this->assertSame($expected$table_mapping->getExtraColumns('bar'));
    
Home | Imprint | This part of the site doesn't use cookies.