|
@@ -0,0 +1,47 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+use Drush\Drush;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+$self = Drush::aliasManager()->getSelf();;
|
|
|
+if (!$self->hasRoot()) {
|
|
|
+ $this->output()->writeln('No bootstrapped site.');
|
|
|
+}
|
|
|
+else {
|
|
|
+ $this->output()->writeln('The following site is bootstrapped:');
|
|
|
+ $this->output()->writeln(print_r($self->legacyRecord(), true));
|
|
|
+
|
|
|
+
|
|
|
+ $nodes = \Drupal::entityTypeManager()->getStorage('node')
|
|
|
+ ->loadByProperties(['type' => 'projet']);
|
|
|
+
|
|
|
+ foreach ($nodes as $nid => $node) {
|
|
|
+
|
|
|
+ $field_photo = $node->get('field_photo');
|
|
|
+ $itemlist = $field_photo->getValue();
|
|
|
+
|
|
|
+ foreach ($itemlist as $key => $field_item) {
|
|
|
+ if (!empty($field_item['alt']) && (!isset($field_item['caption']) || empty($field_item['caption']))) {
|
|
|
+ $field_item['image_field_caption']['value'] = $field_item['alt'];
|
|
|
+ $field_item['image_field_caption']['format'] = 'plain_text';
|
|
|
+ $itemlist[$key] = $field_item;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $node->set('field_photo', $itemlist);
|
|
|
+ $node->save();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|