Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / layout_builder / layout_builder.post_update.php
diff --git a/web/core/modules/layout_builder/layout_builder.post_update.php b/web/core/modules/layout_builder/layout_builder.post_update.php
new file mode 100644 (file)
index 0000000..9a2b858
--- /dev/null
@@ -0,0 +1,26 @@
+<?php
+
+/**
+ * @file
+ * Post update functions for Layout Builder.
+ */
+
+/**
+ * Rebuild plugin dependencies for all entity view displays.
+ */
+function layout_builder_post_update_rebuild_plugin_dependencies(&$sandbox = NULL) {
+  $storage = \Drupal::entityTypeManager()->getStorage('entity_view_display');
+  if (!isset($sandbox['ids'])) {
+    $sandbox['ids'] = $storage->getQuery()->accessCheck(FALSE)->execute();
+    $sandbox['count'] = count($sandbox['ids']);
+  }
+
+  for ($i = 0; $i < 10 && count($sandbox['ids']); $i++) {
+    $id = array_shift($sandbox['ids']);
+    if ($display = $storage->load($id)) {
+      $display->save();
+    }
+  }
+
+  $sandbox['#finished'] = empty($sandbox['ids']) ? 1 : ($sandbox['count'] - count($sandbox['ids'])) / $sandbox['count'];
+}