setEntityTypeManager example


  public function getFormObject($entity_type_id$operation) {
    if (!$class = $this->getDefinition($entity_type_id, TRUE)->getFormClass($operation)) {
      throw new InvalidPluginDefinitionException($entity_type_idsprintf('The "%s" entity type did not specify a "%s" form class.', $entity_type_id$operation));
    }

    $form_object = $this->classResolver->getInstanceFromDefinition($class);

    return $form_object
      ->setStringTranslation($this->stringTranslation)
      ->setModuleHandler($this->moduleHandler)
      ->setEntityTypeManager($this)
      ->setOperation($operation);
  }

  /** * {@inheritdoc} */
  public function getRouteProviders($entity_type_id) {
    if (!isset($this->handlers['route_provider'][$entity_type_id])) {
      $route_provider_classes = $this->getDefinition($entity_type_id, TRUE)->getRouteProviderClasses();

      foreach ($route_provider_classes as $type => $class) {
        

  protected function setUpStorage() {
    $storage = $this->prophesize(EntityStorageInterface::class);

    $entity_type_manager = $this->prophesize(EntityTypeManagerInterface::class);
    $entity_type_manager->getDefinition($this->entityType->id())->willReturn($this->entityType);
    $entity_type_manager->getStorage($this->entityType->id())->willReturn($storage->reveal());

    $this->entityForm->setEntityTypeManager($entity_type_manager->reveal());

    return $storage;
  }

}
Home | Imprint | This part of the site doesn't use cookies.