/** * Set RAISe Requested Resource * Resource Model by the HTTP Request Requested Uri * * @note A string manipulation is applied since php's * function strstr will return null if the desired match * isn't present. */ public function setResource() { /* get resource string from requested url */ $resourceString = strtolower(str_replace('/', '', $this->getRequest()->getRequestUri())); /* stores resource model applying the string manipulation */ $this->requestedResource = RaiseManager::getFactory('resource')->get(strpos($resourceString, '?') !== false ? strstr($resourceString, '?', true) : $resourceString); }
/** * Execute's MySQL Query with the Instruction Factory * Generated Statement */ public function execute() { $this->statement = DatabaseManager::getInstance()->query(RaiseManager::getFactory('instruction')->getInstruction(), RaiseManager::getFactory('instruction')->getStatement()); switch (RaiseManager::getHandler('request')->getRequest()->getMethod()) { case 'GET': $this->response = $this->statement->fetchAll(PDO::FETCH_OBJ); break; case 'POST': $this->lastInsertId = DatabaseManager::getInstance()->getLastInsertId(); break; } }
/** * Used to set the HTTP Response Content * as an RAISe Message (object) * * @param string $message Message Name * @param array $templateEngine */ public function setMessage($message, array $templateEngine = array()) { if (!$this->messageDefined) { $this->getResponse()->setData(RaiseManager::getFactory('message')->get($message, $templateEngine)->__getResult()); $this->messageDefined = true; } }