本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface::getRevisionId方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface::getRevisionId方法的具体用法?PHP EntityInterface::getRevisionId怎么用?PHP EntityInterface::getRevisionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityInterface
的用法示例。
在下文中一共展示了EntityInterface::getRevisionId方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unset
function __construct(EntityInterface $entity)
{
$this->queue = new \Celery('localhost', 'guest', 'guest', '/');
$this->id = $entity->getRevisionId();
$this->ref_id = $entity->nid->value;
$this->name = $entity->getTitle();
$this->type = $entity->bundle();
// Host Definition
$this->host_def_vars = $this->getHostDefinition($entity);
$this->host_def_vars['ran_name'] = $this->name;
$this->host_def_type = $this->host_def_vars['_system_type'];
unset($this->host_def_vars['_system_type']);
// Host Configuration
$this->host_conf_vars = $this->getHostConfiguration($entity);
$this->host_conf_types = $this->host_conf_vars['_roles'];
unset($this->host_conf_vars['_roles']);
// Host Description
$this->description = 'Generated by Rán.';
$desc = $entity->getFields()['field_ran__description']->getString();
if (isset($this->vars['_description'])) {
$this->description = $this->vars['_description'];
unset($this->vars['_description']);
}
$this->org = 'root';
$this->project = 'default';
$this->extra_vars = json_encode(array('ran_name' => $this->name, 'ran_desc' => $this->description, 'ran_type' => $this->type, 'ran_def_type' => $this->host_def_type, 'ran_def_vars' => $this->host_def_vars, 'ran_conf_types' => $this->host_conf_types, 'ran_conf_vars' => $this->host_conf_vars), JSON_UNESCAPED_UNICODE);
}
示例2: alterBuild
/**
* {@inheritdoc}
*/
protected function alterBuild(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)
{
$entity_type_id = $entity->getEntityTypeId();
if ($entity instanceof ContentEntityInterface && $entity->isDefaultRevision() || !$entity->getEntityType()->isRevisionable()) {
$build['#contextual_links'][$entity_type_id] = ['route_parameters' => [$entity_type_id => $entity->id()]];
} else {
$build['#contextual_links'][$entity_type_id . '_revision'] = ['route_parameters' => [$entity_type_id => $entity->id(), $entity_type_id . '_revision' => $entity->getRevisionId()]];
}
}
示例3: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
// The revision timestamp will be updated when the revision is saved. Keep
// the original one for the confirmation message.
$this->revision = $this->prepareRevision($this->revision);
if ($this->revision instanceof RevisionLogInterface) {
$original_revision_timestamp = $this->revision->getRevisionCreationTime();
$this->revision->setRevisionLogMessage($this->t('Copy of the revision from %date.', ['%date' => $this->dateFormatter->format($original_revision_timestamp)]));
drupal_set_message(t('@type %title has been reverted to the revision from %revision-date.', ['@type' => $this->getBundleLabel($this->revision), '%title' => $this->revision->label(), '%revision-date' => $this->dateFormatter->format($original_revision_timestamp)]));
} else {
drupal_set_message(t('@type %title has been reverted', ['@type' => $this->getBundleLabel($this->revision), '%title' => $this->revision->label()]));
}
$this->revision->save();
$this->logger('content')->notice('@type: reverted %title revision %revision.', ['@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId()]);
$form_state->setRedirect("entity.{$this->revision->getEntityTypeId()}.version_history", [$this->revision->getEntityTypeId() => $this->revision->id()]);
}
示例4: verifyForums
/**
* Verifies that the logged in user has access to a forum node.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* The node being checked.
* @param bool $admin
* Boolean to indicate whether the user can 'access administration pages'.
* @param int $response
* The expected HTTP response code.
*/
private function verifyForums(EntityInterface $node, $admin, $response = 200)
{
$response2 = $admin ? 200 : 403;
// View forum help node.
$this->drupalGet('admin/help/forum');
$this->assertResponse($response2);
if ($response2 == 200) {
$this->assertTitle(t('Forum | Drupal'), 'Forum help title was displayed');
$this->assertText(t('Forum'), 'Forum help node was displayed');
}
// View forum container page.
$this->verifyForumView($this->forumContainer);
// View forum page.
$this->verifyForumView($this->forum, $this->forumContainer);
// View root forum page.
$this->verifyForumView($this->rootForum);
// View forum node.
$this->drupalGet('node/' . $node->id());
$this->assertResponse(200);
$this->assertTitle($node->label() . ' | Drupal', 'Forum node was displayed');
$breadcrumb_build = array(Link::createFromRoute(t('Home'), '<front>'), Link::createFromRoute(t('Forums'), 'forum.index'), Link::createFromRoute($this->forumContainer['name'], 'forum.page', array('taxonomy_term' => $this->forumContainer['tid'])), Link::createFromRoute($this->forum['name'], 'forum.page', array('taxonomy_term' => $this->forum['tid'])));
$breadcrumb = array('#theme' => 'breadcrumb', '#links' => $breadcrumb_build);
$this->assertRaw(\Drupal::service('renderer')->renderRoot($breadcrumb), 'Breadcrumbs were displayed');
// View forum edit node.
$this->drupalGet('node/' . $node->id() . '/edit');
$this->assertResponse($response);
if ($response == 200) {
$this->assertTitle('Edit Forum topic ' . $node->label() . ' | Drupal', 'Forum edit node was displayed');
}
if ($response == 200) {
// Edit forum node (including moving it to another forum).
$edit = array();
$edit['title[0][value]'] = 'node/' . $node->id();
$edit['body[0][value]'] = $this->randomMachineName(256);
// Assume the topic is initially associated with $forum.
$edit['taxonomy_forums'] = $this->rootForum['tid'];
$edit['shadow'] = TRUE;
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
$this->assertRaw(t('Forum topic %title has been updated.', array('%title' => $edit['title[0][value]'])), 'Forum node was edited');
// Verify topic was moved to a different forum.
$forum_tid = db_query("SELECT tid FROM {forum} WHERE nid = :nid AND vid = :vid", array(':nid' => $node->id(), ':vid' => $node->getRevisionId()))->fetchField();
$this->assertTrue($forum_tid == $this->rootForum['tid'], 'The forum topic is linked to a different forum');
// Delete forum node.
$this->drupalPostForm('node/' . $node->id() . '/delete', array(), t('Delete'));
$this->assertResponse($response);
$this->assertRaw(t('Forum topic %title has been deleted.', array('%title' => $edit['title[0][value]'])), 'Forum node was deleted');
}
}
示例5: calculateEntityBulkFormKey
/**
* Calculates a bulk form key.
*
* This generates a key that is used as the checkbox return value when
* submitting a bulk form. This key allows the entity for the row to be loaded
* totally independently of the executed view row.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to calculate a bulk form key for.
* @param bool $use_revision
* Whether the revision id should be added to the bulk form key. This should
* be set to TRUE only if the view is listing entity revisions.
*
* @return string
* The bulk form key representing the entity's id, language and revision (if
* applicable) as one string.
*
* @see self::loadEntityFromBulkFormKey()
*/
protected function calculateEntityBulkFormKey(EntityInterface $entity, $use_revision)
{
$key_parts = [$entity->language()->getId(), $entity->id()];
if ($entity instanceof RevisionableInterface && $use_revision) {
$key_parts[] = $entity->getRevisionId();
}
return implode('-', $key_parts);
}
示例6: deleteFieldItemsRevision
/**
* Deletes values of configurable fields for a single revision of an entity.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity. It must have a revision ID.
*/
protected function deleteFieldItemsRevision(EntityInterface $entity)
{
$vid = $entity->getRevisionId();
if (isset($vid)) {
foreach ($this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle()) as $field_definition) {
$storage_definition = $field_definition->getFieldStorageDefinition();
if (!$this->usesDedicatedTable($storage_definition)) {
continue;
}
$revision_name = static::_fieldRevisionTableName($storage_definition);
$this->database->delete($revision_name)->condition('entity_id', $entity->id())->condition('revision_id', $vid)->execute();
}
}
}
示例7: calculateEntityBulkFormKey
/**
* Calculates a bulk form key.
*
* This generates a key that is used as the checkbox return value when
* submitting a bulk form. This key allows the entity for the row to be loaded
* totally independently of the executed view row.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to calculate a bulk form key for.
* @param bool $use_revision
* Whether the revision id should be added to the bulk form key. This should
* be set to TRUE only if the view is listing entity revisions.
*
* @return string
* The bulk form key representing the entity's id, language and revision (if
* applicable) as one string.
*
* @see self::loadEntityFromBulkFormKey()
*/
protected function calculateEntityBulkFormKey(EntityInterface $entity, $use_revision)
{
$key_parts = [$entity->language()->getId(), $entity->id()];
if ($entity instanceof RevisionableInterface && $use_revision) {
$key_parts[] = $entity->getRevisionId();
}
// An entity ID could be an arbitrary string (although they are typically
// numeric). JSON then Base64 encoding ensures the bulk_form_key is
// safe to use in HTML, and that the key parts can be retrieved.
$key = json_encode($key_parts);
return base64_encode($key);
}
示例8: setLatestRevision
/**
* Set the latest revision.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The content entity to create content_moderation_state entity for.
*/
protected function setLatestRevision(EntityInterface $entity)
{
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$this->tracker->setLatestRevision($entity->getEntityTypeId(), $entity->id(), $entity->language()->getId(), $entity->getRevisionId());
}
示例9: buildValue
/**
* {@inheritdoc}
*/
protected function buildValue(EntityInterface $entity)
{
!($is_new = $entity->isNew());
$revision_id = $is_new ? 0 : $entity->getRevisionId();
// We assign a temporary status to the revision since we are indexing it
// pre save. It will be updated post save with the final status. This will
// help identifying failures and exception scenarios during entity save.
$status = 'indexed';
if (!$is_new && $revision_id) {
$status = $entity->_deleted->value ? 'deleted' : 'available';
}
return array('entity_type_id' => $entity->getEntityTypeId(), 'entity_id' => $is_new ? 0 : $entity->id(), 'revision_id' => $revision_id, 'uuid' => $entity->uuid(), 'rev' => $entity->_rev->value, 'is_stub' => $entity->_rev->is_stub, 'status' => $status);
}