Pickle\Package\Util\JSON\Dumper::dumpToFile PHP Méthode

dumpToFile() public méthode

public dumpToFile ( Pickle\Base\Interfaces\Package $package, string $path, $with_version = true )
$package Pickle\Base\Interfaces\Package
$path string
    public function dumpToFile(Interfaces\Package $package, $path, $with_version = true)
    {
        file_put_contents($path, $this->dump($package, $with_version));
    }

Usage Example

Exemple #1
0
 public function execute($target, $no_convert)
 {
     $jsonLoader = new \Pickle\Package\Util\JSON\Loader(new \Pickle\Package\Util\Loader());
     $pickle_json = $target . DIRECTORY_SEPARATOR . 'composer.json';
     $package = null;
     if (file_exists($pickle_json)) {
         $package = $jsonLoader->load($pickle_json);
     }
     /* Do we really need to check this here? */
     /*if (null === $package && $no_convert) {
           throw new \RuntimeException('XML package are not supported. Please convert it before install');
       }*/
     if (null === $package) {
         $config_cmake = $target . DIRECTORY_SEPARATOR . 'config.cmake';
         if (!file_exists($config_cmake)) {
             throw new \Exception('config.cmake not found');
         }
         $cmp = new Cmake\Parser(new \Pickle\Package\Util\Loader());
         $package = $cmp->load($config_cmake);
         $dumper = new Dumper();
         $dumper->dumpToFile($package, $pickle_json);
         $package = $jsonLoader->load($pickle_json);
     }
     $package->setRootDir($target);
     return $package;
 }
All Usage Examples Of Pickle\Package\Util\JSON\Dumper::dumpToFile