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


PHP LanguageManagerInterface::getLanguageName方法代码示例

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


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

示例1: getQuestion

 /**
  * {@inheritdoc}
  */
 public function getQuestion()
 {
     return t('Are you sure you want to revert @language translation to the revision from %revision-date?', ['@language' => $this->languageManager->getLanguageName($this->langcode), '%revision-date' => $this->dateFormatter->format($this->revision->getRevisionCreationTime())]);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:7,代码来源:NodeRevisionRevertTranslationForm.php

示例2: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $node = NULL)
 {
     $account = $this->currentUser;
     $langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId();
     $langname = $this->languageManager->getLanguageName($langcode);
     $languages = $node->getTranslationLanguages();
     $has_translations = count($languages) > 1;
     $node_storage = $this->entityManager->getStorage('node');
     $type = $node->getType();
     $vids = array_reverse($node_storage->revisionIds($node));
     $revision_count = count($vids);
     $build['#title'] = $has_translations ? $this->t('@langname revisions for %title', ['@langname' => $langname, '%title' => $node->label()]) : $this->t('Revisions for %title', ['%title' => $node->label()]);
     $build['nid'] = array('#type' => 'hidden', '#value' => $node->id());
     $table_header = array('revision' => $this->t('Revision'), 'operations' => $this->t('Operations'));
     // Allow comparisons only if there are 2 or more revisions.
     if ($revision_count > 1) {
         $table_header += array('select_column_one' => '', 'select_column_two' => '');
     }
     $rev_revert_perm = $account->hasPermission("revert {$type} revisions") || $account->hasPermission('revert all revisions') || $account->hasPermission('administer nodes');
     $rev_delete_perm = $account->hasPermission("delete {$type} revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes');
     $revert_permission = $rev_revert_perm && $node->access('update');
     $delete_permission = $rev_delete_perm && $node->access('delete');
     // Contains the table listing the revisions.
     $build['node_revisions_table'] = array('#type' => 'table', '#header' => $table_header, '#attributes' => array('class' => array('diff-revisions')));
     $build['node_revisions_table']['#attached']['library'][] = 'diff/diff.general';
     $build['node_revisions_table']['#attached']['drupalSettings']['diffRevisionRadios'] = $this->config->get('general_settings.radio_behavior');
     $latest_revision = TRUE;
     // Add rows to the table.
     foreach ($vids as $vid) {
         if ($revision = $node_storage->loadRevision($vid)) {
             if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
                 $username = array('#theme' => 'username', '#account' => $revision->getRevisionAuthor());
                 $revision_date = $this->date->format($revision->getRevisionCreationTime(), 'short');
                 // Use revision link to link to revisions that are not active.
                 if ($vid != $node->getRevisionId()) {
                     $link = $this->l($revision_date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid]));
                 } else {
                     $link = $node->link($revision_date);
                 }
                 // Default revision.
                 if ($latest_revision) {
                     $row = array('revision' => array('#type' => 'inline_template', '#template' => '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}', '#context' => ['date' => $link, 'username' => $this->renderer->renderPlain($username), 'message' => ['#markup' => $revision->revision_log->value, '#allowed_tags' => Xss::getHtmlTagList()]]));
                     // Allow comparisons only if there are 2 or more revisions.
                     if ($revision_count > 1) {
                         $row += array('select_column_one' => array('#type' => 'radio', '#title_display' => 'invisible', '#name' => 'radios_left', '#return_value' => $vid, '#default_value' => FALSE), 'select_column_two' => array('#type' => 'radio', '#title_display' => 'invisible', '#name' => 'radios_right', '#default_value' => $vid, '#return_value' => $vid));
                     }
                     $row['operations'] = array('#prefix' => '<em>', '#markup' => $this->t('Current revision'), '#suffix' => '</em>', '#attributes' => array('class' => array('revision-current')));
                     $latest_revision = FALSE;
                 } else {
                     $route_params = array('node' => $node->id(), 'node_revision' => $vid, 'langcode' => $langcode);
                     $links = array();
                     if ($revert_permission) {
                         $links['revert'] = ['title' => $this->t('Revert'), 'url' => $has_translations ? Url::fromRoute('node.revision_revert_translation_confirm', ['node' => $node->id(), 'node_revision' => $vid, 'langcode' => $langcode]) : Url::fromRoute('node.revision_revert_confirm', ['node' => $node->id(), 'node_revision' => $vid])];
                     }
                     if ($delete_permission) {
                         $links['delete'] = array('title' => $this->t('Delete'), 'url' => Url::fromRoute('node.revision_delete_confirm', $route_params));
                     }
                     // Here we don't have to deal with 'only one revision' case because
                     // if there's only one revision it will also be the default one,
                     // entering on the first branch of this if else statement.
                     $row = array('revision' => array('#type' => 'inline_template', '#template' => '{% trans %}{{ date }} by {{ username }}{% endtrans %}{% if message %}<p class="revision-log">{{ message }}</p>{% endif %}', '#context' => ['date' => $link, 'username' => $this->renderer->renderPlain($username), 'message' => ['#markup' => $revision->revision_log->value, '#allowed_tags' => Xss::getHtmlTagList()]]), 'select_column_one' => array('#type' => 'radio', '#title_display' => 'invisible', '#name' => 'radios_left', '#return_value' => $vid, '#default_value' => isset($vids[1]) ? $vids[1] : FALSE), 'select_column_two' => array('#type' => 'radio', '#title_display' => 'invisible', '#name' => 'radios_right', '#return_value' => $vid, '#default_value' => FALSE), 'operations' => array('#type' => 'operations', '#links' => $links));
                 }
                 // Add the row to the table.
                 $build['node_revisions_table'][] = $row;
             }
         }
     }
     // Allow comparisons only if there are 2 or more revisions.
     if ($revision_count > 1) {
         $build['submit'] = array('#type' => 'submit', '#value' => t('Compare'), '#attributes' => array('class' => array('diff-button')));
     }
     return $build;
 }
开发者ID:sedurzu,项目名称:ildeposito8,代码行数:76,代码来源:RevisionOverviewForm.php


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