コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, array &$form_state, $node_revision = NULL)
 {
     $this->revision = $this->nodeStorage->loadRevision($node_revision);
     $form = parent::buildForm($form, $form_state);
     // @todo Convert to getCancelRoute() after http://drupal.org/node/1863906.
     $form['actions']['cancel']['#href'] = 'node/' . $this->revision->id() . '/revisions';
     return $form;
 }
コード例 #2
0
 /**
  * Checks routing access for the node revision.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  * @param int $node_revision
  *   (optional) The node revision ID. If not specified, but $node is, access
  *   is checked for that object's revision.
  * @param \Drupal\node\NodeInterface $node
  *   (optional) A node object. Used for checking access to a node's default
  *   revision when $node_revision is unspecified. Ignored when $node_revision
  *   is specified. If neither $node_revision nor $node are specified, then
  *   access is denied.
  *
  * @return string
  *   A \Drupal\Core\Access\AccessInterface constant value.
  */
 public function access(Route $route, AccountInterface $account, $node_revision = NULL, NodeInterface $node = NULL)
 {
     if ($node_revision) {
         $node = $this->nodeStorage->loadRevision($node_revision);
     }
     $operation = $route->getRequirement('_access_node_revision');
     return $node && $this->checkAccess($node, $account, $operation) ? static::ALLOW : static::DENY;
 }
コード例 #3
0
 /**
  * Checks routing access for the node revision.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  * @param int $node_revision
  *   (optional) The node revision ID. If not specified, but $node is, access
  *   is checked for that object's revision.
  * @param \Drupal\node\NodeInterface $node
  *   (optional) A node object. Used for checking access to a node's default
  *   revision when $node_revision is unspecified. Ignored when $node_revision
  *   is specified. If neither $node_revision nor $node are specified, then
  *   access is denied.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, AccountInterface $account, $node_revision = NULL, NodeInterface $node = NULL)
 {
     if ($node_revision) {
         $node = $this->nodeStorage->loadRevision($node_revision);
     }
     $operation = $route->getRequirement('_access_node_revision');
     return AccessResult::allowedIf($node && $this->checkAccess($node, $account, $operation))->cachePerRole();
 }
コード例 #4
0
ファイル: EntityRevisionTest.php プロジェクト: aWEBoLabs/taxi
 /**
  * Test that revision updates update.
  *
  * @covers ::getEntity
  */
 public function testGetEntityUpdateRevision()
 {
     $destination = $this->getEntityRevisionDestination([]);
     $entity = $this->prophesize('\\Drupal\\Core\\Entity\\EntityInterface')->willImplement('\\Drupal\\Core\\Entity\\RevisionableInterface');
     $entity_type = $this->prophesize('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $entity_type->getKey('id')->willReturn('nid');
     $entity_type->getKey('revision')->willReturn('vid');
     $this->storage->getEntityType()->willReturn($entity_type->reveal());
     // Assert we load the correct revision.
     $this->storage->loadRevision(2)->shouldBeCalled()->willReturn($entity->reveal());
     // Make sure its set as an update and not the default revision.
     $entity->setNewRevision(FALSE)->shouldBeCalled();
     $entity->isDefaultRevision(FALSE)->shouldBeCalled();
     $row = new Row(['nid' => 1, 'vid' => 2], ['nid' => 1, 'vid' => 2]);
     $row->setDestinationProperty('vid', 2);
     $this->assertEquals($entity->reveal(), $destination->getEntity($row, []));
 }
コード例 #5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $node_revision = NULL)
 {
     $this->revision = $this->nodeStorage->loadRevision($node_revision);
     $form = parent::buildForm($form, $form_state);
     return $form;
 }
コード例 #6
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, $support_ticket_revision = NULL)
 {
     $this->revision = $this->supportTicketStorage->loadRevision($support_ticket_revision);
     $form = parent::buildForm($form, $form_state);
     return $form;
 }