/**
  * @see \Ableron\Core\Template\Plugins\Interfaces\CompilerPluginInterface::compileOpeningTag()
  */
 public function compileOpeningTag(TemplateCompiler $templateCompiler)
 {
     // build base URL
     $actionUrl = new Uri(parent::compileOpeningTag($templateCompiler));
     // add URL of current request as action source URL
     $actionUrl->addQueryParameter(ABLERON_PARAM_ACTION_SOURCE_URL, StringUtil::base64UrlEncode(Application::getRequestHandler()->getRequest()->getUri()->toString()));
     // add CSRF token query parameter to URL
     $actionUrl->addQueryParameter(ABLERON_PARAM_CSRF_TOKEN, self::$actionUrlCsrfTokenPlaceholder);
     // return final URL
     return str_replace(self::$actionUrlCsrfTokenPlaceholder, '<?php echo $application::getSecurityHandler()->getCsrfProtector()->getCurrentToken(); ?>', $actionUrl->toString());
 }
Example #2
0
 /**
  * Tests whether addQueryParameter() works as expected.
  *
  * @return void
  */
 public function testAddQueryParameter()
 {
     $uri = new Uri('http://example.com/path?q1=1&q2=2&q3=3');
     $uri->addQueryParameter('q4', '4');
     $this->assertSame('q1=1&q2=2&q3=3&q4=4', $uri->getQuery());
     $uri->addQueryParameter('q2', '0815');
     $this->assertSame('q1=1&q2=0815&q3=3&q4=4', $uri->getQuery());
 }