image.post_update.php 706 B

12345678910111213141516171819202122
  1. <?php
  2. /**
  3. * @file
  4. * Post-update functions for Image.
  5. */
  6. use Drupal\Core\Entity\Entity\EntityViewDisplay;
  7. use Drupal\Core\Entity\Entity\EntityFormDisplay;
  8. /**
  9. * Saves the image style dependencies into form and view display entities.
  10. */
  11. function image_post_update_image_style_dependencies() {
  12. // Merge view and form displays. Use array_values() to avoid key collisions.
  13. $displays = array_merge(array_values(EntityViewDisplay::loadMultiple()), array_values(EntityFormDisplay::loadMultiple()));
  14. /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface[] $displays */
  15. foreach ($displays as $display) {
  16. // Re-save each config entity to add missed dependencies.
  17. $display->save();
  18. }
  19. }