/** * 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()); } } } } }
/** * 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); } } }