public function BusinessRulesProcessor::ruleExists in Business Rules 2.x
Same name and namespace in other branches
- 8 src/Util/BusinessRulesProcessor.php \Drupal\business_rules\Util\BusinessRulesProcessor::ruleExists()
Check if a Business Rule exists for the entity or not.
Parameters
string $reacts_on: The Event Name.
\Drupal\Core\Entity\EntityInterface $entity: The Entity.
Return value
bool TRUE if the business rule exists, FALSE otherwise.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- src/
Util/ BusinessRulesProcessor.php, line 750
Class
- BusinessRulesProcessor
- Class BusinessRulesProcessor.
Namespace
Drupal\business_rules\UtilCode
public function ruleExists($reacts_on, EntityInterface $entity) {
if (!$entity instanceof ContentEntityInterface) {
return FALSE;
}
$business_rule_entity = $this->entityTypeManager
->getStorage('business_rule')
->loadByProperties([
'reacts_on' => $reacts_on,
'target_entity_type' => $entity
->getEntityTypeId(),
'target_bundle' => $entity
->bundle(),
]);
return !empty($business_rule_entity);
}