Example #1
0
 /**
  * Process a HTTP request.
  *
  * <p>This implementation will delegate request handling based on the method parameter in
  * the request. If no method is found, the default <em>parent</em> <code>process()</code> implementation
  * will be called.</p>
  *
  * <p>Also, if the passed method is not found, the controller will try to resolve the method by appending the
  * configured <em>ajaxFormat</em> string. So, if, for example, the method is <code>getCountries</code> and <em>ajaxFormat</em> is
  * <code>JSON</code>, the controller will first look for <code>getCountries</code> and then for <code>getCountriesJSON</code>.</p>
  *
  * @return View A <code>View</code> instance or <code>null</code>.
  */
 public function processAction(Request $request)
 {
     $method = $sacsMethod = $request->getParameter('method');
     if (!method_exists($this, $method)) {
         $method = $method . 'JSON';
     }
     $sacsManager = $this->container->get('sacsManager');
     // check access on controller level
     $sacsManager->authorize($request, $request->getRequestId(), $this->getUser());
     // (re-)check on method level if mapping exists
     $methodRequestId = $request->getRequestId() . '#' . $sacsMethod;
     if ($sacsManager->hasMappingForRequestId($methodRequestId)) {
         $sacsManager->authorize($request, $methodRequestId, $this->getUser());
     }
     if (method_exists($this, $method) || in_array($method, $this->getAttachedMethods())) {
         $this->{$method}($request);
         return null;
     }
     return parent::processAction($request);
 }
 /**
  * {@inheritDoc}
  */
 public function processAction(Request $request)
 {
     $view = parent::processAction($request);
     if ($view instanceof RedirectView) {
         $view->setUrl($this->get('adminTool')->catalog($this));
     }
     return $view;
 }
 /**
  * {@inheritDoc}
  */
 public function processAction(Request $request)
 {
     $controllers = $this->getCatalogContentControllers($request);
     $controller = null;
     if (null == ($catalogRequestId = $request->query->get('catalogRequestId'))) {
         if (0 < count($controllers)) {
             $controller = $controllers[0];
             $catalogRequestId = $controller->getCatalogRequestId();
             $this->get('logger')->debug('defaulting to controller : ' . get_class($controller));
         }
     } else {
         // let's see if we have a controller for this...
         $definition = Toolbox::className($catalogRequestId . 'Controller');
         $controller = Beans::getBean($definition);
         $this->get('logger')->debug('delegating to controller : ' . get_class($controller));
     }
     // check authorization as we'll need the follow up redirect point to the catalog URL, not a tab url
     $authorized = $this->container->get('sacsManager')->authorize($request, $request->getRequestId(), $this->getUser(), false);
     if (null == $controller || !$authorized) {
         // no controller found
         return parent::processAction($request);
     }
     // fake requestId
     $requestId = $request->getRequestId();
     $request->setRequestId($catalogRequestId);
     // processAction
     $catalogViewContent = null;
     try {
         $catalogContentView = $controller->processAction($request);
         $catalogContentView->setLayout(null);
         $catalogViewContent = $catalogContentView->generate($request);
     } catch (Exception $e) {
         $catalogViewContent = null;
     }
     // restore for normal processing
     $request->setRequestId($requestId);
     // now do the normal thing
     $view = parent::processAction($request);
     // add catalog content view to be used in catalog view template
     $view->setVariable('catalogRequestId', $catalogRequestId);
     $view->setVariable('catalogViewContent', $catalogViewContent);
     $view->setVariable('controllers', $controllers);
     return $view;
 }