本文整理匯總了PHP中Drupal\Core\Entity\Entity\EntityViewDisplay::loadMultiple方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityViewDisplay::loadMultiple方法的具體用法?PHP EntityViewDisplay::loadMultiple怎麽用?PHP EntityViewDisplay::loadMultiple使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Entity\Entity\EntityViewDisplay
的用法示例。
在下文中一共展示了EntityViewDisplay::loadMultiple方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: image_post_update_image_style_dependencies
/**
* Saves the image style dependencies into form and view display entities.
*/
function image_post_update_image_style_dependencies()
{
// Merge view and form displays. Use array_values() to avoid key collisions.
$displays = array_merge(array_values(EntityViewDisplay::loadMultiple()), array_values(EntityFormDisplay::loadMultiple()));
/** @var \Drupal\Core\Entity\Display\EntityDisplayInterface[] $displays */
foreach ($displays as $display) {
// Re-save each config entity to add missed dependencies.
$display->save();
}
}
示例2: responsive_image_post_update_recreate_dependencies
/**
* Make responsive image formatters dependent on responsive image styles.
*/
function responsive_image_post_update_recreate_dependencies()
{
$displays = EntityViewDisplay::loadMultiple();
array_walk($displays, function (EntityViewDisplayInterface $entity_view_display) {
$old_dependencies = $entity_view_display->getDependencies();
$new_dependencies = $entity_view_display->calculateDependencies()->getDependencies();
if ($old_dependencies !== $new_dependencies) {
$entity_view_display->save();
}
});
}
示例3: replaceImageStyle
/**
* Update field settings if the image style name is changed.
*
* @param \Drupal\image\ImageStyleInterface $style
* The image style.
*/
protected static function replaceImageStyle(ImageStyleInterface $style)
{
if ($style->id() != $style->getOriginalId()) {
// Loop through all entity displays looking for formatters / widgets using
// the image style.
foreach (EntityViewDisplay::loadMultiple() as $display) {
foreach ($display->getComponents() as $name => $options) {
if (isset($options['type']) && $options['type'] == 'image' && $options['settings']['image_style'] == $style->getOriginalId()) {
$options['settings']['image_style'] = $style->id();
$display->setComponent($name, $options)->save();
}
}
}
foreach (EntityViewDisplay::loadMultiple() as $display) {
foreach ($display->getComponents() as $name => $options) {
if (isset($options['type']) && $options['type'] == 'image_image' && $options['settings']['preview_image_style'] == $style->getOriginalId()) {
$options['settings']['preview_image_style'] = $style->id();
$display->setComponent($name, $options)->save();
}
}
}
}
}