/** * 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); } }