/** * Returns contents of License file. * * @return string */ public function getContents() { if (!$this->dir->isFile(self::LICENSE_FILENAME)) { return false; } return $this->dir->readFile(self::LICENSE_FILENAME); }
/** * Returns contents of License file. * * @return string|boolean */ public function getContents() { if ($this->dir->isFile(self::LICENSE_FILENAME)) { return $this->dir->readFile(self::LICENSE_FILENAME); } elseif ($this->dir->isFile(self::DEFAULT_LICENSE_FILENAME)) { return $this->dir->readFile(self::DEFAULT_LICENSE_FILENAME); } else { return false; } }
/** * If DB file storage is on - find there, otherwise - just file_exists * * @param string $filename relative file path * @return bool */ protected function checkIsFile($filename) { if ($this->fileStorageDatabase->checkDbUsage() && !$this->mediaDirectory->isFile($filename)) { $this->fileStorageDatabase->saveFileToFilesystem($filename); } return $this->mediaDirectory->isFile($filename); }
/** * Parses .htaccess file and apply php settings to shell script * * @return $this */ protected function _applyPhpVariables() { $htaccess = '.htaccess'; if ($this->rootDirectory->isFile($htaccess)) { // parse htaccess file $data = $this->rootDirectory->readFile($htaccess); $matches = []; preg_match_all('#^\\s+?php_value\\s+([a-z_]+)\\s+(.+)$#siUm', $data, $matches, PREG_SET_ORDER); if ($matches) { foreach ($matches as $match) { @ini_set($match[1], str_replace("\r", '', $match[2])); } } preg_match_all('#^\\s+?php_flag\\s+([a-z_]+)\\s+(.+)$#siUm', $data, $matches, PREG_SET_ORDER); if ($matches) { foreach ($matches as $match) { @ini_set($match[1], str_replace("\r", '', $match[2])); } } } return $this; }
/** * Quote item to order item copy process * * @return $this */ public function copyQuoteToOrder() { $quoteOption = $this->getConfigurationItemOption(); try { $value = unserialize($quoteOption->getValue()); if (!isset($value['quote_path'])) { throw new \Exception(); } $quotePath = $value['quote_path']; $orderPath = $value['order_path']; if (!$this->_rootDirectory->isFile($quotePath) || !$this->_rootDirectory->isReadable($quotePath)) { throw new \Exception(); } $this->_coreFileStorageDatabase->copyFile($this->_rootDirectory->getAbsolutePath($quotePath), $this->_rootDirectory->getAbsolutePath($orderPath)); } catch (\Exception $e) { return $this; } return $this; }
/** * Find a relative path to a first file located in a directory or its descendants * * @param string $dir Directory to search for a file within * @param string $pattern PCRE pattern a file name has to match * @return string|null */ protected function _findFirstFileRelativePath($dir, $pattern = '/.*/') { $childDirs = array(); foreach ($this->_pubDirectory->read($dir) as $itemPath) { if ($this->_pubDirectory->isFile($itemPath)) { if (preg_match($pattern, $itemPath)) { return $itemPath; } } else { $childDirs[$itemPath] = $itemPath; } } foreach ($childDirs as $dirName => $dirPath) { $filePath = $this->_findFirstFileRelativePath($dirPath, $pattern); if ($filePath) { return $filePath; } } return null; }