You are here

public function Entity::targetCallback in Open Social 10.3.x

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

The targetCallback function.

Parameters

string $value: The value.

array|string $settings: The settings.

Return value

mixed Returns mixed.

Overrides MentionsPluginInterface::targetCallback

File

modules/custom/mentions/src/Plugin/Mentions/Entity.php, line 67

Class

Entity
Class Entity.

Namespace

Drupal\mentions\Plugin\Mentions

Code

public function targetCallback($value, $settings) {
  $entity_type = $settings['entity_type'];
  $input_value = $settings['value'];
  $query = $this->entityTypeManager
    ->getStorage($entity_type)
    ->getQuery();
  $result = $query
    ->condition($input_value, $value)
    ->execute();
  if (!empty($result)) {
    $result = reset($result);
    $target = [];
    $target['entity_type'] = $entity_type;
    $target['entity_id'] = $result;
    return $target;
  }
  return FALSE;
}