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


PHP UrlGeneratorInterface::getPathFromRoute方法代码示例

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


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

示例1: getPathFromRoute

 /**
  * {@inheritdoc}
  */
 public function getPathFromRoute($name, $parameters = array())
 {
     return $this->urlGenerator->getPathFromRoute($name, $parameters);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:7,代码来源:MetadataBubblingUrlGenerator.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state)
 {
     $form['actions'] = array('#type' => 'actions');
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Import all'));
     $source_list = $this->sourceStorage->listAll();
     $storage_comparer = new StorageComparer($this->sourceStorage, $this->targetStorage, $this->configManager);
     if (empty($source_list) || !$storage_comparer->createChangelist()->hasChanges()) {
         $form['no_changes'] = array('#type' => 'table', '#header' => array('Name', 'Operations'), '#rows' => array(), '#empty' => $this->t('There are no configuration changes.'));
         $form['actions']['#access'] = FALSE;
         return $form;
     } elseif (!$storage_comparer->validateSiteUuid()) {
         drupal_set_message($this->t('The staged configuration cannot be imported, because it originates from a different site than this site. You can only synchronize configuration between cloned instances of this site.'), 'error');
         $form['actions']['#access'] = FALSE;
         return $form;
     } else {
         // Store the comparer for use in the submit.
         $form_state['storage_comparer'] = $storage_comparer;
     }
     // Add the AJAX library to the form for dialog support.
     $form['#attached']['library'][] = 'core/drupal.ajax';
     foreach ($storage_comparer->getAllCollectionNames() as $collection) {
         if ($collection != StorageInterface::DEFAULT_COLLECTION) {
             $form[$collection]['collection_heading'] = array('#type' => 'html_tag', '#tag' => 'h2', '#value' => $this->t('!collection configuration collection', array('!collection' => $collection)));
         }
         foreach ($storage_comparer->getChangelist(NULL, $collection) as $config_change_type => $config_names) {
             if (empty($config_names)) {
                 continue;
             }
             // @todo A table caption would be more appropriate, but does not have the
             //   visual importance of a heading.
             $form[$collection][$config_change_type]['heading'] = array('#type' => 'html_tag', '#tag' => 'h3');
             switch ($config_change_type) {
                 case 'create':
                     $form[$collection][$config_change_type]['heading']['#value'] = format_plural(count($config_names), '@count new', '@count new');
                     break;
                 case 'update':
                     $form[$collection][$config_change_type]['heading']['#value'] = format_plural(count($config_names), '@count changed', '@count changed');
                     break;
                 case 'delete':
                     $form[$collection][$config_change_type]['heading']['#value'] = format_plural(count($config_names), '@count removed', '@count removed');
                     break;
                 case 'rename':
                     $form[$collection][$config_change_type]['heading']['#value'] = format_plural(count($config_names), '@count renamed', '@count renamed');
                     break;
             }
             $form[$collection][$config_change_type]['list'] = array('#type' => 'table', '#header' => array('Name', 'Operations'));
             foreach ($config_names as $config_name) {
                 if ($config_change_type == 'rename') {
                     $names = $storage_comparer->extractRenameNames($config_name);
                     $route_options = array('source_name' => $names['old_name'], 'target_name' => $names['new_name']);
                     $config_name = $this->t('!source_name to !target_name', array('!source_name' => $names['old_name'], '!target_name' => $names['new_name']));
                 } else {
                     $route_options = array('source_name' => $config_name);
                 }
                 if ($collection != StorageInterface::DEFAULT_COLLECTION) {
                     $route_options['collection'] = $collection;
                     $href = $this->urlGenerator->getPathFromRoute('config.diff_collection', $route_options);
                 } else {
                     $href = $this->urlGenerator->getPathFromRoute('config.diff', $route_options);
                 }
                 $links['view_diff'] = array('title' => $this->t('View differences'), 'href' => $href, 'attributes' => array('class' => array('use-ajax'), 'data-accepts' => 'application/vnd.drupal-modal', 'data-dialog-options' => json_encode(array('width' => 700))));
                 $form[$collection][$config_change_type]['list']['#rows'][] = array('name' => $config_name, 'operations' => array('data' => array('#type' => 'operations', '#links' => $links)));
             }
         }
     }
     return $form;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:70,代码来源:ConfigSync.php


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