getEntityTypeEvents example


  public function __construct(EntityDefinitionUpdateManagerInterface $entityDefinitionUpdateManager, StateInterface $state) {
    $this->entityDefinitionUpdateManager = $entityDefinitionUpdateManager;
    $this->state = $state;
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    return static::getEntityTypeEvents();
  }

  /** * {@inheritdoc} */
  public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
    // Only add the new base field when a test needs it.     if (!$this->state->get('entity_test_update.install_new_base_field_during_create', FALSE)) {
      return;
    }

    
public function __construct(StateInterface $state, EntityLastInstalledSchemaRepositoryInterface $entity_last_installed_schema_repository, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager) {
    $this->state = $state;
    $this->entityLastInstalledSchemaRepository = $entity_last_installed_schema_repository;
    $this->entityTypeManager = $entity_type_manager;
    $this->entityFieldManager = $entity_field_manager;
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    return static::getEntityTypeEvents() + static::getFieldStorageDefinitionEvents();
  }

  /** * {@inheritdoc} */
  public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
    if ($this->entityLastInstalledSchemaRepository->getLastInstalledDefinition($entity_type->id())) {
      $this->storeDefinitionUpdate(EntityTypeEvents::CREATE);
    }
    $this->storeEvent(EntityTypeEvents::CREATE);

    

  public function __construct(EntityTypeManagerInterface $entity_type_manager, LoggerInterface $logger) {
    $this->entityTypeManager = $entity_type_manager;
    $this->logger = $logger;
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    return static::getEntityTypeEvents();
  }

  /** * {@inheritdoc} */
  public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
    $changes = [];

    // We implement a specific logic for table updates, which is bound to the     // default sql content entity storage.     if (!$this->entityTypeManager->getStorage($entity_type->id()) instanceof SqlContentEntityStorage) {
      

  public function __construct(EntityDefinitionUpdateManagerInterface $entityDefinitionUpdateManager, EntityLastInstalledSchemaRepositoryInterface $entityLastInstalledSchemaRepository, WorkspaceManagerInterface $workspace_manager) {
    $this->entityDefinitionUpdateManager = $entityDefinitionUpdateManager;
    $this->entityLastInstalledSchemaRepository = $entityLastInstalledSchemaRepository;
    $this->workspaceManager = $workspace_manager;
  }

  /** * {@inheritdoc} */
  public static function getSubscribedEvents(): array {
    return static::getEntityTypeEvents();
  }

  /** * {@inheritdoc} */
  public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
    // If the entity type is supported by Workspaces, add the revision metadata     // field.     if ($this->workspaceManager->isEntityTypeSupported($entity_type)) {
      $this->addRevisionMetadataField($entity_type);
    }
  }
Home | Imprint | This part of the site doesn't use cookies.