コード例 #1
0
 /**
  * Dispatch a nested URL
  *
  * @param $uri
  *
  * @return string
  */
 protected function _dispatchNestedUrl($uri)
 {
     // if url path is empty, return unchanged
     if (empty($uri[1])) {
         return $uri[0];
     }
     $prefix = '';
     list($path, $append) = Strings::explode('?', $uri[1], [$uri[1], null], 2);
     //Take a root link as it comes
     if (!Strings::startsWith($path, '/')) {
         $relPath = $this->_assetManager->getRelativePath();
         if (Strings::startsWith($path, '../')) {
             $max = count($relPath);
             $depth = substr_count($path, '../');
             $path = substr($path, $depth * 3);
             if ($depth > 0 && $depth < $max) {
                 $rel = array_slice($relPath, 0, $depth);
                 $prefix = implode('/', $rel);
             }
         } else {
             $prefix = implode('/', $relPath);
         }
     }
     $path = ltrim($path, '/');
     $url = $this->_assetManager->getResourceUri(Path::buildUnix($prefix, $path));
     if (empty($url)) {
         return $uri[0];
     }
     if (!empty($append)) {
         return "url('{$url}?{$append}')";
     }
     return "url('{$url}')";
 }
コード例 #2
0
 /**
  * Explode a string, filling the remainder with provided defaults.
  *
  * @param string      $delimiter The boundary string
  * @param string      $string    The input string.
  * @param array|mixed $defaults  Array to return, with replacements made,
  *                               or a padding value
  * @param int|null    $limit     Passed through to the initial explode
  *
  * @return array
  *
  * @deprecated
  */
 function exploded($delimiter, $string, $defaults = null, $limit = null)
 {
     return \Packaged\Helpers\Strings::explode($delimiter, $string, $defaults, $limit);
 }
コード例 #3
0
ファイル: StringsTest.php プロジェクト: PaulAntunes/gclf-paul
 public function testExploded()
 {
     $defaults = ["a", "b", "c", "d"];
     $this->assertEquals([1, 2, 3, 4], Strings::explode(",", "1,2,3,4", $defaults, 4));
     $this->assertEquals([1, 2, "3,4", "d"], Strings::explode(",", "1,2,3,4", $defaults, 3));
     $this->assertEquals([1, 2, "c", "d"], Strings::explode(",", "1,2", $defaults, 3));
     $this->assertEquals([1, 2, "c", "d"], Strings::explode(",", "1,2", $defaults));
     $this->assertEquals([1, 2, 3, 4, 5], Strings::explode(",", "1,2,3,4,5", $defaults));
     $this->assertEquals([1, 2, 3, '-', '-'], Strings::explode(",", "1,2,3", '-', 5));
 }