Ejemplo n.º 1
0
 /**
  * Initializes this sfRequest.
  *
  * @param  sfEventDispatcher $dispatcher  An sfEventDispatcher instance
  * @param  array             $parameters  An associative array of initialization parameters
  * @param  array             $attributes  An associative array of initialization attributes
  *
  * @return bool true, if initialization completes successfully, otherwise false
  *
  * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfRequest
  */
 public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array())
 {
     parent::initialize($dispatcher, $parameters, $attributes);
     if (isset($_SERVER['REQUEST_METHOD'])) {
         switch ($_SERVER['REQUEST_METHOD']) {
             case 'GET':
                 $this->setMethod(self::GET);
                 break;
             case 'POST':
                 $this->setMethod(self::POST);
                 break;
             case 'PUT':
                 $this->setMethod(self::PUT);
                 break;
             case 'DELETE':
                 $this->setMethod(self::DELETE);
                 break;
             case 'HEAD':
                 $this->setMethod(self::HEAD);
                 break;
             default:
                 $this->setMethod(self::GET);
         }
     } else {
         // set the default method
         $this->setMethod(self::GET);
     }
     foreach ($this->getAttribute('formats', array()) as $format => $mimeTypes) {
         $this->setFormat($format, $mimeTypes);
     }
     // load parameters from GET/PATH_INFO/POST
     $this->loadParameters();
 }
Ejemplo n.º 2
0
 /**
  * Initializes this sfRequest.
  *
  * Available options:
  *
  *  * formats:           The list of supported format and their associated mime-types
  *  * path_info_key:     The path info key (default to PATH_INFO)
  *  * path_info_array:   The path info array (default to SERVER)
  *  * relative_url_root: The relative URL root
  *  * http_port:         The port to use for HTTP requests
  *  * https_port:        The port to use for HTTPS requests
  *
  * @param  sfEventDispatcher $dispatcher  An sfEventDispatcher instance
  * @param  array             $parameters  An associative array of initialization parameters
  * @param  array             $attributes  An associative array of initialization attributes
  * @param  array             $options     An associative array of options
  *
  * @return bool true, if initialization completes successfully, otherwise false
  *
  * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfRequest
  *
  * @see sfRequest
  */
 public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array())
 {
     $options = array_merge(array('path_info_key' => 'PATH_INFO', 'path_info_array' => 'SERVER', 'http_port' => null, 'https_port' => null, 'default_format' => null), $options);
     parent::initialize($dispatcher, $parameters, $attributes, $options);
     // GET parameters
     $this->getParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_GET) : $_GET;
     $this->parameterHolder->add($this->getParameters);
     $postParameters = $_POST;
     if (isset($_SERVER['REQUEST_METHOD'])) {
         switch ($_SERVER['REQUEST_METHOD']) {
             case 'GET':
                 $this->setMethod(self::GET);
                 break;
             case 'POST':
                 if (isset($_POST['sf_method'])) {
                     $this->setMethod(strtoupper($_POST['sf_method']));
                     unset($postParameters['sf_method']);
                 } elseif (isset($_GET['sf_method'])) {
                     $this->setMethod(strtoupper($_GET['sf_method']));
                     unset($_GET['sf_method']);
                 } else {
                     $this->setMethod(self::POST);
                 }
                 $this->parameterHolder->remove('sf_method');
                 break;
             case 'PUT':
                 $this->setMethod(self::PUT);
                 if ('application/x-www-form-urlencoded' === $this->getContentType()) {
                     parse_str($this->getContent(), $postParameters);
                 }
                 break;
             case 'DELETE':
                 $this->setMethod(self::DELETE);
                 if ('application/x-www-form-urlencoded' === $this->getContentType()) {
                     parse_str($this->getContent(), $postParameters);
                 }
                 break;
             case 'HEAD':
                 $this->setMethod(self::HEAD);
                 break;
             default:
                 $this->setMethod(self::GET);
         }
     } else {
         // set the default method
         $this->setMethod(self::GET);
     }
     $this->postParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($postParameters) : $postParameters;
     $this->parameterHolder->add($this->postParameters);
     if (isset($this->options['formats'])) {
         foreach ($this->options['formats'] as $format => $mimeTypes) {
             $this->setFormat($format, $mimeTypes);
         }
     }
     // additional parameters
     $this->requestParameters = $this->parseRequestParameters();
     $this->parameterHolder->add($this->requestParameters);
     $this->fixParameters();
 }
 /**
  * Initializes this sfRequest.
  *
  * Available options:
  *
  *  * formats:           The list of supported format and their associated mime-types
  *  * path_info_key:     The path info key (default to SERVER)
  *  * path_info_array:   The path info key (default to PATH_INFO)
  *  * relative_url_root: The relative URL root
  *
  * @param  sfEventDispatcher $dispatcher  An sfEventDispatcher instance
  * @param  array             $parameters  An associative array of initialization parameters
  * @param  array             $attributes  An associative array of initialization attributes
  * @param  array             $options     An associative array of options
  *
  * @return bool true, if initialization completes successfully, otherwise false
  *
  * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfRequest
  *
  * @see sfRequest
  */
 public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array())
 {
     parent::initialize($dispatcher, $parameters, $attributes, $options);
     // GET parameters
     $this->getParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_GET) : $_GET;
     $this->parameterHolder->add($this->getParameters);
     // POST parameters
     $this->postParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($_POST) : $_POST;
     $this->parameterHolder->add($this->postParameters);
     if (isset($_SERVER['REQUEST_METHOD'])) {
         switch ($_SERVER['REQUEST_METHOD']) {
             case 'GET':
                 $this->setMethod(self::GET);
                 break;
             case 'POST':
                 $this->setMethod(strtoupper($this->getParameter('sf_method', 'POST')));
                 $this->parameterHolder->remove('sf_method');
                 break;
             case 'PUT':
                 $this->setMethod(self::PUT);
                 $putParameters = array();
                 parse_str($this->getContent(), $putParameters);
                 $putParameters = get_magic_quotes_gpc() ? sfToolkit::stripslashesDeep($putParameters) : $putParameters;
                 $this->parameterHolder->add($putParameters);
                 break;
             case 'DELETE':
                 $this->setMethod(self::DELETE);
                 break;
             case 'HEAD':
                 $this->setMethod(self::HEAD);
                 break;
             default:
                 $this->setMethod(self::GET);
         }
     } else {
         // set the default method
         $this->setMethod(self::GET);
     }
     if (isset($this->options['formats'])) {
         foreach ($this->options['formats'] as $format => $mimeTypes) {
             $this->setFormat($format, $mimeTypes);
         }
     }
     if (!isset($this->options['path_info_key'])) {
         $this->options['path_info_key'] = 'PATH_INFO';
     }
     if (!isset($this->options['path_info_array'])) {
         $this->options['path_info_array'] = 'SERVER';
     }
     // additional parameters
     $this->requestParameters = $this->parseRequestParameters();
     $this->parameterHolder->add($this->requestParameters);
     $this->fixParameters();
 }
Ejemplo n.º 4
0
 public function initialize($context, $parameters = array(), $attributes = array())
 {
     parent::initialize($context, $parameters, $attributes);
     if (isset($_SERVER['REQUEST_METHOD'])) {
         switch ($_SERVER['REQUEST_METHOD']) {
             case 'GET':
                 $this->setMethod(self::GET);
                 break;
             case 'POST':
                 $this->setMethod(self::POST);
                 break;
             case 'PUT':
                 $this->setMethod(self::PUT);
                 break;
             case 'DELETE':
                 $this->setMethod(self::DELETE);
                 break;
             case 'HEAD':
                 $this->setMethod(self::HEAD);
                 break;
             default:
                 $this->setMethod(self::GET);
         }
     } else {
         $this->setMethod(self::GET);
     }
     $this->loadParameters();
 }
 /**
  * Initializes this sfRequest.
  *
  * @param sfContext A sfContext instance
  * @param array   An associative array of initialization parameters
  * @param array   An associative array of initialization attributes
  *
  * @return boolean true, if initialization completes successfully, otherwise false
  *
  * @throws <b>sfInitializationException</b> If an error occurs while initializing this Request
  */
 public function initialize($context, $parameters = array(), $attributes = array())
 {
     parent::initialize($context, $parameters, $attributes);
     $this->getParameterHolder()->add($_SERVER['argv']);
 }
 /**
  * Initializes this sfRequest.
  *
  * @param  sfEventDispatcher $dispatcher  An sfEventDispatcher instance
  * @param  array             $parameters  An associative array of initialization parameters
  * @param  array             $attributes  An associative array of initialization attributes
  * @param  array             $options     An associative array of options
  *
  * @return bool true, if initialization completes successfully, otherwise false
  *
  * @throws <b>sfInitializationException</b> If an error occurs while initializing this sfRequest
  */
 public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array(), $options = array())
 {
     parent::initialize($dispatcher, $parameters, $attributes, $options);
     $this->getParameterHolder()->add($_SERVER['argv']);
 }