mirror of
https://github.com/Chouchen/Shikiryu_Backup.git
synced 2021-06-30 16:02:14 +02:00
Add a lot of docs
This commit is contained in:
parent
ffdf0b8476
commit
dd2a6bd7d7
@ -157,6 +157,11 @@ class Email extends TransportAbstract
|
|||||||
$this->encoding = $this->config['encoding'];
|
$this->encoding = $this->config['encoding'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $files
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
private function setFiles($files = array())
|
private function setFiles($files = array())
|
||||||
{
|
{
|
||||||
if (is_array($files) && !empty($files)) {
|
if (is_array($files) && !empty($files)) {
|
||||||
@ -165,6 +170,11 @@ class Email extends TransportAbstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $streams
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
private function setStreams($streams = array())
|
private function setStreams($streams = array())
|
||||||
{
|
{
|
||||||
if (is_array($streams) && !empty($streams)) {
|
if (is_array($streams) && !empty($streams)) {
|
||||||
@ -240,5 +250,3 @@ Content-Disposition: attachment; filename=" . $name . "
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -51,6 +51,9 @@ class Ftp extends TransportAbstract
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
public function send()
|
public function send()
|
||||||
{
|
{
|
||||||
$sent = true;
|
$sent = true;
|
||||||
@ -82,6 +85,8 @@ class Ftp extends TransportAbstract
|
|||||||
if (!$sent) {
|
if (!$sent) {
|
||||||
throw new \Exception('At least an upload didnt work.');
|
throw new \Exception('At least an upload didnt work.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $sent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
|
@ -7,7 +7,7 @@ use Shikiryu\Backup\Backup\BackupAbstract;
|
|||||||
|
|
||||||
class Folder extends TransportAbstract
|
class Folder extends TransportAbstract
|
||||||
{
|
{
|
||||||
|
/** @var string */
|
||||||
protected $folder;
|
protected $folder;
|
||||||
|
|
||||||
public function __construct(BackupAbstract $backup, array $config = array())
|
public function __construct(BackupAbstract $backup, array $config = array())
|
||||||
@ -21,6 +21,7 @@ class Folder extends TransportAbstract
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function send()
|
public function send()
|
||||||
|
@ -6,13 +6,17 @@ use phpseclib\Net\SFTP as LibSFTP;
|
|||||||
|
|
||||||
class Sftp extends TransportAbstract
|
class Sftp extends TransportAbstract
|
||||||
{
|
{
|
||||||
|
/** @var string */
|
||||||
protected $host;
|
protected $host;
|
||||||
|
/** @var int */
|
||||||
protected $port = 22;
|
protected $port = 22;
|
||||||
|
/** @var string */
|
||||||
protected $login;
|
protected $login;
|
||||||
|
/** @var string */
|
||||||
protected $password;
|
protected $password;
|
||||||
|
/** @var string */
|
||||||
protected $folder;
|
protected $folder;
|
||||||
|
/** @var LibSFTP */
|
||||||
private $connection;
|
private $connection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +36,7 @@ class Sftp extends TransportAbstract
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function send()
|
public function send()
|
||||||
|
@ -7,7 +7,9 @@ use Shikiryu\Backup\Backup\BackupAbstract;
|
|||||||
abstract class TransportAbstract
|
abstract class TransportAbstract
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/** @var BackupAbstract */
|
||||||
protected $backup;
|
protected $backup;
|
||||||
|
/** @var array */
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
public function __construct(BackupAbstract $backup, array $config)
|
public function __construct(BackupAbstract $backup, array $config)
|
||||||
|
@ -4,7 +4,7 @@ namespace Shikiryu\Backup\Backup;
|
|||||||
|
|
||||||
abstract class BackupAbstract
|
abstract class BackupAbstract
|
||||||
{
|
{
|
||||||
|
/** @var array */
|
||||||
protected $options;
|
protected $options;
|
||||||
/** @var string[] */
|
/** @var string[] */
|
||||||
protected $_filesToBackup = [];
|
protected $_filesToBackup = [];
|
||||||
@ -75,6 +75,9 @@ abstract class BackupAbstract
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize everything
|
||||||
|
*/
|
||||||
protected function init()
|
protected function init()
|
||||||
{
|
{
|
||||||
$this->preBuild();
|
$this->preBuild();
|
||||||
@ -83,9 +86,23 @@ abstract class BackupAbstract
|
|||||||
$this->applyOptions();
|
$this->applyOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be used to initialize the backup
|
||||||
|
*/
|
||||||
abstract protected function preBuild();
|
abstract protected function preBuild();
|
||||||
|
/**
|
||||||
|
* Function that can be used after the backup
|
||||||
|
*/
|
||||||
abstract protected function postBuild();
|
abstract protected function postBuild();
|
||||||
|
/**
|
||||||
|
* Mandatory function doing the backup
|
||||||
|
*/
|
||||||
abstract protected function build();
|
abstract protected function build();
|
||||||
|
/**
|
||||||
|
* Check if the backup is valid
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
abstract public function isValid();
|
abstract public function isValid();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -204,7 +221,10 @@ abstract class BackupAbstract
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $name
|
* @param $name
|
||||||
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("unused")
|
||||||
*/
|
*/
|
||||||
protected function setOptionName($name)
|
protected function setOptionName($name)
|
||||||
{
|
{
|
||||||
@ -214,5 +234,3 @@ abstract class BackupAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -21,6 +21,13 @@ class Files extends BackupAbstract
|
|||||||
parent::__construct($config);
|
parent::__construct($config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the backup is valid
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*
|
||||||
|
* @SuppressWarnings("unused")
|
||||||
|
*/
|
||||||
public function isValid()
|
public function isValid()
|
||||||
{
|
{
|
||||||
$result = true;
|
$result = true;
|
||||||
@ -33,16 +40,25 @@ class Files extends BackupAbstract
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be used to initialize the backup
|
||||||
|
*/
|
||||||
protected function preBuild()
|
protected function preBuild()
|
||||||
{
|
{
|
||||||
// TODO: Implement preBuild() method.
|
// TODO: Implement preBuild() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be used after the backup
|
||||||
|
*/
|
||||||
protected function postBuild()
|
protected function postBuild()
|
||||||
{
|
{
|
||||||
// TODO: Implement postBuild() method.
|
// TODO: Implement postBuild() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mandatory function doing the backup
|
||||||
|
*/
|
||||||
protected function build()
|
protected function build()
|
||||||
{
|
{
|
||||||
// TODO: Implement build() method.
|
// TODO: Implement build() method.
|
||||||
|
@ -18,16 +18,25 @@ class Folder extends BackupAbstract
|
|||||||
// TODO: Implement isValid() method.
|
// TODO: Implement isValid() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be used to initialize the backup
|
||||||
|
*/
|
||||||
protected function preBuild()
|
protected function preBuild()
|
||||||
{
|
{
|
||||||
// TODO: Implement preBuild() method.
|
// TODO: Implement preBuild() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be used after the backup
|
||||||
|
*/
|
||||||
protected function postBuild()
|
protected function postBuild()
|
||||||
{
|
{
|
||||||
// TODO: Implement postBuild() method.
|
// TODO: Implement postBuild() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mandatory function doing the backup
|
||||||
|
*/
|
||||||
protected function build()
|
protected function build()
|
||||||
{
|
{
|
||||||
// TODO: Implement build() method.
|
// TODO: Implement build() method.
|
||||||
|
@ -100,16 +100,25 @@ class Mysql extends BackupAbstract
|
|||||||
return !empty($this->_streamsToBackup);
|
return !empty($this->_streamsToBackup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be used to initialize the backup
|
||||||
|
*/
|
||||||
protected function preBuild()
|
protected function preBuild()
|
||||||
{
|
{
|
||||||
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->database, $this->login, $this->pwd);
|
$this->pdo = new \PDO('mysql:host='.$this->host.';dbname='.$this->database, $this->login, $this->pwd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be used after the backup
|
||||||
|
*/
|
||||||
protected function postBuild()
|
protected function postBuild()
|
||||||
{
|
{
|
||||||
// TODO: Implement postBuild() method.
|
// TODO: Implement postBuild() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mandatory function doing the backup
|
||||||
|
*/
|
||||||
protected function build()
|
protected function build()
|
||||||
{
|
{
|
||||||
empty($this->tables) || $this->tables == '*' ? $this->everything() : $this->fromTables($this->tables);
|
empty($this->tables) || $this->tables == '*' ? $this->everything() : $this->fromTables($this->tables);
|
||||||
|
Loading…
Reference in New Issue
Block a user