本文整理匯總了PHP中Drupal\Core\Entity\ContentEntityInterface::set方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContentEntityInterface::set方法的具體用法?PHP ContentEntityInterface::set怎麽用?PHP ContentEntityInterface::set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Entity\ContentEntityInterface
的用法示例。
在下文中一共展示了ContentEntityInterface::set方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: transferFieldValues
/**
* Transfer field values from update to entity to be updated.
*
* Because different fields may be on different bundles
* not all fields will be transferred to all entities.
*
* @param $update
* @param $entity_to_update
*/
protected function transferFieldValues(ScheduledUpdateInterface $update, ContentEntityInterface $entity_to_update) {
$field_map = $this->scheduled_update_type->getFieldMap();
foreach ($field_map as $from_field => $to_field) {
if ($to_field) {
if ($entity_to_update->hasField($to_field) && $update->hasField($from_field)) {
$new_value = $update->get($from_field)->getValue();
// @todo if $new_value is empty. Check to see if the field is required on the target?
// If it is require don't update value because this cause a fatal at least on base fields.
if (isset($new_value)) {
$entity_to_update->set($to_field, $new_value);
}
}
}
}
}