app = $app; $this->files = $files; $this->manifestPath = storage_path('framework'); } /** * Load the service provider manifest JSON file. * * @return array|null */ public function loadManifest(string $manifestName) { if ($this->files->exists($this->manifestPath.'/'.$manifestName.'.php')) { $manifest = $this->files->getRequire($this->manifestPath.'/'.$manifestName.'.php'); if ($manifest) { return array_merge(['when' => []], $manifest[$manifestName]); } } return null; } /** * Determine if the manifest should be compiled. * * @param array|null $manifest * @param array $paths * @return bool */ public function shouldRefresh($manifest, $paths) { return is_null($manifest) || $manifest != $paths; } /** * Create a fresh service manifest data structure. * * @param string $manifestName * @return array */ protected function freshManifest($manifestName, array $paths) { return [$manifestName => $paths]; } /** * Write the service manifest file to disk. * * @return array * * @throws \Exception */ public function writeManifest(string $manifestName, array $paths) { if (! is_writable($dirname = dirname($this->manifestPath.'/'.$manifestName.'.php'))) { throw new Exception("The {$dirname} directory must be present and writable."); } $manifest = $this->freshManifest($manifestName, $paths); $this->files->replace( $this->manifestPath.'/'.$manifestName.'.php', ' []], $manifest[$manifestName]); } }