本文整理汇总了PHP中sfRequest::initialize方法的典型用法代码示例。如果您正苦于以下问题:PHP sfRequest::initialize方法的具体用法?PHP sfRequest::initialize怎么用?PHP sfRequest::initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfRequest
的用法示例。
在下文中一共展示了sfRequest::initialize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
/**
* 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();
}
示例2: initialize
/**
* 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();
}
示例3: initialize
/**
* 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();
}
示例4: initialize
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();
}
示例5: initialize
/**
* 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']);
}
示例6: initialize
/**
* 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']);
}