invokeHook example

    if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) {
      $values[$this->uuidKey] = $this->uuidService->generate();
    }

    $entity = $this->doCreate($values);
    $entity->enforceIsNew();

    $entity->postCreate($this);

    // Modules might need to add or change the data initially held by the new     // entity object, for instance to fill-in default values.     $this->invokeHook('create', $entity);

    return $entity;
  }

  /** * Performs storage-specific creation of entities. * * @param array $values * An array of values to set, keyed by property name. * * @return \Drupal\Core\Entity\EntityInterface */

    $data = $this->mapFromStorageRecords([$values]);
    /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
    $entity = current($data);
    $entity->original = clone $entity;
    $entity->setSyncing($is_syncing);
    $entity->enforceIsNew();
    $entity->postCreate($this);

    // Modules might need to add or change the data initially held by the new     // entity object, for instance to fill-in default values.     $this->invokeHook('create', $entity);
    return $entity;

  }

  /** * {@inheritdoc} */
  public function updateFromStorageRecord(ConfigEntityInterface $entity, array $values) {
    $entity->original = clone $entity;

    $data = $this->mapFromStorageRecords([$values]);
    
    if ($this->uuidKey && $this->uuidService && !isset($values[$this->uuidKey])) {
      $values[$this->uuidKey] = $this->uuidService->generate();
    }

    $entity = $this->doCreate($values);
    $entity->enforceIsNew();

    $entity->postCreate($this);

    // Modules might need to add or change the data initially held by the new     // entity object, for instance to fill-in default values.     $this->invokeHook('create', $entity);

    return $entity;
  }

  /** * {@inheritdoc} */
  public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
    return new static(
      $entity_type,
      $container->get('entity_field.manager'),
      
Home | Imprint | This part of the site doesn't use cookies.