Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
framework
Backup
Filesystem
Rollback
Fs.php
Go to the documentation of this file.
1
<?php
7
namespace
Magento\Framework\Backup\Filesystem\Rollback
;
8
9
use
Magento\Framework\App\ObjectManager
;
10
use
Magento\Framework\Archive
;
11
use
Magento\Framework\Archive\Gz
;
12
use
Magento\Framework\Archive\Helper\File
;
13
use
Magento\Framework\Archive\Helper\File\Gz
as HelperGz;
14
use
Magento\Framework\Archive\Tar
;
15
use
Magento\Framework\Backup\Exception\CantLoadSnapshot
;
16
use
Magento\Framework\Backup\Exception\NotEnoughPermissions
;
17
use
Magento\Framework\Backup\Filesystem\Helper
;
18
use
Magento\Framework\Exception\LocalizedException
;
19
use
Magento\Framework\Phrase
;
20
26
class
Fs
extends
AbstractRollback
27
{
31
private
$fsHelper;
32
41
public
function
run
()
42
{
43
$snapshotPath = $this->_snapshot->getBackupPath();
44
45
if
(!
is_file
($snapshotPath) || !
is_readable
($snapshotPath)) {
46
throw
new
CantLoadSnapshot
(
47
new
Phrase
(
'Can\'t load snapshot archive'
)
48
);
49
}
50
51
$fsHelper = $this->getFsHelper();
52
53
$filesInfo = $fsHelper->getInfo(
54
$this->_snapshot->getRootDir(),
55
Helper::INFO_WRITABLE
,
56
$this->_snapshot->getIgnorePaths()
57
);
58
59
if
(!$filesInfo[
'writable'
]) {
60
if
(!empty($filesInfo[
'writableMeta'
])) {
61
throw
new
NotEnoughPermissions
(
62
new
Phrase
(
63
'You need write permissions for: %1'
,
64
[implode(
', '
, $filesInfo[
'writableMeta'
])]
65
)
66
);
67
}
68
69
throw
new
NotEnoughPermissions
(
70
new
Phrase
(
"The rollback can't be executed because not all files are writable."
)
71
);
72
}
73
74
$archiver =
new
Archive
();
75
80
new
Tar
();
81
new
Gz
();
82
new
File
(
''
);
83
new
HelperGz(
''
);
84
new
LocalizedException
(
new
Phrase
(
'dummy'
));
85
86
if
(!$this->_snapshot->keepSourceFile()) {
87
$fsHelper->rm($this->_snapshot->getRootDir(), $this->_snapshot->getIgnorePaths());
88
}
89
$archiver->unpack($snapshotPath, $this->_snapshot->getRootDir());
90
91
if
($this->_snapshot->keepSourceFile() ===
false
) {
92
@
unlink
($snapshotPath);
93
}
94
}
95
100
private
function
getFsHelper()
101
{
102
if
(!$this->fsHelper) {
103
$this->fsHelper =
ObjectManager::getInstance
()->get(Helper::class);
104
}
105
106
return
$this->fsHelper;
107
}
108
}
Magento\Framework\Exception\LocalizedException
Definition:
LocalizedException.php:17
Magento\Framework\Archive\Helper\File
Definition:
Bz.php:10
Magento\Framework\App\ObjectManager\getInstance
static getInstance()
Definition:
ObjectManager.php:33
Magento\Framework\Backup\Filesystem\Rollback\Fs\run
run()
Definition:
Fs.php:41
Magento\Framework\Backup\Filesystem\Helper\INFO_WRITABLE
const INFO_WRITABLE
Definition:
Helper.php:25
Magento\Framework\Backup\Filesystem\Rollback\Fs
Definition:
Fs.php:26
Magento\Framework\App\ObjectManager
Definition:
ConfigCache.php:8
Magento\Framework\Backup\Filesystem\Rollback\is_file
is_file($path)
Definition:
ioMock.php:25
Magento\Framework\Archive
Definition:
Archive.php:17
Magento\Framework\Archive\Helper\File
Definition:
File.php:14
Magento\Framework\Archive
Definition:
AbstractArchive.php:12
Magento\Framework\Archive\Helper\File\Gz
Definition:
Gz.php:12
Magento\Framework\Backup\Exception\NotEnoughPermissions
Definition:
NotEnoughPermissions.php:13
Magento\Framework\Backup\unlink
unlink($path)
Definition:
io.php:69
Magento\Framework\Backup\Filesystem\Rollback
Definition:
AbstractRollback.php:6
Magento\Framework\Backup\Filesystem\Helper
Definition:
Helper.php:17
Magento\Framework\Phrase
Definition:
Phrase.php:17
Magento\Framework\Phrase
Magento\Framework\Archive\Gz
Definition:
Gz.php:14
Magento\Framework\Backup\Filesystem\Rollback\AbstractRollback
Definition:
AbstractRollback.php:16
Magento\Framework\Archive\Tar
Definition:
Tar.php:16
Magento\Framework\Backup\Filesystem\Rollback\is_readable
is_readable($path)
Definition:
ioMock.php:14
Magento\Framework\Backup\Exception\CantLoadSnapshot
Definition:
CantLoadSnapshot.php:13