本文整理汇总了PHP中sfRequest::getContent方法的典型用法代码示例。如果您正苦于以下问题:PHP sfRequest::getContent方法的具体用法?PHP sfRequest::getContent怎么用?PHP sfRequest::getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfRequest
的用法示例。
在下文中一共展示了sfRequest::getContent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Execute: Проверяет входящие данные
*
* @param sfRequest $request
* @see executeLogic конкретная реализация логики
*/
public final function execute($request)
{
try {
if (null === ($userId = $this->getUser()->getId())) {
$this->getResponse()->setHttpHeader('WWW_Authenticate', "Authentification required");
$this->raiseError("Authentification required", 0, 401);
}
if (0 === strlen($rawXml = $request->getContent())) {
$this->raiseError("Expected XML data");
}
if (false === strpos($rawXml, "<?xml")) {
$this->raiseError("Expected valid text/xml");
}
try {
$xml = simplexml_load_string($rawXml);
} catch (Exception $e) {
$this->raiseError("Expected valid text/xml: see xmlsoft.org");
// $xml = new SimpleXMLElement('');
}
$this->setXML($xml);
$count = (int) count($xml->recordset[0]);
$limit = sfConfig::get('app_records_sync_limit', 100);
if ($count <= 0) {
$this->raiseError("Expected at least one record");
} elseif ($count > $limit) {
$this->raiseError("More than 'limit' ({$limit}) objects sent, {$count}");
}
$cids = $this->filterByXPath("//record/@cid", "cid");
if (count($cids) != $count) {
$this->raiseError("Request is NOT well-formed: no client ids");
}
} catch (sfStopException $e) {
return $this->handleException($e);
}
try {
return $this->executeLogic($request);
} catch (Exception $e) {
return $this->handleException($e);
}
}