oliverdavies.uk-drupal-old/web/modules/custom/blog/opdavies_blog.install

24 lines
484 B
Plaintext
Raw Normal View History

<?php
2020-09-04 19:56:04 +00:00
/**
* @file
* Install, update and uninstall functions for opdavies_blog.
*/
declare(strict_types=1);
use Drupal\opdavies_blog\Entity\Post;
use Drupal\opdavies_blog\Repository\PostRepository;
/**
* Mark existing blog posts as sent to social media.
*/
function opdavies_blog_update_8001(): void {
$posts = \Drupal::service(PostRepository::class)->getAll();
foreach ($posts as $post) {
$post->set(Post::FIELD_SENT_TO_SOCIAL_MEDIA, TRUE);
$post->save();
}
}