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


PHP Url::FromRoute方法代码示例

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


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

示例1: viewElements

 /**
  * {@inheritdoc}
  *
  * TODO: Use $langcode.
  */
 public function viewElements(FieldItemListInterface $items, $langcode)
 {
     $element = array();
     $settings = $this->getFieldSettings();
     $count = 0;
     // TODO: Is there a better way to get an accurate count of the
     // items from the FieldItemList that doesn't count blank items?
     // Possibly \Countable->count()?
     $storage = \Drupal::entityTypeManager()->getStorage('field_collection_item');
     foreach ($items as $delta => $item) {
         if ($item->value !== NULL) {
             $count++;
             $field_collection_item = $storage->loadRevision($item->revision_id);
             if ($field_collection_item->isDefaultRevision()) {
                 $links = \Drupal::l($this->fieldDefinition->getName() . ' ' . $delta, Url::FromRoute('entity.field_collection_item.canonical', array('field_collection_item' => $item->value)));
                 $links .= ' ' . $this->getEditLinks($item);
             } else {
                 $links = \Drupal::l($this->fieldDefinition->getName() . ' ' . $delta, Url::FromRoute('field_collection_item.revision_show', ['field_collection_item' => $item->value, 'field_collection_item_revision' => $item->revision_id]));
             }
             $element[$delta] = array('#markup' => $links);
         }
     }
     $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
     if ($cardinality == -1 || $count < $cardinality) {
         $element['#suffix'] = '<ul class="action-links action-links-field-collection-add"><li>';
         $element['#suffix'] .= $this->getAddLink($items->getEntity());
         $element['#suffix'] .= '</li></ul>';
     }
     return $element;
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:35,代码来源:FieldCollectionListFormatter.php

示例2: prepare

 /**
  * Setup archive directory and internal migrate data struct.
  *
  * @param array $environment
  *   Environment to migrate to, from NSPI acquia_agent_cloud_migration_environments()
  * @return array $migration
  */
 public function prepare($environment)
 {
     // Internal migration store is an array because objects cannot be stored
     // by Drupal's Batch API.
     $local_env = $this->checkEnv();
     if ($local_env['error'] !== FALSE) {
         return $local_env;
     }
     // Modify environment URL if SSL is available for use.
     if (in_array('ssl', stream_get_transports(), TRUE) && !defined('ACQUIA_DEVELOPMENT_NOSSL')) {
         $uri = parse_url($environment['url']);
         if (isset($uri['host'])) {
             $environment['url'] = $uri['host'];
         }
         $environment['url'] .= isset($uri['port']) ? ':' . $uri['port'] : '';
         $environment['url'] .= isset($uri['path']) && isset($uri['host']) ? $uri['path'] : '';
         $environment['url'] = 'https://' . $environment['url'];
     }
     $time = REQUEST_TIME;
     $date = gmdate('Ymd_his', $time);
     $migration = array('error' => FALSE, 'id' => uniqid() . '_' . $date, 'date' => $date, 'time' => $time, 'compression_ext' => $local_env['compression_ext'], 'request_params' => array('r' => Url::FromRoute('acquia_connector.settings', array(), array('absolute' => TRUE))->toString(), 'y' => 'sar', 'stage' => $environment['stage'], 'nonce' => $environment['nonce']), 'env' => $environment, 'no_data_tables' => array());
     // Set up local storage of archive.
     $this->destination($migration);
     return $migration;
 }
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:32,代码来源:Migration.php

示例3: getAddLink

 protected function getAddLink(ContentEntityInterface $host)
 {
     $link = '';
     if ($host->access('update', \Drupal::currentUser())) {
         $link = '<ul class="action-links action-links-field-collection-add"><li>';
         $link .= \Drupal::l(t('Add'), Url::FromRoute('field_collection_item.add_page', ['field_collection' => $this->fieldDefinition->getName(), 'host_type' => $host->getEntityTypeId(), 'host_id' => $host->id()]));
         $link .= '</li></ul>';
     }
     return $link;
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:10,代码来源:FieldCollectionLinksFormatter.php

示例4: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $filter = $form_state->getValue('name');
     $form_state->setRedirectUrl(Url::FromRoute('devel.configs_list', array('filter' => Html::escape($filter))));
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:8,代码来源:ConfigsList.php


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