public function BusinessRulesProcessor::ruleExists in Business Rules 8
Same name and namespace in other branches
- 2.x 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 732
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);
}