コード例 #1
0
 /**
  * @param \Magento\Framework\Filesystem\Directory\Write $flagDir
  * @param OutputInterface $output
  * @param null $offOption
  */
 protected function handleDisable(\Magento\Framework\Filesystem\Directory\Write $flagDir, OutputInterface $output, $offOption = null)
 {
     $flagDir->delete(MaintenanceMode::FLAG_FILENAME);
     $output->writeln(self::DISABLED_MESSAGE);
     if ($offOption === 'd') {
         // Also delete IP flag file
         $flagDir->delete(MaintenanceMode::IP_FILENAME);
         $output->writeln(self::DELETED_IP_MESSAGE);
     }
 }
コード例 #2
0
ファイル: Dir.php プロジェクト: aiesh/magento2
 /**
  * Clear temporary directories
  *
  * @param \Magento\Install\Controller\Index\Index $subject
  * @param \Magento\Framework\App\RequestInterface $request
  *
  * @return void
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function beforeDispatch(\Magento\Install\Controller\Index\Index $subject, \Magento\Framework\App\RequestInterface $request)
 {
     if (!$this->appState->isInstalled()) {
         foreach ($this->varDirectory->read() as $dir) {
             if ($this->varDirectory->isDirectory($dir)) {
                 try {
                     $this->varDirectory->delete($dir);
                 } catch (FilesystemException $exception) {
                     $this->logger->log($exception->getMessage());
                 }
             }
         }
     }
 }
コード例 #3
0
 /**
  * Delete all files in a directory recursively
  *
  * @param string $targetDir
  * @return void
  */
 protected function _deleteFilesRecursively($targetDir)
 {
     if ($this->_directory->isExist($targetDir)) {
         foreach ($this->_directory->read($targetDir) as $path) {
             $this->_directory->delete($path);
         }
     }
 }
コード例 #4
0
 /**
  * Delete directory
  *
  * @param string $path
  * @return bool
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function deleteDirectory($path)
 {
     $rootCmp = rtrim($this->_helper->getStorageRoot(), '/');
     $pathCmp = rtrim($path, '/');
     if ($rootCmp == $pathCmp) {
         throw new \Magento\Framework\Exception\LocalizedException(__('We can\'t delete root directory %1 right now.', $path));
     }
     return $this->mediaWriteDirectory->delete($path);
 }
コード例 #5
0
ファイル: Storage.php プロジェクト: tingyeeh/magento2
 /**
  * Delete file (and its thumbnail if exists) from storage
  *
  * @param string $target File path to be deleted
  * @return $this
  */
 public function deleteFile($target)
 {
     $relativePath = $this->_directory->getRelativePath($target);
     if ($this->_directory->isFile($relativePath)) {
         $this->_directory->delete($relativePath);
     }
     $this->_coreFileStorageDb->deleteFile($target);
     $thumb = $this->getThumbnailPath($target, true);
     $relativePathThumb = $this->_directory->getRelativePath($thumb);
     if ($thumb) {
         if ($this->_directory->isFile($relativePathThumb)) {
             $this->_directory->delete($relativePathThumb);
         }
         $this->_coreFileStorageDb->deleteFile($thumb);
     }
     return $this;
 }
コード例 #6
0
ファイル: File.php プロジェクト: aiesh/magento2
 /**
  * Export attribute value to entity model
  *
  * @param array|string $value
  * @return $this
  */
 public function compactValue($value)
 {
     if ($this->getIsAjaxRequest()) {
         return $this;
     }
     $attribute = $this->getAttribute();
     $original = $this->getEntity()->getData($attribute->getAttributeCode());
     $toDelete = false;
     if ($original) {
         if (!$attribute->getIsRequired() && !empty($value['delete'])) {
             $toDelete = true;
         }
         if (!empty($value['tmp_name'])) {
             $toDelete = true;
         }
     }
     $destinationFolder = $attribute->getEntity()->getEntityTypeCode();
     // unlink entity file
     if ($toDelete) {
         $this->getEntity()->setData($attribute->getAttributeCode(), '');
         $file = $destinationFolder . $original;
         if ($this->_directory->isExist($file)) {
             $this->_directory->delete($file);
         }
     }
     if (!empty($value['tmp_name'])) {
         try {
             $uploader = new \Magento\Framework\File\Uploader($value);
             $uploader->setFilesDispersion(true);
             $uploader->setFilenamesCaseSensitivity(false);
             $uploader->setAllowRenameFiles(true);
             $uploader->save($this->_directory->getAbsolutePath($destinationFolder), $value['name']);
             $fileName = $uploader->getUploadedFileName();
             $this->getEntity()->setData($attribute->getAttributeCode(), $fileName);
         } catch (\Exception $e) {
             $this->_logger->logException($e);
         }
     }
     return $this;
 }
コード例 #7
0
 protected function tearDown()
 {
     $this->varDirectory->delete('generation');
     unset($this->_generator);
 }
コード例 #8
0
ファイル: GeneratorTest.php プロジェクト: aiesh/magento2
 protected function tearDown()
 {
     $this->varDirectory->delete('generation');
     set_include_path($this->_includePath);
     unset($this->_generator);
 }
コード例 #9
0
ファイル: ConfigTest.php プロジェクト: aiesh/magento2
 public static function tearDownAfterClass()
 {
     self::$_varDirectory->delete(self::$_varDirectory->getRelativePath(self::$_tmpDir));
 }
コード例 #10
0
 protected function tearDown()
 {
     $this->directoryTmp->delete($this->directoryTmp->getRelativePath($this->_helperStorage->getStorageRoot()));
 }