Ejemplo n.º 1
0
 /**
  * @expectedException \ExtDirect\Exceptions\ExtDirectException
  */
 public function testRunInvalidGenericMethodCallMethod()
 {
     $requestParams = array();
     $requestParams['type'] = "rpc";
     $requestParams['tid'] = 1;
     $requestParams['action'] = "FirstDemo";
     $requestParams['method'] = "getTree";
     $requestParams['data'] = array("demoKey" => "demoValue");
     $request = new ExtDirectRequest(false, $this->demoAppPath, $this->demoAppNameSpace);
     // parameter validation here
     $response = new ExtDirectResponse();
     $requestParameters = new Parameters();
     $requestParameters->setParameters($requestParams);
     // inject parameters instance into request and response object to get access to all relevant params
     $request->injectParameters($requestParameters);
     $response->injectParameters($requestParameters);
     $request->injectResponse($response);
     $request->setParamMethod("setParams");
     $request->setMethodCalls(array("invalidMethod" => array("dummy")));
     $request->run();
 }
Ejemplo n.º 2
0
 /**
  * process a single ext direct request
  *
  * @param array $requestParams the ext direct request as array
  *
  * @return array
  */
 protected function process(array $requestParams)
 {
     $request = new ExtDirectRequest($this->useCache(), $this->getApplicationPath(), $this->getApplicationNameSpace());
     $response = new ExtDirectResponse();
     $requestParameters = new Parameters();
     try {
         // parameter validation here
         $request->setApplicationPath($this->getApplicationPath());
         $requestParameters->setParameters($requestParams);
         // inject parameters instance into request and response object to get access to all relevant params
         $request->injectParameters($requestParameters);
         $response->injectParameters($requestParameters);
         $request->injectResponse($response);
         $request->setParamMethod($this->getParamMethod());
         $request->setMethodCalls($this->getMethodsToCall());
         $request->run();
     } catch (ExtDirectApplicationException $e) {
         $result = $e->getResponse();
         if (!empty($result)) {
             $response->setResult(array("success" => false, "message" => $e->getMessage(), "actions" => $result));
         } else {
             $response->setResult(array("success" => false, "message" => $e->getMessage()));
         }
     } catch (\Exception $e) {
         $response->setResult(array("success" => false, "message" => $e->getMessage()));
     }
     return $response;
 }