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


PHP EntityInterface::toArray方法代碼示例

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


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

示例1: toArray

 /**
  * {@inheritdoc}
  */
 public function toArray()
 {
     if (!isset($this->entity)) {
         throw new MissingDataException('Unable to get property values as no entity has been provided.');
     }
     return $this->entity->toArray();
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:10,代碼來源:EntityAdapter.php

示例2: getFormSubmitActionForNewTranslation

 /**
  * Returns the form action value when submitting a new translation.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity being tested.
  * @param string $langcode
  *   Language code for the form.
  *
  * @return string
  *   Name of the button to hit.
  */
 protected function getFormSubmitActionForNewTranslation(EntityInterface $entity, $langcode)
 {
     $entity->addTranslation($langcode, $entity->toArray());
     return $this->getFormSubmitAction($entity, $langcode);
 }
開發者ID:ravindrasingh22,項目名稱:Drupal-8-rc,代碼行數:16,代碼來源:ContentTranslationUITestBase.php

示例3: mapToStorageRecord

 /**
  * Maps from an entity object to the storage record.
  *
  * @param \Drupal\Core\Entity\EntityInterface $entity
  *   The entity object.
  *
  * @return array
  *   The record to store.
  */
 protected function mapToStorageRecord(EntityInterface $entity)
 {
     return $entity->toArray();
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:13,代碼來源:ConfigEntityStorage.php

示例4: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, EntityInterface $entity)
 {
     $is_new = $entity->isNew();
     // Save the entity data in the key value store.
     $this->keyValueStore->set($entity->id(), $entity->toArray());
     // If this is a rename, delete the original entity.
     if ($this->has($id, $entity) && $id !== $entity->id()) {
         $this->keyValueStore->delete($id);
     }
     return $is_new ? SAVED_NEW : SAVED_UPDATED;
 }
開發者ID:eigentor,項目名稱:tommiblog,代碼行數:14,代碼來源:KeyValueEntityStorage.php

示例5: doSave

 /**
  * {@inheritdoc}
  */
 protected function doSave($id, EntityInterface $entity)
 {
     $is_new = $entity->isNew();
     $prefix = $this->getConfigPrefix();
     if ($id !== $entity->id()) {
         // Renaming a config object needs to cater for:
         // - Storage needs to access the original object.
         // - The object needs to be renamed/copied in ConfigFactory and reloaded.
         // - All instances of the object need to be renamed.
         $config = $this->configFactory->rename($prefix . $id, $prefix . $entity->id());
     } else {
         $config = $this->configFactory->get($prefix . $id);
     }
     // Retrieve the desired properties and set them in config.
     foreach ($entity->toArray() as $key => $value) {
         $config->set($key, $value);
     }
     $config->save();
     return $is_new ? SAVED_NEW : SAVED_UPDATED;
 }
開發者ID:alnutile,項目名稱:drunatra,代碼行數:23,代碼來源:ConfigEntityStorage.php


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