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

writeProviderLatest() protected method

protected writeProviderLatest ( $name, $hash )
    protected function writeProviderLatest($name, $hash)
    {
        $latest_path = $this->buildHashedPath('provider-latest');
        if (file_exists($latest_path)) {
            $data = Json::decode(file_get_contents($latest_path) ?: '[]');
        }
        if (!isset($data) || !is_array($data)) {
            $data = [];
        }
        if (!isset($data['providers'])) {
            $data['providers'] = [];
        }
        $data['providers'][$name] = ['sha256' => $hash];
        $json = Json::encode($data);
        $hash = hash('sha256', $json);
        $path = $this->buildHashedPath('provider-latest', $hash);
        if (!file_exists($path)) {
            $this->getLocker()->lock();
            $this->mkdir(dirname($path));
            file_put_contents($path, $json);
            file_put_contents($latest_path, $json);
            $this->writePackagesJson($hash);
            $this->getLocker()->release();
        }
        return $hash;
    }