Example #1
0
 public function __construct(ContainerInterface $container = null)
 {
     $this->container = $container;
     $this->debugbar = $this->container->get('debug');
     $this->renderer = $this->debugbar->getJavascriptRenderer();
     $url = \GL\Core\Helpers\Utils::url("/dbg");
     $this->renderer->setBaseUrl($url);
 }
Example #2
0
 public function execute()
 {
     $resp = $this->_response;
     try {
         $headers = $resp->headers;
         $ct = $headers->get('Content-Type');
         if (strtolower($ct) == "text/html") {
             $content = $resp->getContent();
             // add debugbar before <html> closure tag
             $debugbar = $this->_container->get('debug');
             $renderer = $debugbar->getJavascriptRenderer();
             $url = \GL\Core\Helpers\Utils::url("/dbg");
             $renderer->setBaseUrl($url);
             $dbghd = $renderer->renderHead();
             $dbgct = $renderer->render();
             $buf = "";
             // test if </head> if present
             if (strpos($content, '</head>') !== false) {
                 $head = $dbghd . "</head>";
                 $content = str_replace("</head>", $head, $content);
             } else {
                 $buf .= $dbghd;
             }
             if (strpos($content, '</body>') !== false) {
                 $buf = $dbgct . "</body>";
                 $content = str_replace("</body>", $buf, $content);
             } else {
                 $buf .= $dbgct . "</html>";
                 $content = str_replace("</html>", $buf, $content);
             }
             $resp->setContent($content);
         }
     } catch (Exception $e) {
     }
     // Warning don't forget to return a symfony response object !!
     return $resp;
 }
Example #3
0
 /**
  * Convert relative url to absolute url
  * 
  * @param string $partialurl relative url
  * @return string absolute url (use BASE_PATH define in config.php)
  */
 public static function url($partialurl)
 {
     return Hutils::url($partialurl);
 }
Example #4
0
 /**
  * Redirect with 302 response
  * 
  * @param string $routename route name defined in routes.yml
  * @param array $params parameters needed for the route
  */
 function redirect($routename, $params = array())
 {
     $url = "";
     try {
         $url = \GL\Core\Helpers\Utils::route($routename, $params);
     } catch (\Exception $e) {
         \Debug::addException($e);
     }
     if ($url != "") {
         $this->redirecting($url);
     }
 }
Example #5
0
 /**
  * Return public webpath
  * @return string
  */
 public static function getPublicPath()
 {
     return Utils::getPublicPath();
 }
Example #6
0
 private static function getJsDeclaration($jsfile)
 {
     $url = Utils::url($jsfile);
     return S::create("<script src='##file##'></script>")->replace('##file##', $url)->__toString();
 }
Example #7
0
 /**
  * Convert relative url to absolute url
  * 
  * @param string $partialurl relative url
  * @return string absolute url (use BASE_PATH define in config.php)
  */
 public function url($partialurl)
 {
     return Utils::url($partialurl);
 }
Example #8
-1
 /**
  * Get Url from routename and parameters array
  * @param string $routename route name defined in routes.yml
  * @param array $params parameters array
  * @return string url
  */
 public static function route($routename, $params = array())
 {
     $url = "";
     try {
         $rc = \GL\Core\DI\ServiceProvider::GetDependencyContainer()->get('routes');
         $route = $rc->get($routename);
         if ($route != null) {
             $pattern = $route->getPath();
             $url = \GL\Core\Helpers\Utils::url($pattern);
             $urlo = S::create($url);
             $sep = "/";
             $defaults = $route->getDefaults();
             $param_array = array_merge($defaults, $params);
             foreach ($param_array as $key => $value) {
                 $str = '{' . $key . '}';
                 $urlo = $urlo->replace($str, $value);
             }
             $urlo = $urlo->removeRight($sep);
         }
     } catch (Exception $e) {
         $urlo = S::create("");
     }
     $ret = isset($urlo) == true ? $urlo->__toString() : "";
     return $ret;
 }