public function TooltipManager::checkPathAndContentType in Tooltip Taxonomy 8
Check the path and content type.
Return all conditions that match the restrictions.
Parameters
\Drupal\Core\Entity\ContentEntityBase $node: The node being viewed.
Return value
array All filter conditions matched.
1 call to TooltipManager::checkPathAndContentType()
- TooltipManager::addTooltip in src/
Services/ TooltipManager.php - Attach tooltip into a field text.
File
- src/
Services/ TooltipManager.php, line 92
Class
- TooltipManager
- Tooltip filter condition manager class.
Namespace
Drupal\tooltip_taxonomy\ServicesCode
public function checkPathAndContentType(ContentEntityBase $entity) {
$all_con = $this
->getAllFilterCondition();
$match_cons = [];
if (!empty($all_con)) {
$this->allConditions = $all_con;
// Check the path & content types.
foreach ($all_con as $con) {
$path_con = $con
->get('path');
if (!empty($path_con)) {
$this->pathCondition
->setConfiguration($path_con);
if ($this->pathCondition
->evaluate() ^ $this->pathCondition
->isNegated()) {
$content_type_con = $con
->get('contentTypes');
if (!empty($content_type_con) && $entity instanceof Node) {
$this->contentTypeCondition
->setConfiguration($content_type_con)
->setContextValue('node', $entity);
if ($this->contentTypeCondition
->evaluate()) {
$match_cons[] = $con;
}
}
else {
// Either this condition apply to all content types
// or the entity is not a Node.
$match_cons[] = $con;
}
}
}
}
}
return $match_cons;
}