/** * @param \Magento\Framework\Filesystem\Directory\Write $flagDir * @param OutputInterface $output * @param null $onOption */ protected function handleEnable(\Magento\Framework\Filesystem\Directory\Write $flagDir, OutputInterface $output, $onOption = null) { $flagDir->touch(MaintenanceMode::FLAG_FILENAME); $output->writeln(self::ENABLED_MESSAGE); if (!is_null($onOption)) { // Write IPs to exclusion file $flagDir->writeFile(MaintenanceMode::IP_FILENAME, $onOption); $output->writeln(self::WROTE_IP_MESSAGE); } }
/** * Constructor * * @param \Magento\Framework\App\Filesystem $filesystem * @param string|null $destination * @throws \Magento\Framework\Model\Exception */ public function __construct(\Magento\Framework\App\Filesystem $filesystem, $destination = null) { $this->_directoryHandle = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::SYS_TMP_DIR); if (!$destination) { $destination = uniqid('importexport_'); $this->_directoryHandle->touch($destination); } if (!is_string($destination)) { throw new \Magento\Framework\Model\Exception(__('Destination file path must be a string')); } if (!$this->_directoryHandle->isWritable()) { throw new \Magento\Framework\Model\Exception(__('Destination directory is not writable')); } if ($this->_directoryHandle->isFile($destination) && !$this->_directoryHandle->isWritable($destination)) { throw new \Magento\Framework\Model\Exception(__('Destination file is not writable')); } $this->_destination = $destination; $this->_init(); }
/** * Constructor * * @param Filesystem $filesystem * @param string|null $destination * @param string $destinationDirectoryCode * @throws \Magento\Framework\Exception\LocalizedException */ public function __construct(\Magento\Framework\Filesystem $filesystem, $destination = null, $destinationDirectoryCode = DirectoryList::SYS_TMP) { $this->_directoryHandle = $filesystem->getDirectoryWrite($destinationDirectoryCode); if (!$destination) { $destination = uniqid('importexport_'); $this->_directoryHandle->touch($destination); } if (!is_string($destination)) { throw new \Magento\Framework\Exception\LocalizedException(__('The destination file path must be a string.')); } if (!$this->_directoryHandle->isWritable()) { throw new \Magento\Framework\Exception\LocalizedException(__('The destination directory is not writable.')); } if ($this->_directoryHandle->isFile($destination) && !$this->_directoryHandle->isWritable($destination)) { throw new \Magento\Framework\Exception\LocalizedException(__('Destination file is not writable')); } $this->_destination = $destination; $this->_init(); }