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


PHP EntityInterface::isNewRevision方法代码示例

本文整理汇总了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);
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:27,代码来源:RevisionableContentEntityForm.php

示例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();
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:29,代码来源:ContentEntityDatabaseStorage.php


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