本文整理汇总了PHP中Drupal\Core\Entity\EntityStorageInterface::loadRevision方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityStorageInterface::loadRevision方法的具体用法?PHP EntityStorageInterface::loadRevision怎么用?PHP EntityStorageInterface::loadRevision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityStorageInterface
的用法示例。
在下文中一共展示了EntityStorageInterface::loadRevision方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
/**
* {@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: access
/**
* 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: access
/**
* 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: testGetEntityUpdateRevision
/**
* 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: buildForm
/**
* {@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: buildForm
/**
* {@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;
}