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.
This commit is contained in:
Oliver Davies 2020-11-10 19:34:15 +00:00
parent 3025ab0f68
commit 06c3da1880
8 changed files with 28 additions and 17 deletions

View file

@ -7,6 +7,7 @@
declare(strict_types=1);
use Drupal\opdavies_blog\Entity\Post;
use Drupal\opdavies_blog\Repository\PostRepository;
/**
@ -16,7 +17,7 @@ function opdavies_blog_update_8001(): void {
$posts = \Drupal::service(PostRepository::class)->getAll();
foreach ($posts as $post) {
$post->set('field_sent_to_social_media', TRUE);
$post->set(Post::FIELD_SENT_TO_SOCIAL_MEDIA, TRUE);
$post->save();
}
}