本文整理汇总了PHP中sfWebRequest::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWebRequest::getContent方法的具体用法?PHP sfWebRequest::getContent怎么用?PHP sfWebRequest::getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWebRequest
的用法示例。
在下文中一共展示了sfWebRequest::getContent方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeCreate
/**
* Creates a EpisodeAssignment object
* @param sfWebRequest $request a request object
* @return string
*/
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0) {
$content = $request->getParameter('content');
}
if ($content === false) {
$content = $request->getPostParameter('content');
// Last chance to get the content!
}
$request->setRequestFormat('html');
try {
$parameters = $request->getParameterHolder()->getAll();
$params = $this->getApiAuthFieldValues($parameters, $content);
$this->validateApiAuth($parameters, $content);
$this->validateCreate($content, $request);
} catch (Exception $e) {
$this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
$this->setTemplate('index');
return sfView::SUCCESS;
}
$object_params = $this->parsePayload($content);
if (!array_key_exists('sf_guard_user_id', $object_params)) {
$object_params['sf_guard_user_id'] = $this->getUser()->getGuardUser()->getIncremented();
}
$this->object = $this->createObject();
$this->object->importFrom('array', $object_params);
try {
$return = $this->doSave($params);
} catch (Exception $e) {
$this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
$this->setTemplate('index');
return sfView::SUCCESS;
}
return $return;
}
示例2: executeCreate
/**
* Creates a rfid_groupe object :
* affecter tous les badges rfid groupe sélectionnés
* générer des visiteurs anonymes (autant qu'il y a de badges)
* générer une visite à chaque visiteur
*
* @param sfWebRequest $request a request object
* @return string
*/
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0) {
$content = $request->getParameter('content');
}
$request->setRequestFormat('html');
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
try {
$this->validateCreate($content);
} catch (Exception $e) {
$this->getResponse()->setStatusCode(406);
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
$this->setTemplate('index');
return sfView::SUCCESS;
}
$this->object = $this->createObject();
$this->updateObjectFromRequest($content);
$this->doSave();
}
示例3: executeSync
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeSync(sfWebRequest $request)
{
include_once sfConfig::get('sf_root_dir') . '/apps/api/lib/PlancakeApiServer.class.php';
parse_str(urldecode($request->getContent()), $requestParams);
$tasks = isset($requestParams['tasks']) && is_array($requestParams['tasks']) ? $requestParams['tasks'] : array();
$changes = PlancakeApiServer::sync(array('from_ts' => $requestParams['from_ts'], 'tasks' => $tasks, 'camel_case_keys' => 1, 'api_ver' => sfConfig::get('app_api_version')));
if ($request->isXmlHttpRequest()) {
return $this->renderJson($changes);
}
}
示例4: executeUpdate
/**
* Updates a Visiteur object
* @param sfWebRequest $request a request object
* @return string
*/
public function executeUpdate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0) {
$content = $request->getParameter('content');
}
$parameters = $this->parsePayload($content, true);
$this->preference_media_ids = array_key_exists('preference_media_id', $parameters) ? $parameters['preference_media_id'] : "";
$serializer = $this->getSerializer();
$content = $serializer->serialize($parameters);
try {
$this->validateUpdate($content);
if (isset($parameters['pseudo_son'])) {
$visiteur = Doctrine::getTable('Visiteur')->isUpdatePseudoUnique($parameters['guid'], $parameters['pseudo_son']);
if (count($visiteur)) {
$this->getResponse()->setStatusCode(406);
$result = array(array('message' => sprintf('visitor already exist %s ', $parameters['pseudo_son']), 'code' => 'E_VISITEUR_00'));
$this->output = $serializer->serialize($result, 'error');
return sfView::SUCCESS;
}
}
} catch (Exception $e) {
$this->getResponse()->setStatusCode(406);
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
return sfView::SUCCESS;
}
$primaryKey = $request->getParameter('guid');
if (empty($primaryKey)) {
$primaryKey = $parameters["guid"];
}
$this->object = Doctrine_Core::getTable($this->model)->findOneByGuid($primaryKey);
if ($parameters["is_anonyme"] == false && $this->object->getIsAnonyme() == true) {
$this->is_anonyme_converted = true;
}
// update and save it
$this->updateObjectFromRequest($content);
return $this->doSave();
}
示例5: executeCreate
/**
* Creates a VisiteurMedaille object
* @param sfWebRequest $request a request object
* @return string
*/
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0) {
$content = $request->getParameter('content');
}
$request->setRequestFormat('html');
$serializer = $this->getSerializer();
try {
$params = $this->parsePayload($content);
$this->validateCreate($content, $params);
$this->getResponse()->setContentType($serializer->getContentType());
$this->object = $this->createObject();
$this->updateObjectFromRequest($content);
//$connection = isset($params['connection'])?$params['connection']: 'insitu';
if ($this->object->hasAlreadyMedaille($params['univers_id'], $params['contexte_id'])) {
throw new Exception(sprintf("The medal %s is unique for this visitor %s", $this->object->getMedailleId(), $this->object->getVisiteurId()));
}
$this->doSave();
VisiteurUniversStatusGainTable::hasNewStatus($this->object->getVisiteurId(), $this->object->getMedailleId(), $this->object->getContexteId());
$output = array(array('message' => "ok"));
$this->output = $serializer->serialize($output);
} catch (Exception $e) {
$this->getResponse()->setStatusCode(406);
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
$this->setTemplate('index');
return sfView::SUCCESS;
}
return sfView::SUCCESS;
}
示例6: executeToken
/**
* Creates a token referring to an sfGuardUser object
* @param sfWebRequest $request a request object
* @return string
*/
public function executeToken(sfWebRequest $request)
{
//$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0) {
$content = $request->getParameter('content');
}
if ($content === false) {
$content = $request->getPostParameter('content');
// Last chance to get the content!
}
$request->setRequestFormat('html');
$this->setTemplate('index');
try {
$parameters = $request->getParameterHolder()->getAll();
$params = $this->getApiAuthFieldValues($parameters, $content);
$this->validateApiAuth($parameters, $content);
$this->validateToken($content);
$auth_key = $this->requestToken($content);
$data = $this->parsePayload($content);
$email_address = $data['email_address'];
} catch (Exception $e) {
$this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
$this->setTemplate('index');
return sfView::SUCCESS;
}
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$user = sfGuardUserTable::getInstance()->findOneBy('email_address', $email_address);
$user_id = $user && $auth_key ? $user->getIncremented() : null;
$this->output = $serializer->serialize(array('auth_key' => $auth_key, 'user_id' => $user_id), $this->model, false);
}
示例7: executeUpdateMarket
/**
* Updates a Visite object
* @param sfWebRequest $request a request object
* @return string
*/
public function executeUpdateMarket(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0) {
$content = $request->getParameter('content');
}
$parameters = $this->parsePayload($content, true);
if (isset($parameters['connexion_id'])) {
$connexion_id = $parameters['connexion_id'];
unset($parameters['connexion_id']);
}
$serializer = $this->getSerializer();
$content = $serializer->serialize($parameters);
$request->setRequestFormat('html');
try {
$this->validateUpdateMarket($content);
$this->object = Doctrine_Core::getTable($this->model)->findOneByConnexionId($connexion_id);
} catch (Exception $e) {
$this->getResponse()->setStatusCode(406);
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
return sfView::SUCCESS;
}
if (!$this->object) {
$this->object = $this->createObject();
$this->object->set('guid', Guid::generate());
}
// update and save it
$this->updateObjectFromRequest($content);
$response = $this->doSave();
if (isset($connexion_id) && !empty($connexion_id)) {
// Notify websocket server
caNotificationsTools::getInstance()->notifyAuth($this->object['guid'], $connexion_id);
}
if (isset($is_ending) && $is_ending == true) {
// Notify websocket server
caNotificationsTools::getInstance()->notifyReset($this->object['guid']);
}
return $response;
}
示例8: executeUpload_outro
/**
* Allows for the upload of a Subreddit intro sound file.
* @param sfWebRequest $request a request object
* @return string
*/
public function executeUpload_outro(sfWebRequest $request)
{
// PUT makes more sense, but I am limited currently by my API to POST.
$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0 || $request->hasParameter('content')) {
$content = $request->getParameter('content');
}
$request->setRequestFormat('html');
try {
$parameters = $request->getParameterHolder()->getAll();
$params = $this->getApiAuthFieldValues($parameters, $content);
$this->validateUpload($content, $request);
} catch (Exception $e) {
$this->getResponse()->setStatusCode($e->getCode() ? $e->getCode() : 406);
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
$this->setTemplate('index');
return sfView::SUCCESS;
}
// We move the file from its temporary location to the Episode in question.
if ($this->_nice_filename && $this->_temporary_file_location) {
$targetDir = rtrim(ProjectConfiguration::getSubredditAudioFileLocalDirectory(), '/');
$pattern = '/\\.([^\\.]+)$/';
preg_match($pattern, $filename, $matches);
$extension = array_key_exists(1, $matches) ? $matches[1] : 'mp3';
// We don't need the upload hash because we're not uploading AJAX-like in real time.
$hash = sha1(microtime() . $this->object->getIncremented());
$fileName = $hash . '.' . $extension;
//Move the file.
rename($this->_temporary_file_location, $targetDir . '/' . $fileName);
// update and save it
$this->object->setEpisodeOutro($fileName);
}
return $this->doSave($params);
}
示例9: executeCreate
public function executeCreate(sfWebRequest $request)
{
$this->forward404Unless($request->isMethod(sfRequest::POST));
$content = $request->getContent();
// Restores backward compatibility. Content can be the HTTP request full body, or a form encoded "content" var.
if (strpos($content, 'content=') === 0) {
$content = $request->getParameter('content');
}
$request->setRequestFormat('html');
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$parameters = $this->parsePayload($content, true);
// $content = $serializer->serialize($parameters);
$interactif_id = $parameters['interactif_id'];
$visite_id = isset($parameters['visite_id']) ? $parameters['visite_id'] : '';
$start_at = $parameters['start_at'];
$end_at = $parameters['end_at'];
$connection = $parameters['connection'];
if ($start_at) {
$start_at = date('Y-m-d H:i:s', $start_at);
$parameters['start_at'] = $start_at;
}
if ($end_at) {
$end_at = date('Y-m-d H:i:s', $end_at);
$parameters['end_at'] = $end_at;
}
try {
if (isset($connection) && $connection == 'insitu') {
$this->validateCreateInsitu($content);
} else {
$this->validateCreate($content);
}
} catch (Exception $e) {
$this->getResponse()->setStatusCode(406);
$serializer = $this->getSerializer();
$this->getResponse()->setContentType($serializer->getContentType());
$error = $e->getMessage();
// event filter to enable customisation of the error message.
$result = $this->dispatcher->filter(new sfEvent($this, 'sfDoctrineRestGenerator.filter_error_output'), $error)->getReturnValue();
if ($error === $result) {
$error = array(array('message' => $error));
$this->output = $serializer->serialize($error, 'error');
} else {
$this->output = $serializer->serialize($result);
}
return sfView::SUCCESS;
}
$this->object = $this->createObject();
$this->updateObjectFromRequest($serializer->serialize($parameters));
return $this->doSave();
}