hiqdev\assetpackagist\components\Storage::writePackage PHP Method

writePackage() public method

public writePackage ( AssetPackage $package )
$package hiqdev\assetpackagist\models\AssetPackage
    public function writePackage(AssetPackage $package)
    {
        $name = $package->getNormalName();
        $data = ['packages' => [$name => $package->getReleases()]];
        $json = Json::encode($data);
        $hash = hash('sha256', $json);
        $path = $this->buildHashedPath($name, $hash);
        if (!file_exists($path)) {
            $this->getLocker()->lock();
            $this->mkdir(dirname($path));
            file_put_contents($path, $json);
            file_put_contents($this->buildHashedPath($name), $json);
            $this->writeProviderLatest($name, $hash);
            $this->getLocker()->release();
        }
        return $hash;
    }