/** * Get the composer command for the environment. * * @return string */ protected function findComposer() { if ($this->files->exists($this->workingPath . '/composer.phar')) { return 'php composer.phar'; } else { return 'composer'; } }
/** * Determine if the view at the given path is expired. * * @param string $path * @return bool */ public function isExpired($path) { $compiled = $this->getCompiledPath($path); // If the compiled file doesn't exist we will indicate that the view is expired // so that it can be re-compiled. Else, we will verify the last modification // of the views is less than the modification times of the compiled views. if (!$this->cachePath or !$this->files->exists($compiled)) { return true; } $lastModified = $this->files->lastModified($path); return $lastModified >= $this->files->lastModified($compiled); }
/** * Load the service provider manifest JSON file. * * @return array */ public function loadManifest() { $path = $this->manifestPath . '/services.json'; // The service manifest is a file containing a JSON representation of every // service provided by the application and whether its provider is using // deferred loading or should be eagerly loaded on each request to us. if ($this->files->exists($path)) { return json_decode($this->files->get($path), true); } }
/** * Retrieve an item from the cache by key. * * @param string $key * @return mixed */ protected function retrieveItem($key) { $path = $this->path($key); // If the file doesn't exists, we obviously can't return the cache so we will // just return null. Otherwise, we'll get the contents of the file and get // the expiration UNIX timestamps from the start of the file's contents. if (!$this->files->exists($path)) { return null; } $contents = $this->files->get($path); $expiration = substr($contents, 0, 10); // If the current time is greater than expiration timestamps we will delete // the file and return null. This helps clean up the old files and keeps // this directory much cleaner for us as old files aren't hanging out. if (time() >= $expiration) { return $this->removeItem($key); } return unserialize(substr($contents, 10)); }
/** * Find the given view in the list of paths. * * @param string $name * @param array $paths * @return string */ protected function findInPaths($name, $paths) { foreach ((array) $paths as $path) { foreach ($this->getPossibleViewFiles($name) as $file) { if ($this->files->exists($viewPath = $path . '/' . $file)) { return $viewPath; } } } throw new \InvalidArgumentException("View [{$name}] not found."); }
/** * Apply any cascades to an array of package options. * * @param string $environment * @param string $package * @param string $group * @param array $items * @return array */ public function cascadePackage($environment, $package, $group, $items) { // First we will look for a configuration file in the packages configuration // folder. If it exists, we will load it and merge it with these original // options so that we will easily "cascade" a package's configurations. $file = "packages/{$package}/{$group}.php"; if ($this->files->exists($path = $this->defaultPath . '/' . $file)) { $items = array_merge($items, $this->getRequire($path)); } // Once we have merged the regular package configuration we need to look for // an environment specific configuration file. If one exists, we will get // the contents and merge them on top of this array of options we have. $path = $this->defaultPath . "/{$environment}/" . $file; if ($this->files->exists($path)) { $items = array_merge($items, $this->getRequire($path)); } return $items; }
/** * Retrieve a session payload from storage. * * @param string $id * @return array|null */ public function retrieveSession($id) { if ($this->files->exists($path = $this->getFilePath($id))) { return unserialize($this->files->get($path)); } }
/** * Load a locale from a given path. * * @param string $path * @param string $locale * @param string $group * @return array */ protected function loadPath($path, $locale, $group) { if ($this->files->exists($full = "{$path}/{$locale}/{$group}.php")) { return array_dot($this->files->getRequire($full)); } return array(); }