urlRouteParameters example

// The links array might contain URI templates set in annotations.     $link_templates = $this->linkTemplates();

    // Links pointing to the current revision point to the actual entity. So     // instead of using the 'revision' link, use the 'canonical' link.     if ($rel === 'revision' && $this instanceof RevisionableInterface && $this->isDefaultRevision()) {
      $rel = 'canonical';
    }

    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'];
      }
      
if (isset($link_templates['config-translation-overview'])) {
        $link_templates["config-translation-overview.{$this->entity_type}"] = "entity.field_config.config_translation_overview.{$this->entity_type}";
      }
    }
    return $link_templates;
  }

  /** * {@inheritdoc} */
  protected function urlRouteParameters($rel) {
    $parameters = parent::urlRouteParameters($rel);
    $entity_type = \Drupal::entityTypeManager()->getDefinition($this->entity_type);
    $bundle_parameter_key = $entity_type->getBundleEntityType() ?: 'bundle';
    $parameters[$bundle_parameter_key] = $this->bundle;
    return $parameters;
  }

  /** * {@inheritdoc} */
  public function isDeleted() {
    return $this->deleted;
  }

  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage$entities);
    \Drupal::service('entity_field.manager')->clearCachedFieldDefinitions();
  }

  /** * {@inheritdoc} */
  protected function urlRouteParameters($rel) {
    $uri_route_parameters = parent::urlRouteParameters($rel);
    if ($rel === 'add-form') {
      $uri_route_parameters['entity_type_id'] = $this->getTargetType();
    }

    return $uri_route_parameters;
  }

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