/** * * */ private function loadEvents() { $action = $this->action; $eventsConfig = $this->config->{$action}->events; $emptyFunction = function () { }; $events = new \stdClass(); $events->before = new \stdClass(); $events->before->{$action} = $emptyFunction; $events->after = new \stdClass(); $events->after->{$action} = $emptyFunction; $events->on = new \stdClass(); $events->on->validate = $emptyFunction; if (isset($eventsConfig->before->{$action})) { $events->before->{$action} = Util::getPhpFunction(Util::normalizePath($this->root, $eventsConfig->before->{$action})); } if (isset($eventsConfig->after->{$action})) { $events->after->{$action} = Util::getPhpFunction(Util::normalizePath($this->root, $eventsConfig->after->{$action})); } if (isset($eventsConfig->on->{$action})) { $events->on->{$action} = Util::getPhpFunction(Util::normalizePath($this->root, $eventsConfig->on->{$action})); } return $events; }
/** * * */ private function genericFormEvent($when, $eventName) { global $VNT; // // if (empty($this->formEvents)) { $fileEvents = isset($this->formData->events) ? Util::normalizePath($VNT->app->folder->forms, $this->formData->events) : ($fileEvents = $VNT->file->form->events); $this->formEvents = Util::getPhpFunction($fileEvents)(); } // OBJETO PARA REFERENCIA $formReference = new StdClassDyn(); $formReference->final =& $this->finalData; $formReference->loaded = $this->dataLoaded; // $formReference->error = function ($code, $message, $input) use($when, $eventName) { $this->validation["error"] = true; $this->validation["detail"][] = ["code" => $code, "message" => $message, "event" => "{$when}.{$eventName}", "input" => $input]; }; // $event = $this->formEvents->{$when}->{$eventName}; // $event($formReference); }
// // // test Form // use Vanuatu\Admin\Form; // $form = new Form(Form::INSERT, "people.yaml", "cadastro_pessoa", "group:dados_pessoais>input:cpf"); // $form = new Form(Form::INSERT, "people.yaml", "cadastro_pessoa", "group:dados_pessoais"); // $form = new Form(Form::INSERT, "people.yaml", "cadastro_pessoa", ""); // echo $form; use Vanuatu\Template\Template; use Vanuatu\Admin\Form\Form; use Vanuatu\Log\Log; use Vanuatu\Util; // // MOSTRA TELA DE ERRO PARA AÇÃO NÃO DEFINIDA // if (empty($VNT->fw->url->parameters->action)) { $errorPage = new Template(Util::normalizePath($VNT->app->folder->template, "error.phtml"), ["code" => Log::error(), "message" => "nenhuma ação definida"]); echo $errorPage; die; } // // EXECUTA AÇÕES // switch ($VNT->fw->url->parameters->action) { // // EXEMPLO DE URL // /view // /event:insert // /form:cadastro_pessoa // /path:group:dados_pessoais%3Einput:cpf // /file:people.yaml //