當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。