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


PHP EntityInterface::hasLinkTemplate方法代码示例

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


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

示例1: actions

 /**
  * Returns an array of supported actions for the current entity form.
  *
  * @todo Consider introducing a 'preview' action here, since it is used by
  *   many entity types.
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     // @todo Rename the action key from submit to save.
     $actions['submit'] = array('#type' => 'submit', '#value' => $this->t('Save'), '#validate' => array(array($this, 'validate')), '#submit' => array(array($this, 'submit'), array($this, 'save')));
     if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('delete-form')) {
         $route_info = $this->entity->urlInfo('delete-form');
         if ($this->getRequest()->query->has('destination')) {
             $query = $route_info->getOption('query');
             $query['destination'] = $this->getRequest()->query->get('destination');
             $route_info->setOption('query', $query);
         }
         $actions['delete'] = array('#type' => 'link', '#title' => $this->t('Delete'), '#access' => $this->entity->access('delete'), '#attributes' => array('class' => array('button', 'button--danger')));
         $actions['delete'] += $route_info->toRenderArray();
     }
     return $actions;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:22,代码来源:EntityForm.php

示例2: actions

 /**
  * Returns an array of supported actions for the current entity form.
  *
  * @todo Consider introducing a 'preview' action here, since it is used by
  *   many entity types.
  */
 protected function actions(array $form, FormStateInterface $form_state)
 {
     // @todo Consider renaming the action key from submit to save. The impacts
     //   are hard to predict. For example, see
     //   \Drupal\language\Element\LanguageConfiguration::processLanguageConfiguration().
     $actions['submit'] = array('#type' => 'submit', '#value' => $this->t('Save'), '#validate' => array('::validate'), '#submit' => array('::submitForm', '::save'));
     if (!$this->entity->isNew() && $this->entity->hasLinkTemplate('delete-form')) {
         $route_info = $this->entity->urlInfo('delete-form');
         if ($this->getRequest()->query->has('destination')) {
             $query = $route_info->getOption('query');
             $query['destination'] = $this->getRequest()->query->get('destination');
             $route_info->setOption('query', $query);
         }
         $actions['delete'] = array('#type' => 'link', '#title' => $this->t('Delete'), '#access' => $this->entity->access('delete'), '#attributes' => array('class' => array('button', 'button--danger')));
         $actions['delete']['#url'] = $route_info;
     }
     return $actions;
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:24,代码来源:EntityForm.php

示例3: buildDeleteRevisionLink

 /**
  * {@inheritdoc}
  */
 protected function buildDeleteRevisionLink(EntityInterface $entity_revision)
 {
     if ($entity_revision->hasLinkTemplate('revision-delete')) {
         return ['title' => t('Delete'), 'url' => $entity_revision->toUrl('revision-delete')];
     }
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:9,代码来源:RevisionOverviewController.php

示例4: getEntityUri

 /**
  * Constructs the entity URI.
  *
  * @param \Drupal\Core\Entity\EntityInterface
  *   The entity.
  * @return string
  *   The entity URI.
  */
 protected function getEntityUri(EntityInterface $entity)
 {
     // Some entity types don't provide a canonical link template, at least call
     // out to ->url().
     if ($entity->isNew() || !$entity->hasLinkTemplate('canonical')) {
         return $entity->url('canonical', []);
     }
     $url = $entity->urlInfo('canonical', ['absolute' => TRUE]);
     return $url->setRouteParameter('_format', 'hal_json')->toString();
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:18,代码来源:ContentEntityNormalizer.php

示例5: getReadUrl

 /**
  * Gets the read URL object for the entity.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity to get the URL for.
  * @param string $format
  *   The format to request the entity in.
  * @param string $entity_id
  *   The entity ID to use in the URL, defaults to the entity's ID if know
  *   given.
  *
  * @return \Drupal\Core\Url
  *   The Url object.
  */
 protected function getReadUrl(EntityInterface $entity, $format = NULL, $entity_id = NULL)
 {
     if (!$format) {
         $format = $this->defaultFormat;
     }
     if (!$entity_id) {
         $entity_id = $entity->id();
     }
     $entity_type = $entity->getEntityTypeId();
     if ($entity->hasLinkTemplate('canonical')) {
         $url = $entity->toUrl('canonical');
     } else {
         $route_name = 'rest.entity.' . $entity_type . ".GET.";
         // If testing unsupported format don't use the format to construct route
         // name. This would give a RouteNotFoundException.
         if ($format == 'wrongformat') {
             $route_name .= $this->defaultFormat;
         } else {
             $route_name .= $format;
         }
         $url = Url::fromRoute($route_name);
     }
     $url->setRouteParameter($entity_type, $entity_id);
     $url->setRouteParameter('_format', $format);
     return $url;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:40,代码来源:ReadTest.php

示例6: getDefaultOperations

 /**
  * Gets this list's default operations.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity the operations are for.
  *
  * @return array
  *   The array structure is identical to the return value of
  *   self::getOperations().
  */
 protected function getDefaultOperations(EntityInterface $entity)
 {
     $operations = array();
     if ($entity->access('update') && $entity->hasLinkTemplate('edit-form')) {
         $operations['edit'] = array('title' => $this->t('Edit'), 'weight' => 10, 'url' => $entity->urlInfo('edit-form'));
     }
     if ($entity->access('delete') && $entity->hasLinkTemplate('delete-form')) {
         $operations['delete'] = array('title' => $this->t('Delete'), 'weight' => 100, 'url' => $entity->urlInfo('delete-form'));
     }
     return $operations;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:21,代码来源:EntityListBuilder.php


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