parent
c5c774290d
commit
10e4616e01
2 changed files with 35 additions and 0 deletions
|
@ -61,10 +61,19 @@ class Post extends Node implements ContentEntityBundleInterface {
|
|||
|
||||
private function convertTermsToHashtags(): string {
|
||||
return $this->getTags()
|
||||
->filter(fn(Term $term) => !$this->tagsToRemove()
|
||||
->contains($term->label()))
|
||||
->map(fn(Term $term) => $this->convertTermToHashtag($term))
|
||||
->implode(' ');
|
||||
}
|
||||
|
||||
private function tagsToRemove(): Collection {
|
||||
// TODO: Move these values into configuration/settings.php.
|
||||
return new Collection([
|
||||
'Drupal Planet',
|
||||
]);
|
||||
}
|
||||
|
||||
private function convertTermToHashtag(Term $tag): string {
|
||||
$tagName = strtolower($tag->label());
|
||||
$tagName = "#{$tagName}";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue