Save tags to the post
This commit is contained in:
parent
81bc39b5c2
commit
d0b591d57a
|
@ -5,6 +5,7 @@ namespace Drupal\example\Builder;
|
||||||
use Drupal\Core\Datetime\DrupalDateTime;
|
use Drupal\Core\Datetime\DrupalDateTime;
|
||||||
use Drupal\node\Entity\Node;
|
use Drupal\node\Entity\Node;
|
||||||
use Drupal\node\NodeInterface;
|
use Drupal\node\NodeInterface;
|
||||||
|
use Drupal\taxonomy\Entity\Term;
|
||||||
|
|
||||||
final class PostBuilder {
|
final class PostBuilder {
|
||||||
|
|
||||||
|
@ -79,7 +80,10 @@ final class PostBuilder {
|
||||||
|
|
||||||
$tagTerms[] = $term;
|
$tagTerms[] = $term;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$post->set('field_tags', $tagTerms);
|
||||||
}
|
}
|
||||||
|
|
||||||
$post->save();
|
$post->save();
|
||||||
|
|
||||||
return $post;
|
return $post;
|
||||||
|
|
Loading…
Reference in a new issue