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


PHP NodeInterface::getTranslation方法代码示例

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


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

示例1: createIndex

 /**
  * {@inheritdoc}
  */
 public function createIndex(NodeInterface $node)
 {
     $query = $this->database->insert('forum_index')->fields(array('nid', 'title', 'tid', 'sticky', 'created', 'comment_count', 'last_comment_timestamp'));
     foreach ($node->getTranslationLanguages() as $langcode => $language) {
         $translation = $node->getTranslation($langcode);
         foreach ($translation->taxonomy_forums as $item) {
             $query->values(array('nid' => $node->id(), 'title' => $translation->label(), 'tid' => $item->target_id, 'sticky' => (int) $node->isSticky(), 'created' => $node->getCreatedTime(), 'comment_count' => 0, 'last_comment_timestamp' => $node->getCreatedTime()));
         }
     }
     $query->execute();
     // The logic for determining last_comment_count is fairly complex, so
     // update the index too.
     if ($node->isNew()) {
         $this->updateIndex($node);
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:19,代码来源:ForumIndexStorage.php

示例2: prepareRevertedRevision

  /**
   * {@inheritdoc}
   */
  protected function prepareRevertedRevision(NodeInterface $revision, FormStateInterface $form_state) {
    $this->latestRevision = $this->latestRevision->getTranslation($this->langcode);

    return $this->prepareRevertedRevisionERFT($revision->getTranslation($this->langcode), $form_state);
  }
开发者ID:rmiessau,项目名称:sftest,代码行数:8,代码来源:NodeRevisionRevertTranslationForm.php

示例3: prepareRevertedRevision

 /**
  * {@inheritdoc}
  */
 protected function prepareRevertedRevision(NodeInterface $revision, FormStateInterface $form_state)
 {
     $revert_untranslated_fields = $form_state->getValue('revert_untranslated_fields');
     /** @var \Drupal\node\NodeInterface $default_revision */
     $latest_revision = $this->nodeStorage->load($revision->id());
     $latest_revision_translation = $latest_revision->getTranslation($this->langcode);
     $revision_translation = $revision->getTranslation($this->langcode);
     foreach ($latest_revision_translation->getFieldDefinitions() as $field_name => $definition) {
         if ($definition->isTranslatable() || $revert_untranslated_fields) {
             $latest_revision_translation->set($field_name, $revision_translation->get($field_name)->getValue());
         }
     }
     $latest_revision_translation->setNewRevision();
     $latest_revision_translation->isDefaultRevision(TRUE);
     return $latest_revision_translation;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:19,代码来源:NodeRevisionRevertTranslationForm.php

示例4: prepareRevertedRevision

 /**
  * Prepares a revision to be reverted.
  *
  * @param \Drupal\node\NodeInterface $revision
  *   The revision to be reverted.
  *
  * @return \Drupal\node\NodeInterface
  *   The prepared revision ready to be stored.
  */
 protected function prepareRevertedRevision(NodeInterface $revision)
 {
     /** @var \Drupal\node\NodeInterface $default_revision */
     $default_revision = $this->nodeStorage->load($revision->id());
     // If the entity is translated, make sure only translations affected by the
     // specified revision are reverted.
     $languages = $default_revision->getTranslationLanguages();
     if (count($languages) > 1) {
         // @todo Instead of processing all the available translations, we should
         //   let the user decide which translations should be reverted. See
         //   https://www.drupal.org/node/2465907.
         foreach ($languages as $langcode => $language) {
             if ($revision->hasTranslation($langcode) && !$revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
                 $revision_translation = $revision->getTranslation($langcode);
                 $default_translation = $default_revision->getTranslation($langcode);
                 foreach ($default_revision->getFieldDefinitions() as $field_name => $definition) {
                     if ($definition->isTranslatable()) {
                         $revision_translation->set($field_name, $default_translation->get($field_name)->getValue());
                     }
                 }
             }
         }
     }
     $revision->setNewRevision();
     $revision->isDefaultRevision(TRUE);
     return $revision;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:36,代码来源:NodeRevisionRevertForm.php


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