88
99namespace Magento \Backup \Helper ;
1010
11+ use Magento \Backup \Model \Backup ;
12+ use Magento \Framework \App \Cache \TypeListInterface ;
1113use Magento \Framework \App \Filesystem \DirectoryList ;
14+ use Magento \Framework \App \Helper \AbstractHelper ;
15+ use Magento \Framework \App \Helper \Context ;
1216use Magento \Framework \App \MaintenanceMode ;
17+ use Magento \Framework \AuthorizationInterface ;
18+ use Magento \Framework \Backup \Factory ;
1319use Magento \Framework \Filesystem ;
1420
1521/**
1622 * Backup data helper
1723 * @api
1824 * @since 100.0.2
1925 */
20- class Data extends \ Magento \ Framework \ App \ Helper \ AbstractHelper
26+ class Data extends AbstractHelper
2127{
2228 /**
2329 * @var Filesystem
2430 */
2531 protected $ _filesystem ;
2632
2733 /**
28- * @var \Magento\Framework\ AuthorizationInterface
34+ * @var AuthorizationInterface
2935 */
3036 protected $ _authorization ;
3137
3238 /**
33- * @var \Magento\Framework\App\Cache\ TypeListInterface
39+ * @var TypeListInterface
3440 */
3541 protected $ _cacheTypeList ;
3642
3743 /**
3844 * Construct
3945 *
40- * @param \Magento\Framework\App\Helper\ Context $context
46+ * @param Context $context
4147 * @param Filesystem $filesystem
42- * @param \Magento\Framework\ AuthorizationInterface $authorization
43- * @param \Magento\Framework\App\Cache\ TypeListInterface $cacheTypeList
48+ * @param AuthorizationInterface $authorization
49+ * @param TypeListInterface $cacheTypeList
4450 */
4551 public function __construct (
46- \ Magento \ Framework \ App \ Helper \ Context $ context ,
52+ Context $ context ,
4753 Filesystem $ filesystem ,
48- \ Magento \ Framework \ AuthorizationInterface $ authorization ,
49- \ Magento \ Framework \ App \ Cache \ TypeListInterface $ cacheTypeList
54+ AuthorizationInterface $ authorization ,
55+ TypeListInterface $ cacheTypeList
5056 ) {
5157 parent ::__construct ($ context );
5258 $ this ->_authorization = $ authorization ;
@@ -62,10 +68,10 @@ public function __construct(
6268 public function getBackupTypes ()
6369 {
6470 return [
65- \ Magento \ Framework \ Backup \ Factory::TYPE_DB => __ ('Database ' ),
66- \ Magento \ Framework \ Backup \ Factory::TYPE_MEDIA => __ ('Database and Media ' ),
67- \ Magento \ Framework \ Backup \ Factory::TYPE_SYSTEM_SNAPSHOT => __ ('System ' ),
68- \ Magento \ Framework \ Backup \ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA => __ ('System (excluding Media) ' )
71+ Factory::TYPE_DB => __ ('Database ' ),
72+ Factory::TYPE_MEDIA => __ ('Database and Media ' ),
73+ Factory::TYPE_SYSTEM_SNAPSHOT => __ ('System ' ),
74+ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA => __ ('System (excluding Media) ' )
6975 ];
7076 }
7177
@@ -77,10 +83,10 @@ public function getBackupTypes()
7783 public function getBackupTypesList ()
7884 {
7985 return [
80- \ Magento \ Framework \ Backup \ Factory::TYPE_DB ,
81- \ Magento \ Framework \ Backup \ Factory::TYPE_SYSTEM_SNAPSHOT ,
82- \ Magento \ Framework \ Backup \ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA ,
83- \ Magento \ Framework \ Backup \ Factory::TYPE_MEDIA
86+ Factory::TYPE_DB ,
87+ Factory::TYPE_SYSTEM_SNAPSHOT ,
88+ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA ,
89+ Factory::TYPE_MEDIA
8490 ];
8591 }
8692
@@ -91,7 +97,7 @@ public function getBackupTypesList()
9197 */
9298 public function getDefaultBackupType ()
9399 {
94- return \ Magento \ Framework \ Backup \ Factory::TYPE_DB ;
100+ return Factory::TYPE_DB ;
95101 }
96102
97103 /**
@@ -124,22 +130,22 @@ public function getExtensionByType($type)
124130 public function getExtensions ()
125131 {
126132 return [
127- \ Magento \ Framework \ Backup \ Factory::TYPE_SYSTEM_SNAPSHOT => 'tgz ' ,
128- \ Magento \ Framework \ Backup \ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA => 'tgz ' ,
129- \ Magento \ Framework \ Backup \ Factory::TYPE_MEDIA => 'tgz ' ,
130- \ Magento \ Framework \ Backup \ Factory::TYPE_DB => 'sql '
133+ Factory::TYPE_SYSTEM_SNAPSHOT => 'tgz ' ,
134+ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA => 'tgz ' ,
135+ Factory::TYPE_MEDIA => 'tgz ' ,
136+ Factory::TYPE_DB => 'sql '
131137 ];
132138 }
133139
134140 /**
135141 * Generate backup download name
136142 *
137- * @param \Magento\Backup\Model\ Backup $backup
143+ * @param Backup $backup
138144 * @return string
139145 */
140- public function generateBackupDownloadName (\ Magento \ Backup \ Model \ Backup $ backup )
146+ public function generateBackupDownloadName (Backup $ backup )
141147 {
142- $ additionalExtension = $ backup ->getType () == \ Magento \ Framework \ Backup \ Factory::TYPE_DB ? '.sql ' : '' ;
148+ $ additionalExtension = $ backup ->getType () == Factory::TYPE_DB ? '.sql ' : '' ;
143149 return $ backup ->getTime () .
144150 '_ ' .
145151 $ backup ->getType () .
@@ -213,12 +219,12 @@ public function getRollbackIgnorePaths()
213219 public function getCreateSuccessMessageByType ($ type )
214220 {
215221 $ messagesMap = [
216- \ Magento \ Framework \ Backup \ Factory::TYPE_SYSTEM_SNAPSHOT => __ ('You created the system backup. ' ),
217- \ Magento \ Framework \ Backup \ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA => __ (
222+ Factory::TYPE_SYSTEM_SNAPSHOT => __ ('You created the system backup. ' ),
223+ Factory::TYPE_SNAPSHOT_WITHOUT_MEDIA => __ (
218224 'You created the system backup (excluding media). '
219225 ),
220- \ Magento \ Framework \ Backup \ Factory::TYPE_MEDIA => __ ('You created the database and media backup. ' ),
221- \ Magento \ Framework \ Backup \ Factory::TYPE_DB => __ ('You created the database backup. ' ),
226+ Factory::TYPE_MEDIA => __ ('You created the database and media backup. ' ),
227+ Factory::TYPE_DB => __ ('You created the database backup. ' ),
222228 ];
223229
224230 if (!isset ($ messagesMap [$ type ])) {
@@ -263,7 +269,7 @@ public function extractDataFromFilename($filename)
263269 {
264270 $ extensions = $ this ->getExtensions ();
265271
266- $ filenameWithoutExtension = $ filename ;
272+ $ filenameWithoutExtension = $ filename ?: '' ;
267273
268274 foreach ($ extensions as $ extension ) {
269275 $ filenameWithoutExtension = preg_replace (
0 commit comments