/**
  * Trigger a rule.
  *
  * The trigger will check the conditions and if conditions are valid then the actions are executed
  *
  * @param CRM_Civirules_Trigger $trigger
  * @param object CRM_Civirules_TriggerData_TriggerData $triggerData
  * @return bool true when conditions are valid; false when conditions are not valid
  * @access public
  * @static
  */
 public static function triggerRule(CRM_Civirules_Trigger $trigger, CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     try {
         $triggerData->setTrigger($trigger);
         $isRuleValid = self::areConditionsValid($triggerData);
         if ($isRuleValid) {
             self::logRule($triggerData);
             self::executeActions($triggerData);
             return true;
         }
     } catch (Exception $e) {
         $message = "Error on {file} (Line {line})\r\n\r\n{exception_message}";
         $context = array();
         $context['line'] = $e->getLine();
         $context['file'] = $e->getFile();
         $context['exception_message'] = $e->getMessage();
         CRM_Civirules_Utils_LoggerFactory::logError("Failed to execute rule", $message, $triggerData, $context);
     }
     return false;
 }