Exemplo n.º 1
0
 /**
  * Set TMP file path prefix
  *
  * @param string $path
  * @return bool
  */
 public function setTmpDir($path)
 {
     if (is_string($path) && $this->_directory->isReadable($path)) {
         $this->_tmpDir = $path;
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Enables apppropriate cache types in app/etc/env.php based on the passed in $cacheTypes array
  * TODO: to be removed in scope of MAGETWO-53476
  *
  * @param string[]
  *
  * @return void
  */
 private function enableCacheTypes($cacheTypes)
 {
     if (empty($cacheTypes)) {
         return;
     }
     $envPath = $this->getEnvPath();
     if ($this->write->isReadable($this->write->getRelativePath($envPath))) {
         $envData = (include $envPath);
         foreach ($cacheTypes as $cacheType) {
             if (isset($envData['cache_types'][$cacheType])) {
                 $envData['cache_types'][$cacheType] = 1;
             }
         }
         $formatter = new PhpFormatter();
         $contents = $formatter->format($envData);
         $this->write->writeFile($this->write->getRelativePath($envPath), $contents);
         if (function_exists('opcache_invalidate')) {
             opcache_invalidate($this->write->getAbsolutePath($envPath));
         }
     }
 }
Exemplo n.º 3
0
 /**
  * Run application
  *
  * @return Response
  * @throws \LogicException
  */
 public function launch()
 {
     if ($this->mediaDirectoryPath !== $this->directory->getAbsolutePath()) {
         // Path to media directory changed or absent - update the config
         /** @var \Magento\MediaStorage\Model\File\Storage\Config $config */
         $config = $this->configFactory->create(['cacheFile' => $this->configCacheFile]);
         $config->save();
         $this->mediaDirectoryPath = $config->getMediaDirectory();
         $allowedResources = $config->getAllowedResources();
         $isAllowed = $this->isAllowed;
         if (!$isAllowed($this->relativeFileName, $allowedResources)) {
             throw new \LogicException('The specified path is not allowed.');
         }
     }
     /** @var \Magento\MediaStorage\Model\File\Storage\Synchronization $sync */
     $sync = $this->syncFactory->create(['directory' => $this->directory]);
     $sync->synchronize($this->relativeFileName);
     if ($this->directory->isReadable($this->relativeFileName)) {
         $this->response->setFilePath($this->directory->getAbsolutePath($this->relativeFileName));
     } else {
         $this->response->setHttpResponseCode(404);
     }
     return $this->response;
 }
 /**
  * Checks if directory exists and is readable
  *
  * @param \Magento\Framework\Filesystem\Directory\WriteInterface $directory
  * @return bool
  */
 protected function isReadableDirectory($directory)
 {
     if (!$directory->isExist() || !$directory->isDirectory() || !$directory->isReadable()) {
         return false;
     }
     return true;
 }
Exemplo n.º 5
0
 /**
  * @param string $relativePath
  * @return bool
  */
 protected function _isCanProcessed($relativePath)
 {
     $filePath = $this->_rootDir->getAbsolutePath($relativePath);
     return strpos($this->_rootDir->getDriver()->getRealPath($filePath), $relativePath) !== false && $this->_rootDir->isFile($relativePath) && $this->_rootDir->isReadable($relativePath) || $this->_processDatabaseFile($filePath, $relativePath);
 }
Exemplo n.º 6
0
 /**
  * @param string $dbCode
  * @return bool
  */
 public function isDbAvailable($dbCode)
 {
     $dbPath = $this->getDbPath($dbCode);
     return $dbPath && $this->directory->isFile($dbPath) && $this->directory->isReadable($dbPath);
 }
Exemplo n.º 7
0
 /**
  * @param string $relativePath
  * @return bool
  */
 protected function _isCanProcessed($relativePath)
 {
     $filePath = $this->_rootDir->getAbsolutePath($relativePath);
     return (!$this->_rootDir->isFile($relativePath) || !$this->_rootDir->isReadable($relativePath)) && !$this->_processDatabaseFile($filePath);
 }
Exemplo n.º 8
0
 /**
  * @param string $relativePath
  * @return bool
  */
 protected function _isCanProcessed($relativePath)
 {
     $filePath = $this->_rootDir->getAbsolutePath($relativePath);
     $pathWithFixedSeparator = str_replace('\\', '/', $this->_rootDir->getDriver()->getRealPath($filePath));
     return strpos($pathWithFixedSeparator, $relativePath) !== false && $this->_rootDir->isFile($relativePath) && $this->_rootDir->isReadable($relativePath) || $this->_processDatabaseFile($filePath, $relativePath);
 }