oliverdavies.uk-drupal-old/web/modules/custom/blog/opdavies_blog.install
Oliver Davies 06c3da1880 Add public constants for field names
Make it easier and safer when referencing field names by adding public
constants for them to the Talk and Post classes.
2020-11-10 19:34:15 +00:00

24 lines
484 B
Plaintext

<?php
/**
* @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();
}
}