InvalidLinkTemplateException example

/** * {@inheritdoc} */
  public function processDefinition(&$definition$plugin_id) {
    /** @var \Drupal\Core\Entity\EntityTypeInterface $definition */
    parent::processDefinition($definition$plugin_id);

    // All link templates must have a leading slash.     foreach ((array) $definition->getLinkTemplates() as $link_relation_name => $link_template) {
      if ($link_template[0] != '/') {
        throw new InvalidLinkTemplateException("Link template '$link_relation_name' for entity type '$plugin_id' must start with a leading slash, the current link template is '$link_template'");
      }
    }
  }

  /** * {@inheritdoc} */
  protected function findDefinitions() {
    $definitions = $this->getDiscovery()->getDefinitions();
    $this->moduleHandler->invokeAllWith('entity_type_build', function Dcallable $hook, string $module) use (&$definitions) {
      $hook($definitions);
    });
Home | Imprint | This part of the site doesn't use cookies.