You are here

protected function Topic::prepareTopicType in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  2. 8 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  3. 8.2 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  4. 8.3 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  5. 8.4 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  6. 8.5 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  7. 8.6 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  8. 8.7 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  9. 8.8 modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  10. 10.0.x modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  11. 10.1.x modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()
  12. 10.2.x modules/custom/social_demo/src/Plugin/DemoContent/Topic.php \Drupal\social_demo\Plugin\DemoContent\Topic::prepareTopicType()

Returns taxonomy term id.

Parameters

string $name: Term name.

Return value

array|null Array containing related terms.

1 call to Topic::prepareTopicType()
Topic::getEntry in modules/custom/social_demo/src/Plugin/DemoContent/Topic.php
Makes an array with data of an entity.

File

modules/custom/social_demo/src/Plugin/DemoContent/Topic.php, line 140

Class

Topic
Topic Plugin for demo content.

Namespace

Drupal\social_demo\Plugin\DemoContent

Code

protected function prepareTopicType($name) {
  $value = NULL;
  $terms = $this->termStorage
    ->loadByProperties([
    'name' => $name,
  ]);
  if ($terms) {
    $value = [
      [
        'target_id' => current($terms)
          ->id(),
      ],
    ];
  }
  return $value;
}