Ejemplo n.º 1
0
 /**
  * path method
  *
  * @param null|string $path
  * @param bool $canonicalize
  *
  * @return string
  */
 public function path($path = null, $canonicalize = false)
 {
     $path = $path === null ? $this->path : Path::join($this->path, $path);
     return $canonicalize ? Path::canonicalize($path) : $path;
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider provideCanonicalizationTests
  */
 public function testCanonicalize($path, $canonicalized)
 {
     $this->assertSame($canonicalized, Path::canonicalize($path));
 }
Ejemplo n.º 3
0
 /**
  * Sets a config value for the loader (i.e. permanently).
  *
  * @param  string  $key
  * @param  mixed   $value
  * @param  string  $environment
  * @return void
  */
 public function set($key, $value = null, $environment = null)
 {
     if (!isset($this->repository)) {
         throw new \RuntimeException('Repo is needed to set config.');
     }
     list($namespace, $group, $item) = $this->repository->parseKey($key);
     $environment = $environment ? $environment : $this->repository->getEnvironment();
     $path = String::remove($this->getPath($namespace), Path::canonicalize(base_path()));
     $parts = "{$environment} - {$namespace} - {$group} - {$item} - {$value}";
     $f = $this->files;
     $storPath = $this->laradicConfig['loaders.file.save_path'];
     $fileName = "global.php";
     if ($namespace) {
         $fileName = (string) \Stringy\Stringy::create($namespace)->slugify()->ensureRight('.php');
     }
     $file = Path::join($storPath, $fileName);
     $items = $f->exists($file) ? $f->getRequire($file) : [];
     $dest = "{$environment}.{$group}" . (isset($item) ? ".{$item}" : '');
     array_set($items, $dest, $value);
     $this->files->put($file, "<?php \n return " . var_export($items, true) . ';');
 }