Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Member Functions
Media Class Reference
Inheritance diagram for Media:
Snapshot Filesystem AbstractBackup BackupInterface SourceFileInterface Nomedia

Public Member Functions

 rollback ()
 
 create ()
 
 getType ()
 
- Public Member Functions inherited from Snapshot
 __construct (AppFilesystem $filesystem, Factory $backupFactory)
 
 rollback ()
 
 create ()
 
 getType ()
 
 setDbBackupManager (AbstractBackup $manager)
 
 getDbBackupFilename ()
 
- Public Member Functions inherited from Filesystem
 rollback ()
 
 create ()
 
 validateAvailableDiscSpace ($backupDir, $size)
 
 setUseFtp ($host, $username, $password, $path)
 
 getType ()
 
 addIgnorePaths ($paths)
 
 getIgnorePaths ()
 
 setBackupsDir ($backupsDir)
 
 getFtpPath ()
 
 getFtpConnectString ()
 
- Public Member Functions inherited from AbstractBackup
 setBackupExtension ($backupExtension)
 
 getBackupExtension ()
 
 setResourceModel ($resourceModel)
 
 getResourceModel ()
 
 setTime ($time)
 
 getTime ()
 
 setRootDir ($rootDir)
 
 getRootDir ()
 
 setBackupsDir ($backupsDir)
 
 getBackupsDir ()
 
 getBackupPath ()
 
 getBackupFilename ()
 
 getIsSuccess ()
 
 getErrorMessage ()
 
 setErrorMessage ($errorMessage)
 
 setName ($name, $applyFilter=true)
 
 getName ()
 
 getDisplayName ()
 
 keepSourceFile ()
 
 setKeepSourceFile (bool $keepSourceFile)
 

Protected Member Functions

 _prepareIgnoreList ()
 
- Protected Member Functions inherited from Snapshot
 _createDbBackupInstance ()
 
 _getDbBackupManager ()
 
 _removeDbBackup ()
 
- Protected Member Functions inherited from Filesystem
 _checkBackupsDir ()
 
 _getTarTmpPath ()
 
 getRollBackFtp ()
 
 getRollBackFs ()
 
- Protected Member Functions inherited from AbstractBackup
 _filterName ($name)
 

Additional Inherited Members

- Protected Attributes inherited from Snapshot
 $_dbBackupManager
 
 $_filesystem
 
 $_backupFactory
 
- Protected Attributes inherited from Filesystem
 $_ignorePaths = []
 
 $_useFtp = false
 
 $_ftpHost
 
 $_ftpUser
 
 $_ftpPass
 
 $_ftpPath
 
 $rollBackFtp
 
 $rollBackFs
 
- Protected Attributes inherited from AbstractBackup
 $_name
 
 $_time
 
 $_backupExtension
 
 $_resourceModel
 
 $_rootDir
 
 $_backupsDir
 
 $_lastOperationSucceed = false
 
 $_lastErrorMessage
 

Detailed Description

Class to work media folder and database backups

Author
Magento Core Team core@.nosp@m.mage.nosp@m.ntoco.nosp@m.mmer.nosp@m.ce.co.nosp@m.m

Definition at line 13 of file Media.php.

Member Function Documentation

◆ _prepareIgnoreList()

_prepareIgnoreList ( )
protected

Add all folders and files except media and db backup to ignore list

Returns
$this

Definition at line 55 of file Media.php.

56  {
57  $rootDir = $this->getRootDir();
58  $map = [
59  $rootDir => ['var', 'pub'],
60  $rootDir . '/pub' => ['media'],
61  $rootDir . '/var' => [$this->getDbBackupFilename()],
62  ];
63 
64  foreach ($map as $path => $whiteList) {
65  foreach (new \DirectoryIterator($path) as $item) {
66  $filename = $item->getFilename();
67  if (!$item->isDot() && !in_array($filename, $whiteList)) {
68  $this->addIgnorePaths(str_replace('\\', '/', $item->getPathname()));
69  }
70  }
71  }
72 
73  return $this;
74  }
$rootDir
Definition: website.php:12

◆ create()

create ( )

Implementation Create Backup functionality for Media

Exceptions

Implements BackupInterface.

Definition at line 33 of file Media.php.

34  {
35  $this->_prepareIgnoreList();
36  return parent::create();
37  }

◆ getType()

getType ( )

Overlap getType

Returns
string
See also
BackupInterface::getType()

Implements BackupInterface.

Definition at line 45 of file Media.php.

46  {
47  return 'media';
48  }

◆ rollback()

rollback ( )

Implementation Rollback functionality for Media

Exceptions

Implements BackupInterface.

Definition at line 21 of file Media.php.

22  {
23  $this->_prepareIgnoreList();
24  return parent::rollback();
25  }

The documentation for this class was generated from the following file: