Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractBackup.php
Go to the documentation of this file.
1 <?php
7 
10 
18 {
24  protected $_name;
25 
31  protected $_time;
32 
38  protected $_backupExtension;
39 
45  protected $_resourceModel;
46 
52  protected $_rootDir;
53 
59  protected $_backupsDir;
60 
66  protected $_lastOperationSucceed = false;
67 
73  protected $_lastErrorMessage;
74 
80  private $keepSourceFile;
81 
88  public function setBackupExtension($backupExtension)
89  {
90  $this->_backupExtension = $backupExtension;
91  return $this;
92  }
93 
99  public function getBackupExtension()
100  {
102  }
103 
111  {
112  $this->_resourceModel = $resourceModel;
113  return $this;
114  }
115 
121  public function getResourceModel()
122  {
123  return $this->_resourceModel;
124  }
125 
132  public function setTime($time)
133  {
134  $this->_time = $time;
135  return $this;
136  }
137 
143  public function getTime()
144  {
145  return $this->_time;
146  }
147 
155  public function setRootDir($rootDir)
156  {
157  if (!is_dir($rootDir)) {
158  throw new LocalizedException(
159  new Phrase('Bad root directory')
160  );
161  }
162 
163  $this->_rootDir = $rootDir;
164  return $this;
165  }
166 
171  public function getRootDir()
172  {
173  return $this->_rootDir;
174  }
175 
182  public function setBackupsDir($backupsDir)
183  {
184  $this->_backupsDir = $backupsDir;
185  return $this;
186  }
187 
193  public function getBackupsDir()
194  {
195  return $this->_backupsDir;
196  }
197 
203  public function getBackupPath()
204  {
205  return $this->getBackupsDir() . '/' . $this->getBackupFilename();
206  }
207 
213  public function getBackupFilename()
214  {
215  $filename = $this->getTime() . '_' . $this->getType();
216 
217  $name = $this->getName();
218 
219  if (!empty($name)) {
220  $filename .= '_' . $name;
221  }
222 
223  $filename .= '.' . $this->getBackupExtension();
224 
225  return $filename;
226  }
227 
234  public function getIsSuccess()
235  {
237  }
238 
244  public function getErrorMessage()
245  {
247  }
248 
255  public function setErrorMessage($errorMessage)
256  {
257  $this->_lastErrorMessage = $errorMessage;
258  }
259 
267  public function setName($name, $applyFilter = true)
268  {
269  if ($applyFilter) {
270  $name = $this->_filterName($name);
271  }
272  $this->_name = $name;
273  return $this;
274  }
275 
281  public function getName()
282  {
283  return $this->_name;
284  }
285 
291  public function getDisplayName()
292  {
293  return str_replace('_', ' ', $this->_name);
294  }
295 
302  protected function _filterName($name)
303  {
304  $name = trim(preg_replace('/[^\da-zA-Z ]/', '', $name));
305  $name = preg_replace('/\s{2,}/', ' ', $name);
306  $name = str_replace(' ', '_', $name);
307 
308  return $name;
309  }
310 
316  public function keepSourceFile()
317  {
318  return $this->keepSourceFile;
319  }
320 
327  public function setKeepSourceFile(bool $keepSourceFile)
328  {
329  $this->keepSourceFile = $keepSourceFile;
330  return $this;
331  }
332 }
$resourceModel
Definition: tablerates.php:10
$rootDir
Definition: website.php:12
if(!isset($_GET['name'])) $name
Definition: log.php:14