33 private $_type =
'db';
86 \
Magento\Framework\Locale\ResolverInterface $localeResolver,
87 \
Magento\Backend\Model\Auth\Session $authSession,
93 parent::__construct(
$data);
98 $this->_localeResolver = $localeResolver;
99 $this->_backendAuthSession = $authSession;
147 $backupData = $this->_helper->extractDataFromFilename(
$fileName);
152 'time' => (
int)$backupData->getTime(),
154 'extension' => $this->_helper->getExtensionByType($backupData->getType()),
155 'display_name' => $this->_helper->nameToDisplayName($backupData->getName()),
156 'name' => $backupData->getName(),
157 'date_object' => (new \DateTime())->setTimestamp($backupData->getTime()),
161 $this->
setType($backupData->getType());
172 return $this->varDirectory->isFile($this->
_getFilePath());
182 $filename = $this->getTime() .
"_" . $this->
getType();
183 $backupName = $this->getName();
185 if (!empty($backupName)) {
186 $filename .=
'_' . $backupName;
189 $filename .=
'.' . $this->_helper->getExtensionByType($this->
getType());
202 $possibleTypes = $this->_helper->getBackupTypesList();
203 if (!in_array(
$value, $possibleTypes)) {
204 $value = $this->_helper->getDefaultBackupType();
208 $this->
setData(
'type', $this->_type);
233 throw new \Magento\Framework\Exception\LocalizedException(
234 __(
'Please correct the order of creation for a new backup.')
251 throw new \Magento\Framework\Exception\LocalizedException(
__(
'The backup file does not exist.'));
254 return $this->varDirectory->read($this->
_getFilePath());
266 throw new \Magento\Framework\Exception\LocalizedException(
__(
'The backup file does not exist.'));
281 public function open($write =
false)
283 if ($this->getPath() ===
null) {
284 throw new \Magento\Framework\Exception\InputException(
__(
'The backup file path was not specified.'));
287 if ($write && $this->varDirectory->isFile($this->_getFilePath())) {
290 if (!$write && !$this->varDirectory->isFile($this->_getFilePath())) {
291 throw new \Magento\Framework\Exception\InputException(
292 __(
'The backup file "%1" does not exist.', $this->
getFileName())
305 }
catch (\
Magento\Framework\Exception\FileSystemException $e) {
306 throw new \Magento\Framework\Backup\Exception\NotEnoughPermissions(
307 __(
'Sorry, but we cannot read from or write to backup file "%1".', $this->
getFileName())
322 if ($this->_stream ===
null) {
323 throw new \Magento\Framework\Exception\InputException(
__(
'The backup file handler was unspecified.'));
360 }
catch (\
Magento\Framework\Exception\FileSystemException $e) {
361 throw new \Magento\Framework\Exception\InputException(
362 __(
'Something went wrong while writing to the backup file "%1".', $this->
getFileName())
377 $this->_stream =
null;
395 $directory = $directory->readFile($this->
_getFilePath());
405 if ($this->
getData(
'size') !==
null) {
410 $this->
setData(
'size', $this->varDirectory->stat($this->_getFilePath())[
'size']);
425 $userPasswordHash = $this->_backendAuthSession->getUser()->getPassword();
426 return $this->_encryptor->validateHash($password, $userPasswordHash);
436 return $this->varDirectory->getRelativePath($this->getPath() .
'/' . $this->
getFileName());
output($string, $level=INFO, $label='')
getData($key='', $index=null)
__construct(\Magento\Backup\Helper\Data $helper, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Backend\Model\Auth\Session $authSession, \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Framework\Filesystem $filesystem, $data=[])
load($fileName, $filePath)
validateUserPassword($password)
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
setData($key, $value=null)
if(!isset($_GET['name'])) $name