toArray() public static method

Get all of the input and files for the request.
public static toArray ( ) : array
return array
Example #1
0
 /**
  * Store request object and error list in session
  *
  */
 public function saveState()
 {
     //@session_start();
     $_SESSION['validatorData'][$this->name]['error'] = $this->errorList;
     $_SESSION['validatorData'][$this->name]['data'] = $this->request->toArray();
     unset($_SESSION['validatorData'][$this->name]['data']['server']);
 }
 static function toXml($json, $objOption)
 {
     $obj = array('name' => $objOption[Request::BODY_TAG], 'attributes' => array('xmlns:xsi' => "http://www.w3.org/2001/XMLSchema-instance", 'xmlns:xsd' => "http://www.w3.org/2001/XMLSchema", 'MajorVersion' => 3, 'xmlns' => 'http://www.nrf-arts.org/IXRetail/namespace/'));
     $header = array();
     $header['name'] = 'ARTSHeader';
     $header['attributes'] = array('MessageType' => 'Request');
     $header[] = array('name' => 'DateTime', 'value' => date('c'));
     if ($objOption[Request::HEADER_OPTION]) {
         $header['attributes'] = array_merge($header['attributes'], $objOption[Request::HEADER_OPTION]);
     }
     $header[] = $objOption[Request::HEADER_CONTENT];
     $obj[] = $header;
     $body = array();
     $body['name'] = 'CustomerBody';
     $body['attributes'] = $objOption[Request::BODY_OPTION];
     $body = array_merge($body, Request::parseArray(Request::toArray($json)));
     $obj[] = $body;
     $doc = new DOMDocument();
     $child = Request::generate_xml_element($doc, $obj);
     if ($child) {
         $doc->appendChild($child);
     }
     $doc->formatOutput = true;
     // Add whitespace to make easier to read XML
     $xml = $doc->saveXML();
     return $xml;
 }
Example #3
0
 /**
  * Executes controller action (method) and gets a response instance
  *
  * Registers request data array if request is renderable
  *
  * @param string $actionName
  * @return Response
  */
 public final function execute($actionName)
 {
     $result = $this->init();
     if ($result instanceof Response) {
         return $result;
     }
     if (method_exists($this, $actionName) && $this->isAction($actionName)) {
         $response = call_user_func(array(&$this, $actionName));
         if ($response instanceof Response) {
             if ($response instanceof Renderable) {
                 $response->set("request", $this->request->toArray());
             }
             return $response;
         } else {
             return new RawResponse();
         }
     } else {
         throw new ActionNotFoundException($this);
     }
 }
Example #4
0
 public function testRequestShouldReturnCorrectSerializedArray()
 {
     $instance = new Request('http://www.google.com/', Request::METHOD_POST, array('param' => 'value'), array('X-Header' => 'value'), array(new Request\Cookie('Cookie', 'value')));
     $this->assertEquals(array('uri' => 'http://www.google.com/', 'method' => 'POST', 'params' => array('param' => 'value'), 'headers' => array('X-Header' => 'value'), 'cookies' => array(array('name' => 'Cookie', 'value' => 'value', 'domain' => NULL, 'path' => '/', 'httpOnly' => false, 'secure' => false, 'expires' => NULL))), $instance->toArray());
 }
 /**
  * Get all the services including require services
  * and optional services from request.
  *
  * @param Request $request
  *
  * @return Array services
  */
 private function getService($request)
 {
     /*
      * Get all the required services
      * from 'services' table.
      */
     $requireServices = $this->referenceRepository->requireService();
     /**
      * Get optional services id from user request, and store in
      * $requestServiceId. The format of the request services
      * is: 3 => 'on' therefore we retrieve
      * the option by 'on' value.
      */
     $requestServiceId = array();
     foreach ($request->toArray() as $key => $value) {
         if ($value == 'on') {
             array_push($requestServiceId, $key);
         }
     }
     /*
      * Get optional services using the
      * services id from request,
      */
     $optionalServices = $this->referenceRepository->optionalServiceIn($requestServiceId);
     /*
      * Merge the required services and optional
      * services, and return the array
      */
     $services = array();
     foreach ($requireServices as $requireService) {
         array_push($services, $requireService);
     }
     foreach ($optionalServices as $optionalService) {
         array_push($services, $optionalService);
     }
     return $services;
 }