/** * Loads the configuration file. * * @access protected * @param string $file File name * @return array */ protected function load($file) { // Load configuration foreach ($this->getCascadingFilePaths($file) as $path) { if ($this->fileSystem->exists($path)) { $config = $this->fileSystem->includeFile($path); break; } } if (!isset($config)) { throw new RuntimeException(vsprintf("%s(): The [ %s ] config file does not exist.", [__METHOD__, $file])); } // Merge environment specific configuration if ($this->environment !== null) { $namespace = strpos($file, '::'); $namespaced = $namespace === false ? $this->environment . '.' . $file : substr_replace($file, $this->environment . '.', $namespace + 2, 0); foreach ($this->getCascadingFilePaths($namespaced) as $path) { if ($this->fileSystem->exists($path)) { $config = array_replace_recursive($config, $this->fileSystem->includeFile($path)); break; } } } $this->configuration[$file] = $config; }
/** * Constructor. * * @access public * @param string $file File path * @param array $options Options */ public function __construct($file, array $options = []) { $this->fileSystem = $this->getFileSystem(); if ($this->fileSystem->exists($file) === false || $this->fileSystem->isReadable($file) === false) { throw new RuntimeException(vsprintf("%s(): File [ %s ] is not readable.", [__METHOD__, $file])); } $this->filePath = $file; $this->fileSize = $this->fileSystem->size($file); $this->options = $options + ['file_name' => basename($file), 'disposition' => 'attachment', 'content_type' => $this->fileSystem->mime($file) ?: 'application/octet-stream', 'callback' => null]; }
/** * Loads and returns language strings. * * @access public * @param string $language Name of the language pack * @param string $file File we want to load * @return array */ public function loadStrings($language, $file) { $strings = false; foreach ($this->getCascadingFilePaths($file, null, $language . '/strings') as $file) { if ($this->fileSystem->exists($file)) { $strings = $this->fileSystem->includeFile($file); break; } } if ($strings === false) { throw new RuntimeException(vsprintf("%s(): The [ %s ] language file does not exist in the [ %s ] language pack.", [__METHOD__, $file, $language])); } return $strings; }
/** * {@inheritdoc} */ public function remove($key) { if ($this->fileSystem->exists($this->cacheFile($key))) { return $this->fileSystem->delete($this->cacheFile($key)); } return false; }
/** * {@inheritdoc} */ public function delete($sessionId) { if ($this->fileSystem->exists($this->sessionPath . '/' . $sessionId) && $this->fileSystem->isWritable($this->sessionPath . '/' . $sessionId)) { $this->fileSystem->delete($this->sessionPath . '/' . $sessionId); } }