Beispiel #1
0
 public function testGetSetFilterChain()
 {
     $fc = FrontController::getInstance();
     $manager = new FilterManager($fc);
     $this->assertEmpty($manager->getFilterChain()->getFilters(), print_r($manager->getFilterChain()->getFilters(), true));
     $fc->destroy();
 }
 public function validate()
 {
     $this->helper = (include FrontController::getRootPath() . "/src/cli_config.php");
     $validator = Validation::createValidatorBuilder()->enableAnnotationMapping()->getValidator();
     $violations = $validator->validate($this);
     return $violations;
 }
 /**
  * Render the view into a string and return for output
  *
  * @param mixed $input
  * @return string
  * @throws \Exception
  */
 public function render($input = null)
 {
     $context = new SerializationContext();
     $context->setSerializeNull(true);
     $context->enableMaxDepthChecks();
     FrontController::getInstance()->getResponse()->headers->set('Content-Type', 'application/json');
     return $this->serializer->serialize($input, $this->format, $context);
 }
Beispiel #4
0
     * @return bool
     */
    public function filterResponse(Response $response)
    {
        // TODO: Implement filterResponse() method.
    }
}
class RatelimitFilter implements \Framework\Request\Filter\FilterInterface
{
    /**
     * @param Request $request
     * @return bool
     */
    public function filterRequest(Request $request)
    {
        var_dump("ratelimiting bro");
    }
    /**
     * @param Response $response
     * @return bool
     */
    public function filterResponse(Response $response)
    {
        // TODO: Implement filterResponse() method.
    }
}
$fc = \Framework\Controller\FrontController::getInstance();
$fc->addFilter(new AuthFilter());
$fc->addFilter(new RatelimitFilter());
$response = $fc->execute(Request::createFromGlobals());
$response->send();
 public function testGetSetResponse()
 {
     FrontController::$routesFile = __DIR__ . "/Fixtures/routes.php";
     $routes = (include __DIR__ . "/Fixtures/routes.php");
     $fc = FrontController::getInstance();
     $response = $this->getMock(Response::class);
     $fc->setResponse($response);
     $this->assertSame($response, $fc->getResponse());
     $fc->destroy();
 }
 protected function getTemplatePath()
 {
     return rtrim(FrontController::getRootPath(), DIRECTORY_SEPARATOR) . "/" . ltrim($this->getTemplateFile(), DIRECTORY_SEPARATOR);
 }