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


PHP NodeInterface::setNewRevision方法代码示例

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


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

示例1: createNodeRevision

 /**
  * Creates a new revision for a given node.
  *
  * @param \Drupal\node\NodeInterface $node
  *   A node object.
  *
  * @return \Drupal\node\NodeInterface
  *   A node object with up to date revision information.
  */
 protected function createNodeRevision(NodeInterface $node)
 {
     // Create revision with a random title and body and update variables.
     $node->title = $this->randomMachineName();
     $node->body = array('value' => $this->randomMachineName(32), 'format' => filter_default_format());
     $node->setNewRevision();
     $node->save();
     return $node;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:18,代码来源:NodeRevisionsAllTest.php

示例2: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, array &$form_state)
 {
     $this->revision->setNewRevision();
     // Make this the new default revision for the node.
     $this->revision->isDefaultRevision(TRUE);
     // The revision timestamp will be updated when the revision is saved. Keep the
     // original one for the confirmation message.
     $original_revision_timestamp = $this->revision->getRevisionCreationTime();
     $this->revision->revision_log = t('Copy of the revision from %date.', array('%date' => format_date($original_revision_timestamp)));
     $this->revision->save();
     watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
     drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => format_date($original_revision_timestamp))));
     $form_state['redirect_route'] = array('route_name' => 'node.revision_overview', 'route_parameters' => array('node' => $this->revision->id()));
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:17,代码来源:NodeRevisionRevertForm.php

示例3: submitForm

 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $this->revision->setNewRevision();
     // Make this the new default revision for the node.
     $this->revision->isDefaultRevision(TRUE);
     // The revision timestamp will be updated when the revision is saved. Keep the
     // original one for the confirmation message.
     $original_revision_timestamp = $this->revision->getRevisionCreationTime();
     $this->revision->revision_log = t('Copy of the revision from %date.', array('%date' => format_date($original_revision_timestamp)));
     $this->revision->save();
     $this->logger('content')->notice('@type: reverted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()));
     drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', array('@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => format_date($original_revision_timestamp))));
     $form_state->setRedirect('entity.node.version_history', array('node' => $this->revision->id()));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:17,代码来源:NodeRevisionRevertForm.php

示例4: createRevisions

 /**
  * Creates a series of revisions for the specified node.
  *
  * @param \Drupal\node\NodeInterface $node
  *   The node object.
  * @param $count
  *   The number of revisions to be created.
  */
 protected function createRevisions(NodeInterface $node, $count)
 {
     for ($i = 0; $i < $count; $i++) {
         $node->title = $this->randomString();
         $node->untranslatable_string_field->value = $this->randomString();
         $node->setNewRevision(TRUE);
         $node->save();
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:17,代码来源:NodeRevisionsTest.php

示例5: prepareRevertedRevision

 /**
  * Prepares a revision to be reverted.
  *
  * @param \Drupal\node\NodeInterface $revision
  *   The revision to be reverted.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  *
  * @return \Drupal\node\NodeInterface
  *   The prepared revision ready to be stored.
  */
 protected function prepareRevertedRevision(NodeInterface $revision, FormStateInterface $form_state)
 {
     $revision->setNewRevision();
     $revision->isDefaultRevision(TRUE);
     return $revision;
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:17,代码来源:NodeRevisionRevertForm.php

示例6: createRevisions

  /**
   * Creates a series of revisions for the specified node.
   *
   * @param \Drupal\node\NodeInterface $node
   *   The node object.
   * @param $count
   *   The number of revisions to be created.
   */
  protected function createRevisions(NodeInterface $node, $count) {
    for ($i = 0; $i < $count; $i++) {
      $node->title = $this->randomString();
      $node->body = [
        'value' => $this->randomMachineName(32),
        'format' => filter_default_format(),
      ];
      $node->untranslatable_string_field->value = $this->randomString();
      $node->setNewRevision(TRUE);
      $node->save();
    }

  }
开发者ID:rmiessau,项目名称:sftest,代码行数:21,代码来源:RevisionUiNodeTest.php

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