protected function EditorDetectorBase::extractEntitiesFromText in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 4.0.x src/Plugin/RelatedEntitiesDetector/EditorDetectorBase.php \Drupal\lingotek\Plugin\RelatedEntitiesDetector\EditorDetectorBase::extractEntitiesFromText()
- 3.6.x src/Plugin/RelatedEntitiesDetector/EditorDetectorBase.php \Drupal\lingotek\Plugin\RelatedEntitiesDetector\EditorDetectorBase::extractEntitiesFromText()
- 3.7.x src/Plugin/RelatedEntitiesDetector/EditorDetectorBase.php \Drupal\lingotek\Plugin\RelatedEntitiesDetector\EditorDetectorBase::extractEntitiesFromText()
Extract entities referenced by a given text.
Parameters
string $text: The text to extract the entities from.
Return value
array Array of entities in the form of (uuid => entity_type_id).
1 call to EditorDetectorBase::extractEntitiesFromText()
- EditorDetectorBase::extract in src/
Plugin/ RelatedEntitiesDetector/ EditorDetectorBase.php - Extract nested and related content.
1 method overrides EditorDetectorBase::extractEntitiesFromText()
- HtmlLinkDetector::extractEntitiesFromText in src/
Plugin/ RelatedEntitiesDetector/ HtmlLinkDetector.php - Extract entities referenced by a given text.
File
- src/
Plugin/ RelatedEntitiesDetector/ EditorDetectorBase.php, line 130
Class
Namespace
Drupal\lingotek\Plugin\RelatedEntitiesDetectorCode
protected function extractEntitiesFromText($text) {
$dom = Html::load($text);
$xpath = new \DOMXPath($dom);
$entities = [];
foreach ($xpath
->query($this->xpath) as $node) {
$entities[$node
->getAttribute('data-entity-uuid')] = $node
->getAttribute('data-entity-type');
}
return $entities;
}