本文整理汇总了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();
}
}
}
}
}