Exemple #1
0
 /**
  * @dataProvider baseUrlAndPathProvider
  * @param array  $server
  * @param string $baseUrl
  * @param string $basePath
  */
 public function testBasePathDetection(array $server, $baseUrl, $basePath)
 {
     $_SERVER = $server;
     $request = new Request();
     $this->assertEquals($baseUrl, $request->getBaseUrl());
     $this->assertEquals($basePath, $request->getBasePath());
 }
Exemple #2
0
 public function __construct(Request $request)
 {
     $uri = substr($request->getRequestUri(), strlen($request->getBaseUrl()));
     if ($pos = strpos($uri, '?')) {
         $uri = substr($uri, 0, $pos);
     }
     $this->path = array_filter(explode('/', trim($uri, '/')));
     $this->config = (new Routes())->routesMap;
     $this->module = $this->getModule();
     $this->dir = $this->config[$this->module];
 }
Exemple #3
0
 /**
  * Get Theme image
  *
  * @return string
  */
 private function getThemeImage()
 {
     $homeUrl = $this->request->getBaseUrl();
     if (is_file(THEMES_PATH . $this->skin . DS . 'images' . DS . $this->img)) {
         // Картинка из текущей темы (если есть)
         $file = $homeUrl . '/themes/' . $this->skin . '/images/' . $this->img;
         return $this->getLink($file);
     } elseif (is_file(ASSETS_PATH . 'template' . DS . 'images' . DS . $this->img)) {
         // Если нет в теме, то выдаем картинку по умолчанию
         $file = $homeUrl . '/assets/template/images/' . $this->img;
         return $this->getLink($file);
     }
     // Если картинка не найдена
     return '';
 }
Exemple #4
0
 /**
  * @group ZF2-480
  */
 public function testBaseurlFallsBackToRootPathIfScriptFilenameIsNotSet()
 {
     $request = new Request();
     $server = $request->getServer();
     $server->set('SCRIPT_NAME', null);
     $server->set('PHP_SELF', null);
     $server->set('ORIG_SCRIPT_NAME', null);
     $server->set('ORIG_SCRIPT_NAME', null);
     $server->set('SCRIPT_FILENAME', null);
     $this->assertEquals('', $request->getBaseUrl());
 }
 /**
  * Get base url
  *
  * @return string
  */
 public function getBaseUrl()
 {
     $url = urldecode(parent::getBaseUrl());
     $url = str_replace('\\', '/', $url);
     return $url;
 }