本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface::isNewRevision方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface::isNewRevision方法的具体用法?PHP EntityInterface::isNewRevision怎么用?PHP EntityInterface::isNewRevision使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityInterface
的用法示例。
在下文中一共展示了EntityInterface::isNewRevision方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: form
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state)
{
$entity_type = $this->entity->getEntityType();
$bundle_entity = $this->getBundleEntity();
$account = $this->currentUser();
if ($this->operation == 'edit') {
$form['#title'] = $this->t('Edit %bundle_label @label', ['%bundle_label' => $bundle_entity ? $bundle_entity->label() : '', '@label' => $this->entity->label()]);
}
$form['advanced'] = ['#type' => 'vertical_tabs', '#weight' => 99];
// Add a log field if the "Create new revision" option is checked, or if the
// current user has the ability to check that option.
// @todo Could we autogenerate this form by using some widget on the
// revision info field.
$form['revision_information'] = ['#type' => 'details', '#title' => $this->t('Revision information'), '#open' => $this->entity->isNewRevision(), '#group' => 'advanced', '#weight' => 20, '#access' => $this->entity->isNewRevision() || $account->hasPermission($entity_type->get('admin_permission'))];
$form['revision_information']['revision'] = ['#type' => 'checkbox', '#title' => $this->t('Create new revision'), '#default_value' => $this->entity->isNewRevision(), '#access' => $account->hasPermission($entity_type->get('admin_permission'))];
// Check the revision log checkbox when the log textarea is filled in.
// This must not happen if "Create new revision" is enabled by default,
// since the state would auto-disable the checkbox otherwise.
if (!$this->entity->isNewRevision()) {
$form['revision_information']['revision']['#states'] = ['checked' => ['textarea[name="revision_log"]' => ['empty' => FALSE]]];
}
$form['revision_information']['revision_log'] = ['#type' => 'textarea', '#title' => $this->t('Revision log message'), '#rows' => 4, '#default_value' => $this->entity->getRevisionLogMessage(), '#description' => $this->t('Briefly describe the changes you have made.')];
return parent::form($form, $form_state);
}
示例2: savePropertyData
/**
* Stores the entity property language-aware data.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object.
* @param string $table_name
* (optional) The table name to save to. Defaults to the data table.
*/
protected function savePropertyData(EntityInterface $entity, $table_name = NULL)
{
if (!isset($table_name)) {
$table_name = $this->dataTable;
}
$revision = $table_name != $this->dataTable;
if (!$revision || !$entity->isNewRevision()) {
$key = $revision ? $this->revisionKey : $this->idKey;
$value = $revision ? $entity->getRevisionId() : $entity->id();
// Delete and insert to handle removed values.
$this->database->delete($table_name)->condition($key, $value)->execute();
}
$query = $this->database->insert($table_name);
foreach ($entity->getTranslationLanguages() as $langcode => $language) {
$translation = $entity->getTranslation($langcode);
$record = $this->mapToDataStorageRecord($translation, $table_name);
$values = (array) $record;
$query->fields(array_keys($values))->values($values);
}
$query->execute();
}