public function execute(AgaviFilterChain $filterChain, AgaviExecutionContainer $container)
 {
     $isGlobal = ++self::$runCount == 1;
     if ($isGlobal) {
         // We are called from a global filterchain
         //trigger datasource event listeners
         foreach ($this->rq->getAttribute('datasources', self::NS, array()) as $ds) {
             $ds->beforeExecuteOnce($container);
         }
     } else {
         // This is a action filterchain
         //trigger datasource event listeners
         foreach ($this->rq->getAttribute('datasources', self::NS, array()) as $ds) {
             $ds->beforeExecute($container);
         }
     }
     // Proceed with execution
     $filterChain->execute($container);
     if ($isGlobal) {
         // We are called from a global filterchain
         //trigger datasource event listeners
         foreach ($this->rq->getAttribute('datasources', self::NS, array()) as $ds) {
             $ds->afterExecuteOnce($container);
         }
         //log global (i.e. not per action) stuff
         $this->rq->setAttribute('routes', $this->getMatchedRoutes(), self::NS_DATA);
         $this->rq->setAttribute('request_data', array('request_parameters' => $this->getContext()->getRequest()->getRequestData()->getParameters(), 'cookies' => $this->getContext()->getRequest()->getRequestData()->getCookies(), 'headers' => $this->getContext()->getRequest()->getRequestData()->getHeaders()), self::NS_DATA);
         $this->rq->setAttribute('tm', $this->getContext()->getTranslationManager(), self::NS_DATA);
         //		$this->log['environments'] = $this->getAvailableEnvironments();
         $this->render($container);
     } else {
         //trigger datasource event listeners
         foreach ($this->rq->getAttribute('datasources', self::NS, array()) as $ds) {
             $ds->afterExecute($container);
         }
         //now the action has been executed and we'll log what can be logged
         if (true) {
             //FIXME: options: in_array('actions', $this->options['sections'])) {
             $this->log($container);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Adds the validation report to the current request to retain error messages
  * when forwarding (like <code>return $this->createForwardContainer('Foo', 'Bar');</code>).
  *
  * Background: The \AgaviFormPopulationFilter gets the validation report
  * from the AgaviExecutionContainer of the initial request (the main agavi
  * action called) and uses that report to fill forms with data taken from
  * the request (form fields and values).
  *
  * If your forms are not populated automatically, check that you have an
  * id and an action attribute on the form element and call this method in
  * the view of the action that was being forwarded to internally.
  *
  * @return void
  */
 protected function addValidationReportToRequestForFpf()
 {
     $this->request->setAttribute('validation_report', $this->getContainer()->getValidationManager()->getReport(), 'org.agavi.filter.FormPopulationFilter');
 }