Exemplo n.º 1
0
Arquivo: Form.php Projeto: vanuatu/Zzz
 /**
  *
  *
  */
 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);
 }
Exemplo n.º 2
0
 /**
  *
  *
  */
 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;
 }