2015-07-03 00:00:30 +02:00
|
|
|
<?php
|
2015-07-10 19:07:14 +02:00
|
|
|
namespace Shikiryu\Backup\Backup;
|
2015-07-03 00:00:30 +02:00
|
|
|
|
2015-07-10 19:07:14 +02:00
|
|
|
class Files extends BackupAbstract
|
2015-07-03 00:00:30 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
2015-07-10 23:13:46 +02:00
|
|
|
* @param array $config
|
|
|
|
* @throws \Exception
|
2015-07-03 00:00:30 +02:00
|
|
|
*/
|
2015-07-12 20:34:54 +02:00
|
|
|
public function __construct(array $config = array())
|
2015-07-03 00:00:30 +02:00
|
|
|
{
|
2015-07-10 23:13:46 +02:00
|
|
|
if (!isset($config['files'])) {
|
|
|
|
throw new \Exception('Files needs a "files" configuration.');
|
|
|
|
}
|
|
|
|
$filesToBackup = $config['files'];
|
2015-07-03 00:00:30 +02:00
|
|
|
if(!empty($filesToBackup) && is_array($filesToBackup)){
|
2015-07-09 00:46:17 +02:00
|
|
|
$names = array_map("basename",$filesToBackup);
|
2015-07-03 00:00:30 +02:00
|
|
|
$this->_filesToBackup = array_combine($filesToBackup,$names);
|
|
|
|
}
|
2015-08-18 17:02:37 +02:00
|
|
|
parent::__construct($config);
|
2015-07-03 00:00:30 +02:00
|
|
|
}
|
|
|
|
|
2015-07-12 20:34:54 +02:00
|
|
|
public function isValid()
|
2015-07-03 00:00:30 +02:00
|
|
|
{
|
2015-07-12 20:34:54 +02:00
|
|
|
$result = true;
|
|
|
|
foreach ($this->_filesToBackup as $file => $name) {
|
|
|
|
if (!file_exists($file)) {
|
|
|
|
$result = false;
|
|
|
|
break;
|
|
|
|
}
|
2015-07-03 00:00:30 +02:00
|
|
|
}
|
2015-07-12 20:34:54 +02:00
|
|
|
return $result;
|
2015-07-03 00:00:30 +02:00
|
|
|
}
|
2015-07-12 20:34:54 +02:00
|
|
|
|
2015-08-18 17:02:37 +02:00
|
|
|
protected function preBuild()
|
|
|
|
{
|
|
|
|
// TODO: Implement preBuild() method.
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function postBuild()
|
|
|
|
{
|
|
|
|
// TODO: Implement postBuild() method.
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function build()
|
|
|
|
{
|
|
|
|
// TODO: Implement build() method.
|
|
|
|
}
|
2015-07-03 00:00:30 +02:00
|
|
|
}
|
|
|
|
?>
|