コード例 #1
0
ファイル: FileTest.php プロジェクト: nextinteractive/utils
 public function testRemoveExtension()
 {
     $this->assertEquals('test', File::removeExtension('test.txt'));
     $this->assertEquals('', File::removeExtension('.txt'));
     $this->assertEquals('', File::removeExtension(''));
     $this->assertEquals('test', File::removeExtension('test'));
 }
コード例 #2
0
ファイル: RouteCollection.php プロジェクト: gobjila/BackBee
 /**
  * Returns complete url which match with routeName and routeParams; you can also customize
  * the base url; by default it use current site base url.
  *
  * @param  string      $name       The name of the route to look for.
  * @param  array|null  $params     Optional, parameters to apply to the route.
  * @param  string|null $baseUrl    Optional, base URL to use rather than the computed one.
  * @param  boolean     $addExt     If true adds the default extension to result.
  * @param  Site|null   $site       Optional, the site for which the uri will be built.
  * @param  boolean     $buildQuery If true, adds unused parameters in querystring
  *
  * @return string                  The computed URL.
  */
 public function getUrlByRouteName($name, array $params = null, $baseUrl = null, $addExt = true, Site $site = null, $buildQuery = false)
 {
     $paramsToAdd = [];
     $uri = $this->applyRouteParameters($this->getRoutePath($name), (array) $params, $paramsToAdd);
     $path = $this->getUri($baseUrl . $uri, null, $site);
     if (true !== $addExt) {
         $path = File::removeExtension($path);
     }
     if (!empty($paramsToAdd) && true === $buildQuery) {
         $path = $path . '?' . http_build_query($paramsToAdd);
     }
     return $path;
 }