Oliver Davies
06c3da1880
Make it easier and safer when referencing field names by adding public constants for them to the Talk and Post classes.
24 lines
484 B
Plaintext
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();
|
|
}
|
|
}
|