private function executeRule(Rulerz $rule, sfDoctrineRecord $entity, $eventName) { $execution = new RulerzExecution(); $execution->setRulerz($rule); $execution->setEvent($eventName); $execution->setEntityUid($entity->getPrimaryKey()); try { ob_start(); $lua = new Lua(); $lua->assign('entity', $entity->toArray()); $this->registerLuaApi($lua); $result = $lua->eval($rule->getAction()); $print = ob_get_contents(); ob_end_clean(); $execution->setStatus('SUCCESS'); $execution->setExecutionData(sprintf("%s\n\nResult : %s", $print, $result)); } catch (Exception $e) { $execution->setStatus('FAILED'); $execution->setExecutionData($e->__toString()); } $execution->save(); }