當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContentEntityInterface::save方法代碼示例

本文整理匯總了PHP中Drupal\Core\Entity\ContentEntityInterface::save方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentEntityInterface::save方法的具體用法?PHP ContentEntityInterface::save怎麽用?PHP ContentEntityInterface::save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Entity\ContentEntityInterface的用法示例。


在下文中一共展示了ContentEntityInterface::save方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createTranslatableEntity

 /**
  * Creates a translated entity.
  */
 protected function createTranslatableEntity()
 {
     $this->entity = EntityTest::create();
     $this->entity->addTranslation('es', ['name' => 'name spanish']);
     $this->entity->addTranslation('fr', ['name' => 'name french']);
     $this->entity->save();
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:10,代碼來源:EntityUrlLanguageTest.php

示例2: 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->entityRevision->setNewRevision();
     $this->entityRevision->isDefaultRevision(TRUE);
     if ($this->entityRevision instanceof EntityRevisionLogInterface) {
         if ($this->entityRevision instanceof TimestampedRevisionInterface) {
             $original_revision_timestamp = $this->entityRevision->getRevisionCreationTime();
             $this->entityRevision->revision_log = t('Copy of the revision from %date.', ['%date' => $this->dateFormatter->format($original_revision_timestamp)]);
         } else {
             $this->entityRevision->revision_log = t('Copy of the revision');
         }
     }
     $this->entityRevision->save();
     $this->logger('content')->notice('@type: reverted %title revision %revision.', ['@type' => $this->entityRevision->bundle(), '%title' => $this->entityRevision->label(), '%revision' => $this->entityRevision->getRevisionId()]);
     drupal_set_message(t('@type %title has been reverted to the revision', ['@type' => $this->entityRevision->{$this->entityRevision->getEntityType()->getKey('bundle')}->entity->label(), '%title' => $this->entityRevision->label()]));
     $form_state->setRedirectUrl($this->entityRevision->urlInfo('version-history'));
 }
開發者ID:heddn,項目名稱:content_entity_base,代碼行數:22,代碼來源:EntityRevisionRevertForm.php

示例3: save

 /**
  * Save the entity.
  *
  * @param \Drupal\Core\Entity\ContentEntityInterface $entity
  *   The content entity.
  * @param array $old_destination_id_values
  *   An array of destination id values.
  *
  * @return array
  *   An array containing the entity id.
  */
 protected function save(ContentEntityInterface $entity, array $old_destination_id_values = array())
 {
     $entity->save();
     return array($entity->id());
 }
開發者ID:davidsoloman,項目名稱:drupalconsole.com,代碼行數:16,代碼來源:EntityContentBase.php

示例4: removeCorrespondingReference

 /**
  * @param string $correspondingFieldName
  *  Name of the field on the target entity which holds references back to the
  * referer that need corresponding.
  * @param $refererId
  *  Id of the referencing entity whose update has triggered this.
  * @param $referencedEntity
  *   The referenced entity that needs its corresponding field updating.
  */
 public function removeCorrespondingReference($correspondingFieldName, $refererId, ContentEntityInterface $referencedEntity)
 {
     $correspondingField = $referencedEntity->get($correspondingFieldName);
     $currentReferences = $correspondingField->getValue();
     $desiredReferences = $this->nested_array_diff([['target_id' => $refererId]], $currentReferences);
     $correspondingField->setValue($desiredReferences);
     $referencedEntity->save();
 }
開發者ID:shrimala,項目名稱:ahsweb,代碼行數:17,代碼來源:simple_cer.php


注:本文中的Drupal\Core\Entity\ContentEntityInterface::save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。