/** * Determine if the collections definition has changed when compared to the manifest. * * @param \Illuminate\Support\Collection $assets * @param \Basset\Manifest\Entry $entry * @param string $group * @return bool */ protected function collectionDefinitionHasChanged($assets, $entry, $group) { // If the manifest entry doesn't even have the group registered then it's obvious that the // collection has changed and needs to be rebuilt. if (!$entry->hasDevelopmentAssets($group)) { return true; } // Get the development assets from the manifest entry and flatten the keys so that we have // an array of relative paths that we can compare from. $manifest = $entry->getDevelopmentAssets($group); $manifest = array_flatten(array_keys($manifest)); // Compute the difference between the collections assets and the manifests assets. If we get // an array of values then the collection has changed since the last build and everything // should be rebuilt. $difference = array_diff_assoc($manifest, $assets->map(function ($asset) { return $asset->getRelativePath(); })->flatten()->toArray()); return !empty($difference); }
/** * Clean the collections manifest entry files. * * @param string $collection * @param \Basset\Manifest\Entry $entry * @return void */ protected function cleanManifestFiles($collection, Entry $entry) { if (!$entry->hasProductionFingerprints() or !isset($this->environment[$collection])) { $this->deleteMatchingFiles($this->buildPath . '/' . $collection . '-*.*'); $entry->resetProductionFingerprints(); } if (!$entry->hasDevelopmentAssets() or !isset($this->environment[$collection])) { $this->files->deleteDirectory($this->buildPath . '/' . $collection); $entry->resetDevelopmentAssets(); } }