当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityTypeInterface::hasLinkTemplate方法代码示例

本文整理汇总了PHP中Drupal\Core\Entity\EntityTypeInterface::hasLinkTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityTypeInterface::hasLinkTemplate方法的具体用法?PHP EntityTypeInterface::hasLinkTemplate怎么用?PHP EntityTypeInterface::hasLinkTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Entity\EntityTypeInterface的用法示例。


在下文中一共展示了EntityTypeInterface::hasLinkTemplate方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getModerationFormRoute

 /**
  * Gets the moderation-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getModerationFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('moderation-form') && $entity_type->getFormClass('moderation')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('moderation-form'));
         $route->setDefaults(['_entity_form' => "{$entity_type_id}.moderation", '_title' => 'Moderation'])->setRequirement('_permission', 'administer moderation states')->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]);
         return $route;
     }
 }
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:18,代码来源:EntityTypeModerationRouteProvider.php

示例2: deleteMultipleFormRoute

 /**
  * Returns the delete multiple form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function deleteMultipleFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('delete-multiple-form')) {
         $route = new Route($entity_type->getLinkTemplate('delete-multiple-form'));
         $route->setDefault('_form', '\\Drupal\\entity\\Form\\DeleteMultiple');
         $route->setDefault('entity_type_id', $entity_type->id());
         $route->setRequirement('_permission', $entity_type->getAdminPermission());
         return $route;
     }
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:19,代码来源:DeleteMultipleRouteProvider.php

示例3: addFormRoute

 /**
  * Returns the add form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function addFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('add-form')) {
         $route = new Route($entity_type->getLinkTemplate('add-form'));
         $route->setDefault('_controller', '\\Drupal\\entity\\Controller\\EntityCreateController::addForm');
         $route->setDefault('_title_callback', '\\Drupal\\entity\\Controller\\EntityCreateController::addFormTitle');
         $route->setDefault('entity_type_id', $entity_type->id());
         $route->setRequirement('_entity_create_access', $entity_type->id());
         return $route;
     }
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:20,代码来源:CreateHtmlRouteProvider.php

示例4: getRevisionViewRoute

 /**
  * Gets the entity revision view route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getRevisionViewRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('revision')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('revision'));
         $route->addDefaults(['_controller' => '\\Drupal\\entity\\Controller\\RevisionController::view', '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title']);
         $route->addRequirements(['_entity_access_revision' => "{$entity_type_id}.view"]);
         $route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()], $entity_type->id() . '_revision' => ['type' => 'entity_revision:' . $entity_type->id()]]);
         return $route;
     }
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:20,代码来源:RevisionRouteProvider.php

示例5: entityFormDeleteTranslation

 /**
  * Form submission handler for ContentTranslationHandler::entityFormAlter().
  *
  * Takes care of content translation deletion.
  */
 function entityFormDeleteTranslation($form, FormStateInterface $form_state)
 {
     /** @var \Drupal\Core\Entity\ContentEntityFormInterface $form_object */
     $form_object = $form_state->getFormObject();
     /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
     $entity = $form_object->getEntity();
     $entity_type_id = $entity->getEntityTypeId();
     if ($entity->access('delete') && $this->entityType->hasLinkTemplate('delete-form')) {
         $form_state->setRedirectUrl($entity->urlInfo('delete-form'));
     } else {
         $form_state->setRedirect('content_translation.translation_delete_' . $entity_type_id, [$entity_type_id => $entity->id(), 'language' => $form_object->getFormLangcode($form_state)]);
     }
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:18,代码来源:ContentTranslationHandler.php

示例6: getLatestVersionRoute

 /**
  * Gets the moderation-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getLatestVersionRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('latest-version') && $entity_type->hasViewBuilderClass()) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('latest-version'));
         $route->addDefaults(['_entity_view' => "{$entity_type_id}.full", '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title'])->setRequirement('_entity_access', "{$entity_type_id}.view")->setRequirement('_permission', 'view latest version,view any unpublished content')->setRequirement('_content_moderation_latest_version', 'TRUE')->setOption('_content_moderation_entity_type', $entity_type_id)->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id, 'load_forward_revision' => 1]]);
         // Entity types with serial IDs can specify this in their route
         // requirements, improving the matching process.
         if ($this->getEntityTypeIdKeyType($entity_type) === 'integer') {
             $route->setRequirement($entity_type_id, '\\d+');
         }
         return $route;
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:23,代码来源:EntityModerationRouteProvider.php

示例7: getAddFormRoute

 /**
  * Gets the add-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getAddFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('add-form')) {
         $entity_type_id = $entity_type->id();
         $parameters = [$entity_type_id => ['type' => 'entity:' . $entity_type_id]];
         $route = new Route($entity_type->getLinkTemplate('add-form'));
         $bundle_entity_type_id = $entity_type->getBundleEntityType();
         // Content entities with bundles are added via a dedicated controller.
         $route->setDefaults(['_controller' => 'Drupal\\drupalbristol_sponsors\\Controller\\SponsorEntityAddController::addForm', '_title_callback' => 'Drupal\\drupalbristol_sponsors\\Controller\\SponsorEntityAddController::getAddFormTitle'])->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}');
         $parameters[$bundle_entity_type_id] = ['type' => 'entity:' . $bundle_entity_type_id];
         $route->setOption('parameters', $parameters)->setOption('_admin_route', TRUE);
         return $route;
     }
 }
开发者ID:drupalbristol,项目名称:drupal-bristol-website,代码行数:23,代码来源:SponsorEntityHtmlRouteProvider.php

示例8: addEntityLinks

 /**
  * Sets the entity links in case corresponding link templates exist.
  *
  * @param array $data
  *   The views data of the base table.
  */
 protected function addEntityLinks(array &$data)
 {
     $entity_type_id = $this->entityType->id();
     $t_arguments = ['@entity_type_label' => $this->entityType->getLabel()];
     if ($this->entityType->hasLinkTemplate('canonical')) {
         $data['view_' . $entity_type_id] = ['field' => ['title' => $this->t('Link to @entity_type_label', $t_arguments), 'help' => $this->t('Provide a view link to the @entity_type_label.', $t_arguments), 'id' => 'entity_link']];
     }
     if ($this->entityType->hasLinkTemplate('edit-form')) {
         $data['edit_' . $entity_type_id] = ['field' => ['title' => $this->t('Link to edit @entity_type_label', $t_arguments), 'help' => $this->t('Provide an edit link to the @entity_type_label.', $t_arguments), 'id' => 'entity_link_edit']];
     }
     if ($this->entityType->hasLinkTemplate('delete-form')) {
         $data['delete_' . $entity_type_id] = ['field' => ['title' => $this->t('Link to delete @entity_type_label', $t_arguments), 'help' => $this->t('Provide a delete link to the @entity_type_label.', $t_arguments), 'id' => 'entity_link_delete']];
     }
 }
开发者ID:vinodpanicker,项目名称:drupal-under-the-hood,代码行数:20,代码来源:EntityViewsData.php

示例9: getAddFormRoute

 /**
  * Gets the add-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getAddFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('add-form')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('add-form'));
         // Use the add form handler, if available, otherwise default.
         $operation = 'default';
         if ($entity_type->getFormClass('add')) {
             $operation = 'add';
         }
         $route->setDefaults(['_entity_form' => "{$entity_type_id}.{$operation}", '_title' => "Add {$entity_type->getLabel()}"])->setRequirement('_entity_create_access', $entity_type_id)->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]])->setOption('_admin_route', TRUE);
         return $route;
     }
 }
开发者ID:drupalbristol,项目名称:drupal-bristol-website,代码行数:23,代码来源:SponsorEntityTypeHtmlRouteProvider.php

示例10: getAddFormRoute

 /**
  * Gets the add-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getAddFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('add-form')) {
         $entity_type_id = $entity_type->id();
         $parameters = [$entity_type_id => ['type' => 'entity:' . $entity_type_id]];
         $route = new Route($entity_type->getLinkTemplate('add-form'));
         // Content entities with bundles are added via a dedicated controller.
         if ($bundle_entity_type_id = $entity_type->getBundleEntityType()) {
             $route->setDefaults(['_controller' => 'Drupal\\custom_page\\Controller\\CustomPageAddController::addForm', '_title_callback' => 'Drupal\\custom_page\\Controller\\CustomPageAddController::getAddFormTitle'])->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}');
             $parameters[$bundle_entity_type_id] = ['type' => 'entity:' . $bundle_entity_type_id];
         } else {
             // Use the add form handler, if available, otherwise default.
             $operation = 'default';
             if ($entity_type->getFormClass('add')) {
                 $operation = 'add';
             }
             $route->setDefaults(['_entity_form' => "{$entity_type_id}.{$operation}", '_title' => "Add {$entity_type->getLabel()}"])->setRequirement('_entity_create_access', $entity_type_id);
         }
         $route->setOption('parameters', $parameters)->setOption('_admin_route', TRUE);
         return $route;
     }
 }
开发者ID:poetic,项目名称:clutch,代码行数:31,代码来源:CustomPageHtmlRouteProvider.php

示例11: getDeleteFormRoute

 /**
  * Gets the delete-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getDeleteFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('delete-form')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('delete-form'));
         $route->addDefaults(['_entity_form' => "{$entity_type_id}.delete", '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::deleteTitle'])->setRequirement('_entity_access', "{$entity_type_id}.delete")->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]);
         // Entity types with serial IDs can specify this in their route
         // requirements, improving the matching process.
         if ($this->getEntityTypeIdKeyType($entity_type) === 'integer') {
             $route->setRequirement($entity_type_id, '\\d+');
         }
         return $route;
     }
 }
开发者ID:318io,项目名称:318-io,代码行数:23,代码来源:DefaultHtmlRouteProvider.php

示例12: getDeleteFormRoute

 /**
  * Gets the delete-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getDeleteFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('delete-form')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('delete-form'));
         $route->addDefaults(['_entity_form' => "{$entity_type_id}.delete", '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::deleteTitle'])->setRequirement('_entity_access', "{$entity_type_id}.delete")->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]);
         return $route;
     }
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:18,代码来源:DefaultHtmlRouteProvider.php

示例13: getRevisionHistoryRoute

 /**
  * Gets the entity revision version history route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getRevisionHistoryRoute($entity_type)
 {
     if ($entity_type->hasLinkTemplate('version-history')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('version-history'));
         $route->addDefaults(['_controller' => '\\Drupal\\entity\\Controller\\RevisionOverviewController::revisionOverviewController', '_title' => 'Revisions']);
         $route->setRequirement('_entity_access_revision', "{$entity_type_id}.list");
         $route->setOption('entity_type_id', $entity_type->id());
         $route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()]]);
         return $route;
     }
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:21,代码来源:RevisionRouteProvider.php

示例14: getCollectionRoute

 /**
  * Gets the collection route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getCollectionRoute(EntityTypeInterface $entity_type)
 {
     // If the entity type does not provide an admin permission, there is no way
     // to control access, so we cannot provide a route in a sensible way.
     if ($entity_type->hasLinkTemplate('collection') && $entity_type->hasListBuilderClass() && ($admin_permission = $entity_type->getAdminPermission())) {
         $route = new Route($entity_type->getLinkTemplate('collection'));
         $route->addDefaults(['_entity_list' => $entity_type->id(), '_title' => '@label entities', '_title_arguments' => ['@label' => $entity_type->getLabel()]])->setRequirement('_permission', $admin_permission);
         return $route;
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:19,代码来源:DefaultHtmlRouteProvider.php


注:本文中的Drupal\Core\Entity\EntityTypeInterface::hasLinkTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。