setStorageClass example


    ]);
    $this->assertSame($controller$entity_type->getStorageClass());
  }

  /** * Tests the setStorageClass() method. */
  public function testSetStorageClass() {
    $controller = $this->getTestHandlerClass();
    $entity_type = $this->setUpEntityType([]);
    $this->assertSame($entity_type$entity_type->setStorageClass($controller));
  }

  /** * Tests the getListBuilderClass() method. */
  public function testGetListBuilderClass() {
    $controller = $this->getTestHandlerClass();
    $entity_type = $this->setUpEntityType([
      'handlers' => [
        'list_builder' => $controller,
      ],
    ]);
'handlers' => ['storage' => '\Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage'],
    ]);
  }

  /** * @covers ::setStorageClass */
  public function testSetStorageClass() {
    $config_entity = $this->setUpConfigEntityType([]);
    $this->expectException(ConfigEntityStorageClassException::class);
    $this->expectExceptionMessage('\Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage is not \Drupal\Core\Config\Entity\ConfigEntityStorage or it does not extend it');
    $config_entity->setStorageClass('\Drupal\Core\Entity\KeyValueStore\KeyValueEntityStorage');
  }

  /** * Tests the getConfigPrefix() method. * * @dataProvider providerTestGetConfigPrefix * * @covers ::getConfigPrefix */
  public function testGetConfigPrefix($definition$expected) {
    $entity_type = $this->setUpConfigEntityType($definition);
    

function hook_entity_type_alter(array &$entity_types) {
  /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
  // Set the controller class for nodes to an alternate implementation of the   // Drupal\Core\Entity\EntityStorageInterface interface.   $entity_types['node']->setStorageClass('Drupal\mymodule\MyCustomNodeStorage');
}

/** * Alter the view modes for entity types. * * @param array $view_modes * An array of view modes, keyed first by entity type, then by view mode name. * * @see \Drupal\Core\Entity\EntityDisplayRepositoryInterface::getAllViewModes() * @see \Drupal\Core\Entity\EntityDisplayRepositoryInterface::getViewModes() */
Home | Imprint | This part of the site doesn't use cookies.