class Entity in Open Social 10.1.x
Same name and namespace in other branches
- 8.9 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8.2 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8.3 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8.4 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8.5 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8.6 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8.7 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 8.8 modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 10.3.x modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 10.0.x modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
- 10.2.x modules/custom/mentions/src/Plugin/Mentions/Entity.php \Drupal\mentions\Plugin\Mentions\Entity
Class Entity.
Plugin annotation
@Mention(
id = "entity",
name = @Translation("Entity")
)
Hierarchy
- class \Drupal\mentions\Plugin\Mentions\Entity implements MentionsPluginInterface
Expanded class hierarchy of Entity
1 string reference to 'Entity'
- field.field.activity.activity.field_activity_entity.yml in modules/
custom/ activity_creator/ config/ install/ field.field.activity.activity.field_activity_entity.yml - modules/custom/activity_creator/config/install/field.field.activity.activity.field_activity_entity.yml
File
- modules/
custom/ mentions/ src/ Plugin/ Mentions/ Entity.php, line 21
Namespace
Drupal\mentions\Plugin\MentionsView source
class Entity implements MentionsPluginInterface {
private $tokenService;
private $entityTypeManager;
/**
* Entity constructor.
*
* @param \Drupal\Core\Utility\Token $token
* The token service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(Token $token, EntityTypeManagerInterface $entity_type_manager) {
$this->tokenService = $token;
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$token = $container
->get('token');
$entity_type_manager = $container
->get('entity_type.manager');
return new static($token, $entity_type_manager);
}
/**
* {@inheritdoc}
*/
public function outputCallback($mention, $settings) {
$entity = $this->entityTypeManager
->getStorage($mention['target']['entity_type'])
->load($mention['target']['entity_id']);
$output = [];
$output['value'] = $this->tokenService
->replace($settings['value'], [
$mention['target']['entity_type'] => $entity,
]);
if ($settings['renderlink']) {
$output['link'] = $this->tokenService
->replace($settings['rendertextbox'], [
$mention['target']['entity_type'] => $entity,
]);
}
return $output;
}
/**
* {@inheritdoc}
*/
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;
}
/**
* {@inheritdoc}
*/
public function mentionPresaveCallback(EntityInterface $entity) {
}
/**
* {@inheritdoc}
*/
public function patternCallback($settings, $regex) {
}
/**
* {@inheritdoc}
*/
public function settingsCallback(FormInterface $form, FormStateInterface $form_state, $type) {
}
/**
* {@inheritdoc}
*/
public function settingsSubmitCallback(FormInterface $form, FormStateInterface $form_state, $type) {
}
}