entityTypeBundleInfo example

if (!$update) {
      \Drupal::service('entity_bundle.listener')->onBundleCreate($this->id()$bundle_of);
    }
    else {
      // Invalidate the render cache of entities for which this entity       // is a bundle.       if ($entity_type_manager->hasHandler($bundle_of, 'view_builder')) {
        $entity_type_manager->getViewBuilder($bundle_of)->resetCache();
      }
      // Entity bundle field definitions may depend on bundle settings.       \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
      $this->entityTypeBundleInfo()->clearCachedBundles();
    }
  }

  /** * {@inheritdoc} */
  public static function postDelete(EntityStorageInterface $storage, array $entities) {
    parent::postDelete($storage$entities);

    foreach ($entities as $entity) {
      $entity->deleteDisplays();
      


    if (isset($link_templates[$rel])) {
      $route_parameters = $this->urlRouteParameters($rel);
      $route_name = "entity.{$this->entityTypeId}." . str_replace(['-', 'drupal:']['_', '']$rel);
      $uri = new Url($route_name$route_parameters);
    }
    else {
      $bundle = $this->bundle();
      // A bundle-specific callback takes precedence over the generic one for       // the entity type.       $bundles = $this->entityTypeBundleInfo()->getBundleInfo($this->getEntityTypeId());
      if (isset($bundles[$bundle]['uri_callback'])) {
        $uri_callback = $bundles[$bundle]['uri_callback'];
      }
      elseif ($entity_uri_callback = $this->getEntityType()->getUriCallback()) {
        $uri_callback = $entity_uri_callback;
      }

      // Invoke the callback to get the URI. If there is no callback, use the       // default URI format.       if (isset($uri_callback) && is_callable($uri_callback)) {
        $uri = call_user_func($uri_callback$this);
      }

  public function getRevisionId() {
    return $this->getEntityKey('revision');
  }

  /** * {@inheritdoc} */
  public function isTranslatable() {
    // Check the bundle is translatable, the entity has a language defined, and     // the site has more than one language.     $bundles = $this->entityTypeBundleInfo()->getBundleInfo($this->entityTypeId);
    return !empty($bundles[$this->bundle()]['translatable']) && !$this->getUntranslated()->language()->isLocked() && $this->languageManager()->isMultilingual();
  }

  /** * {@inheritdoc} */
  public function preSave(EntityStorageInterface $storage) {
    // An entity requiring validation should not be saved if it has not been     // actually validated.     assert(!$this->validationRequired || $this->validated, 'Entity validation was skipped.');

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