<?php
 namespace Modules\Admin\AutoProcessRules\Execute; class Controller extends \App\Mvc\Controller\Form\PopupAbstract { protected function getDefaultFormData($R) { return $R; } protected function processFormData(array $R, \App\MessagesCollector $msgs) { $idRule = $R['id']; $idExecution = uniqid(); $ruleLogs = new \App\AutoProcessRules\Logs\Rule($idExecution, $idRule); $OK = true; \App\UserAccess\CurrentUserAccessFast::getInstance()->becomeSuperUser(); try { $ruleExec = \Entity\AutoProcessRule::execute($idRule); $ruleExec->ruleLogs = $ruleLogs; $ruleExec->save(); $msgs->addSuccess($this->lang['index']['msgs']['ok']); } catch (\App\Entity\Exception $e) { $msgs->appendMessages( $e->getMessagesCollector() ); $OK = false; } finally { \App\UserAccess\CurrentUserAccessFast::getInstance()->becomeNormalUser(); $writeLogs = new \App\AutoProcessRules\Logs\WriteLogs($ruleLogs); $writeLogs->write(); } return $OK; } protected function preRenderOperations(\App\Mvc\ViewAbstract $view, array $formData) { $view->getMessagesCollector()->addWarning($this->lang['index']['msgs']['info']); } }