public function Twitter::getHashtags in Social simple 8
Same name and namespace in other branches
- 2.0.x src/SocialNetwork/Twitter.php \Drupal\social_simple\SocialNetwork\Twitter::getHashtags()
1 call to Twitter::getHashtags()
- Twitter::getShareLink in src/
SocialNetwork/ Twitter.php - Checks whether the given transition is allowed.
File
- src/
SocialNetwork/ Twitter.php, line 89
Class
- The social network Twitter.
Namespace
Drupal\social_simple\SocialNetworkCode
public function getHashtags(ContentEntityInterface $entity) {
$options = [];
if (!$entity instanceof NodeInterface) {
return $options;
}
/** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity_type */
$entity_type = $entity->type->entity;
if (!$entity_type instanceof ConfigEntityInterface) {
return $options;
}
$key_value = $entity_type
->getThirdPartySetting('social_simple', 'hashtags', '');
if (!empty($key_value) && $entity
->hasField($key_value)) {
$referenced_entities = $entity
->get($key_value)
->referencedEntities();
$labels = [];
/** @var \Drupal\Core\Entity\EntityInterface $referenced_entity */
foreach ($referenced_entities as $referenced_entity) {
$labels[] = preg_replace('/\\s+/', '', $referenced_entity
->label());
}
if ($labels) {
$options['hashtags'] = implode(',', $labels);
}
}
return $options;
}