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


PHP Drupal::linkGenerator方法代码示例

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


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

示例1: build

 /**
  * {@inheritdoc}
  */
 public function build(RouteMatchInterface $route_match)
 {
     $breadcrumb = array();
     $breadcrumb[] = $this->l($this->t('Home'), '<front>');
     $entity = $this->entityManager->getStorage($route_match->getParameter('entity_type'))->load($route_match->getParameter('entity_id'));
     $breadcrumb[] = \Drupal::linkGenerator()->generateFromUrl($entity->label(), $entity->urlInfo());
     return $breadcrumb;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:11,代码来源:CommentBreadcrumbBuilder.php

示例2: save

 /**
  * Overrides \Drupal\Core\Entity\EntityForm::save().
  */
 public function save(array $form, array &$form_state)
 {
     $block_type = $this->entity;
     $status = $block_type->save();
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label())));
         watchdog('block_content', 'Custom block type %label has been updated.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link);
     } else {
         drupal_set_message(t('Custom block type %label has been added.', array('%label' => $block_type->label())));
         watchdog('block_content', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, $edit_link);
     }
     $form_state['redirect_route']['route_name'] = 'block_content.type_list';
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:17,代码来源:BlockContentTypeForm.php

示例3: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, array &$form_state)
 {
     $comment_type = $this->entity;
     $status = $comment_type->save();
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('Comment type %label has been updated.', array('%label' => $comment_type->label())));
         $this->logger->notice('Comment type %label has been updated.', array('%label' => $comment_type->label(), 'link' => $edit_link));
     } else {
         drupal_set_message(t('Comment type %label has been added.', array('%label' => $comment_type->label())));
         $this->logger->notice('Comment type %label has been added.', array('%label' => $comment_type->label(), 'link' => $edit_link));
     }
     $form_state['redirect_route']['route_name'] = 'comment.type_list';
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:17,代码来源:CommentTypeForm.php

示例4: save

 /**
  * Overrides Drupal\Core\Entity\EntityForm::save().
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $newsletter = $this->entity;
     $status = $newsletter->save();
     $edit_link = \Drupal::linkGenerator()->generate($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('Newsletter %label has been updated.', array('%label' => $newsletter->label())));
         \Drupal::logger('simplenews')->notice('Newsletter %label has been updated.', array('%label' => $newsletter->label(), 'link' => $edit_link));
     } else {
         drupal_set_message(t('Newsletter %label has been added.', array('%label' => $newsletter->label())));
         \Drupal::logger('simplenews')->notice('Newsletter %label has been added.', array('%label' => $newsletter->label(), 'link' => $edit_link));
     }
     $form_state->setRedirect('simplenews.newsletter_list');
 }
开发者ID:aritnath1990,项目名称:simplenewslatest,代码行数:17,代码来源:NewsletterForm.php

示例5: save

 /**
  * Overrides \Drupal\Core\Entity\EntityForm::save().
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $block_type = $this->entity;
     $status = $block_type->save();
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     $logger = $this->logger('block_content');
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label())));
         $logger->notice('Custom block type %label has been updated.', array('%label' => $block_type->label(), 'link' => $edit_link));
     } else {
         drupal_set_message(t('Custom block type %label has been added.', array('%label' => $block_type->label())));
         $logger->notice('Custom block type %label has been added.', array('%label' => $block_type->label(), 'link' => $edit_link));
     }
     $form_state->setRedirect('block_content.type_list');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:18,代码来源:BlockContentTypeForm.php

示例6: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, array &$form_state)
 {
     $entity = $this->entity;
     // Prevent leading and trailing spaces in role names.
     $entity->set('label', trim($entity->label()));
     $status = $entity->save();
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message($this->t('Role %label has been updated.', array('%label' => $entity->label())));
         watchdog('user', 'Role %label has been updated.', array('%label' => $entity->label()), WATCHDOG_NOTICE, $edit_link);
     } else {
         drupal_set_message($this->t('Role %label has been added.', array('%label' => $entity->label())));
         watchdog('user', 'Role %label has been added.', array('%label' => $entity->label()), WATCHDOG_NOTICE, $edit_link);
     }
     $form_state['redirect_route']['route_name'] = 'user.role_list';
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:19,代码来源:RoleForm.php

示例7: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $entity = $this->entity;
     // Prevent leading and trailing spaces in role names.
     $entity->set('label', trim($entity->label()));
     $status = $entity->save();
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message($this->t('Role %label has been updated.', array('%label' => $entity->label())));
         $this->logger('user')->notice('Role %label has been updated.', array('%label' => $entity->label(), 'link' => $edit_link));
     } else {
         drupal_set_message($this->t('Role %label has been added.', array('%label' => $entity->label())));
         $this->logger('user')->notice('Role %label has been added.', array('%label' => $entity->label(), 'link' => $edit_link));
     }
     $form_state->setRedirect('user.role_list');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:19,代码来源:RoleForm.php

示例8: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, array &$form_state)
 {
     $category = $this->entity;
     $status = $category->save();
     $contact_settings = $this->config('contact.settings');
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message($this->t('Category %label has been updated.', array('%label' => $category->label())));
         watchdog('contact', 'Category %label has been updated.', array('%label' => $category->label()), WATCHDOG_NOTICE, $edit_link);
     } else {
         drupal_set_message($this->t('Category %label has been added.', array('%label' => $category->label())));
         watchdog('contact', 'Category %label has been added.', array('%label' => $category->label()), WATCHDOG_NOTICE, $edit_link);
     }
     // Update the default category.
     if ($form_state['values']['selected']) {
         $contact_settings->set('default_category', $category->id())->save();
     } elseif ($contact_settings->get('default_category') == $category->id()) {
         $contact_settings->set('default_category', NULL)->save();
     }
     $form_state['redirect_route']['route_name'] = 'contact.category_list';
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:24,代码来源:CategoryForm.php

示例9: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, FormStateInterface $form_state)
 {
     $category = $this->entity;
     $status = $category->save();
     $contact_settings = $this->config('contact.settings');
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message($this->t('Category %label has been updated.', array('%label' => $category->label())));
         $this->logger('contact')->notice('Category %label has been updated.', array('%label' => $category->label(), 'link' => $edit_link));
     } else {
         drupal_set_message($this->t('Category %label has been added.', array('%label' => $category->label())));
         $this->logger('contact')->notice('Category %label has been added.', array('%label' => $category->label(), 'link' => $edit_link));
     }
     // Update the default category.
     if ($form_state['values']['selected']) {
         $contact_settings->set('default_category', $category->id())->save();
     } elseif ($contact_settings->get('default_category') == $category->id()) {
         $contact_settings->set('default_category', NULL)->save();
     }
     $form_state->setRedirect('contact.category_list');
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:24,代码来源:CategoryForm.php

示例10: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, array &$form_state)
 {
     $menu = $this->entity;
     if (!$menu->isNew() || $menu->isLocked()) {
         $this->submitOverviewForm($form, $form_state);
     }
     $status = $menu->save();
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     if ($status == SAVED_UPDATED) {
         drupal_set_message(t('Menu %label has been updated.', array('%label' => $menu->label())));
         watchdog('menu', 'Menu %label has been updated.', array('%label' => $menu->label()), WATCHDOG_NOTICE, $edit_link);
     } else {
         drupal_set_message(t('Menu %label has been added.', array('%label' => $menu->label())));
         watchdog('menu', 'Menu %label has been added.', array('%label' => $menu->label()), WATCHDOG_NOTICE, $edit_link);
     }
     $form_state['redirect_route'] = $this->entity->urlInfo('edit-form');
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:20,代码来源:MenuForm.php

示例11: linkGenerator

 /**
  * Gets the link generator.
  *
  * @return \Drupal\Core\Utility\LinkGeneratorInterface
  */
 protected function linkGenerator()
 {
     if (!isset($this->linkGenerator)) {
         $this->linkGenerator = \Drupal::linkGenerator();
     }
     return $this->linkGenerator;
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:12,代码来源:FieldPluginBase.php

示例12: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $field)
 {
     if ($field->locked) {
         $row['class'] = array('menu-disabled');
         $row['data']['id'] = t('@field_name (Locked)', array('@field_name' => $field->name));
     } else {
         $row['data']['id'] = $field->name;
     }
     $field_type = $this->fieldTypes[$field->type];
     $row['data']['type'] = t('@type (module: @module)', array('@type' => $field_type['label'], '@module' => $field_type['provider']));
     $usage = array();
     foreach ($field->getBundles() as $bundle) {
         if ($route_info = FieldUI::getOverviewRouteInfo($field->entity_type, $bundle)) {
             $usage[] = \Drupal::linkGenerator()->generateFromUrl($this->bundles[$field->entity_type][$bundle]['label'], $route_info);
         } else {
             $usage[] = $this->bundles[$field->entity_type][$bundle]['label'];
         }
     }
     $usage_escaped = '';
     $separator = '';
     foreach ($usage as $usage_item) {
         $usage_escaped .= $separator . SafeMarkup::escape($usage_item);
         $separator = ', ';
     }
     $row['data']['usage'] = SafeMarkup::set($usage_escaped);
     return $row;
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:30,代码来源:FieldStorageConfigListBuilder.php

示例13: buildRow

 /**
  * {@inheritdoc}
  */
 public function buildRow(EntityInterface $entity)
 {
     $row['type'] = \Drupal::linkGenerator()->generateFromUrl($entity->label(), $entity->urlInfo());
     $row['description'] = Xss::filterAdmin($entity->description);
     return $row + parent::buildRow($entity);
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:9,代码来源:BlockContentTypeListBuilder.php

示例14: testLinkGenerator

 /**
  * Tests the linkGenerator() method.
  *
  * @covers ::linkGenerator
  */
 public function testLinkGenerator()
 {
     $this->setMockContainerService('link_generator');
     $this->assertNotNull(\Drupal::linkGenerator());
 }
开发者ID:dmyerson,项目名称:d8ecs,代码行数:10,代码来源:DrupalTest.php

示例15: save

 /**
  * {@inheritdoc}
  */
 public function save(array $form, array &$form_state)
 {
     $vocabulary = $this->entity;
     // Prevent leading and trailing spaces in vocabulary names.
     $vocabulary->name = trim($vocabulary->name);
     $status = $vocabulary->save();
     $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo());
     switch ($status) {
         case SAVED_NEW:
             drupal_set_message($this->t('Created new vocabulary %name.', array('%name' => $vocabulary->name)));
             watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, $edit_link);
             $form_state['redirect_route'] = $vocabulary->urlInfo('overview-form');
             break;
         case SAVED_UPDATED:
             drupal_set_message($this->t('Updated vocabulary %name.', array('%name' => $vocabulary->name)));
             watchdog('taxonomy', 'Updated vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, $edit_link);
             $form_state['redirect_route']['route_name'] = 'taxonomy.vocabulary_list';
             break;
     }
     $form_state['values']['vid'] = $vocabulary->id();
     $form_state['vid'] = $vocabulary->id();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:25,代码来源:VocabularyForm.php


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