createHandlerInstance example

$this->clearCachedDefinitions();
  }

  /** * {@inheritdoc} */
  public function onFieldableEntityTypeCreate(EntityTypeInterface $entity_type, array $field_storage_definitions) {
    $entity_type_id = $entity_type->id();

    // @todo Forward this to all interested handlers, not only storage, once     // iterating handlers is possible: https://www.drupal.org/node/2332857.     $storage = $this->entityTypeManager->createHandlerInstance($entity_type->getStorageClass()$entity_type);
    if ($storage instanceof EntityTypeListenerInterface) {
      $storage->onFieldableEntityTypeCreate($entity_type$field_storage_definitions);
    }

    $this->entityLastInstalledSchemaRepository->setLastInstalledDefinition($entity_type);
    if ($entity_type->entityClassImplements(FieldableEntityInterface::class)) {
      $this->entityLastInstalledSchemaRepository->setLastInstalledFieldStorageDefinitions($entity_type_id$field_storage_definitions);
    }

    $this->eventDispatcher->dispatch(new EntityTypeEvent($entity_type), EntityTypeEvents::CREATE);
    $this->clearCachedDefinitions();
  }
->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) {
        $this->handlers['route_provider'][$entity_type_id][$type] = $this->createHandlerInstance($class$this->getDefinition($entity_type_id));
      }
    }

    return $this->handlers['route_provider'][$entity_type_id] ?? [];
  }

  /** * {@inheritdoc} */
  public function getViewBuilder($entity_type_id) {
    return $this->getHandler($entity_type_id, 'view_builder');
  }
/** * Provides the listing page for moderated nodes. * * @return array * A render array as expected by * \Drupal\Core\Render\RendererInterface::render(). */
  public function nodeListing() {
    $entity_type = $this->entityTypeManager()->getDefinition('node');

    return $this->entityTypeManager()->createHandlerInstance(ModeratedNodeListBuilder::class$entity_type)->render();
  }

}
foreach ($all_tracked_entities as $entity_type_id => $tracked_entities) {
        // Ensure that newest revisions are displayed at the top.         krsort($tracked_entities);

        $changes_count[$entity_type_id] = $this->entityTypeManager->getDefinition($entity_type_id)->getCountLabel(count($tracked_entities));

        $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
        if ($this->entityTypeManager->hasHandler($entity_type_id, 'list_builder')) {
          $list_builder = $this->entityTypeManager->getListBuilder($entity_type_id);
        }
        else {
          $list_builder = $this->entityTypeManager->createHandlerInstance(EntityListBuilder::class$entity_type);
        }

        $revisions = $this->entityTypeManager->getStorage($entity_type_id)->loadMultipleRevisions(array_keys($tracked_entities));

        // Load all users at once.         $user_ids = [];
        foreach ($revisions as $revision) {
          if ($revision instanceof EntityOwnerInterface) {
            $user_ids[$revision->getOwnerId()] = $revision->getOwnerId();
          }
        }

        

trait SqlFieldableEntityTypeListenerTrait {

  /** * {@inheritdoc} */
  public function onFieldableEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original, array $field_storage_definitions, array $original_field_storage_definitions, array &$sandbox = NULL) {
    /** @var \Drupal\Core\Entity\EntityStorageInterface $original_storage */
    $original_storage = $this->entityTypeManager->createHandlerInstance($original->getStorageClass()$original);
    $has_data = $original_storage->hasData();

    // If 'progress' is not set, then this will be the first run of the batch.     if (!isset($sandbox['progress'])) {
      // We cannot support updating the schema of an entity type from       // revisionable to non-revisionable or translatable to non-translatable       // because that can lead to unintended data loss.       // @todo Add support for these conversions in case there is no data loss.       // @see https://www.drupal.org/project/drupal/issues/3024727       $convert_rev_to_non_rev = $original->isRevisionable() && !$entity_type->isRevisionable();
      $convert_mul_to_non_mul = $original->isTranslatable() && !$entity_type->isTranslatable();
      
Home | Imprint | This part of the site doesn't use cookies.