本文整理匯總了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();
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}