Ejemplo n.º 1
0
 /**
  * @throws SystemException
  */
 public function __construct()
 {
     $this->uri = URI::create();
     $path = $this->uri->getPath();
     if (strpos($path, E()->getSiteManager()->getCurrentSite()->root) !== false) {
         $path = array_values(array_diff(explode('/', substr($path, strlen(E()->getSiteManager()->getCurrentSite()->root))), array('')));
     } else {
         $path = array();
     }
     try {
         $language = E()->getLanguage();
         $this->lang = isset($path[0]) && $language->isValidLangAbbr($path[0]) ? array_shift($path) : '';
     } catch (SystemException $e) {
         $this->lang = '';
     }
     $this->path = $path;
 }
Ejemplo n.º 2
0
 /**
  * Given 2 paths, will merge them according to rules set out in RFC 2986,
  * Section 5.2
  *
  * @see http://tools.ietf.org/html/rfc3986#section-5.2.3
  *
  * @param $path1
  * @param $path2
  */
 protected function mergePaths(URI $base, URI $reference)
 {
     if (!empty($base->getAuthority()) && empty($base->getPath())) {
         return '/' . ltrim($base->getPath(), '/ ');
     }
     $path = explode('/', $base->getPath());
     if (empty($path[0])) {
         unset($path[0]);
     }
     array_pop($path);
     array_push($path, $reference->getPath());
     return implode('/', $path);
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider invalidPaths
  */
 public function testPathGetsFiltered($path, $expected)
 {
     $uri = new URI();
     $uri->setPath($path);
     $this->assertEquals($expected, $uri->getPath());
 }