You are here

protected function EntityExtraField::linkTemplates in Entity Extra Field 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/EntityExtraField.php \Drupal\entity_extra_field\Entity\EntityExtraField::linkTemplates()

Gets an array link templates.

Return value

array An array of link templates containing paths.

Overrides EntityBase::linkTemplates

File

src/Entity/EntityExtraField.php, line 413

Class

EntityExtraField
Define entity extra field.

Namespace

Drupal\entity_extra_field\Entity

Code

protected function linkTemplates() {
  $templates = [];
  $ui_base_path = $this
    ->getBaseEntityBundleUiPath();
  $entity_type = $this
    ->getEntityType();
  $entity_handlers = $entity_type
    ->getHandlerClasses();
  if (isset($entity_handlers['form'])) {
    foreach (array_keys($entity_handlers['form']) as $rel) {
      $template_path = "{$ui_base_path}/extra-fields";
      switch ($rel) {
        case 'add':
          $template_path = "{$template_path}/{$rel}";
          break;
        case 'edit':
        case 'delete':
          $template_path = "{$template_path}/{" . $entity_type
            ->id() . "}/{$rel}";
          break;
      }
      $templates[$rel . '-form'] = $template_path;
    }
  }
  $templates['collection'] = "{$ui_base_path}/extra-fields";
  return $templates;
}