protected function isParametersValid()
 {
     $status = parent::isParametersValid();
     if (!$status) {
         $event = new ParameterEvent($this->parametersMeta);
         $this->getDispatcher()->dispatch(ParameterEvent::PARAMETER_ERROR, $event);
     }
     //TODO disparar o PARAMETER_SUCCESS
     return $status;
 }
Esempio n. 2
0
 /**
  * Método interno utilizado para realizar o procesamento da ação solicitada
  * @param type $action
  */
 private final function _processRequest($action)
 {
     $this->method = $action;
     //Define o nome do método que deverá ser chamado
     $method = '_' . $action;
     if (!method_exists($this, $method)) {
         if (method_exists($this, $this->defaultMethod)) {
             $method = $this->defaultMethod;
         } else {
             $method = '';
         }
     }
     if (empty($method)) {
         $errorPage = Factory::page('ErrorPage');
         $errorPage->setErrorMessage('O Método solicitado: "' . $action . '" não foi implementado');
         return $errorPage;
     } else {
         $this->preProcess();
         if ($this->canAccess()) {
             $this->executeMethod($method);
         } else {
             //permissão negada
             $deniedaccess = Factory::page("DeniedacessPage");
             $deniedaccess->service(ProcessRequest::getMethod(), "_index", ResponseType::getDefaultType());
             exit;
         }
         $this->posProcess();
     }
 }
Esempio n. 3
0
 *      /[page]/[id]/[action]
 *      /[page]/[id]/[action]?responseType=[format]
 * 
 *      /[page]/[id]/[action]/[format]
 * 
 *      
 */
require_once "vendor/autoload.php";
/**
* Display all errors when APPLICATION_ENV is development.
*/
if ($_SERVER['APPLICATION_ENV'] == 'development') {
    error_reporting(E_ALL);
    ini_set("display_errors", 1);
}
require_once 'bootstrap.php';
$pageclass = filter_input(INPUT_GET, '_page', FILTER_SANITIZE_STRING);
if (empty($pageclass)) {
    $pageclass = 'main';
}
$action = filter_input(INPUT_GET, '_action', FILTER_SANITIZE_STRING);
if (empty($action)) {
    $action = '';
}
$type = filter_input(INPUT_GET, 'responseType', FILTER_CALLBACK, array("options" => "ResponseType::getDefaultType"));
$page = Factory::page($pageclass);
if (filter_has_var(INPUT_GET, '_id')) {
    $page->setId(filter_input(INPUT_GET, '_id', FILTER_SANITIZE_STRING));
}
$page->service(ProcessRequest::getMethod(), $action, $type);
 public function testGetMethod()
 {
     $this->assertFalse(headers_sent(), "O header já foi enviado ? por quem ? onde ? pelo ResponseHTML ?");
     $this->assertFalse(ProcessRequest::isGETRequest());
     $this->assertFalse(ProcessRequest::isPOSTRequest());
     $this->assertEquals(RequestType::GET, ProcessRequest::getMethod());
     $this->object->service(RequestType::GET, 'main', ResponseType::HTML);
     $this->assertEquals(RequestType::GET, ProcessRequest::getMethod());
     $this->assertTrue(ProcessRequest::isGETRequest());
     $this->assertFalse(ProcessRequest::isPOSTRequest());
     $this->object->service(RequestType::POST, 'main', ResponseType::HTML);
     $this->assertEquals(RequestType::POST, ProcessRequest::getMethod());
     $this->assertFalse(ProcessRequest::isGETRequest());
     $this->assertTrue(ProcessRequest::isPOSTRequest());
 }