Replaced Moment with Carbon #84
2 changed files with 20 additions and 31 deletions
|
@ -8,10 +8,14 @@ use Carbon\Carbon;
|
||||||
class MaintenanceService
|
class MaintenanceService
|
||||||
{
|
{
|
||||||
protected $settings;
|
protected $settings;
|
||||||
|
protected $filePaths = [];
|
||||||
|
|
||||||
public function __construct(SettingsService $settingsService)
|
public function __construct(SettingsService $settingsService)
|
||||||
{
|
{
|
||||||
$this->settings = $settingsService;
|
$this->settings = $settingsService;
|
||||||
|
$this->filePaths = ['../public/assets/images/blog',
|
||||||
|
'../public/assets/images/user', '../public/assets/docs/blog',
|
||||||
|
'../public/assets/video/blog', '../public/assets/sound/blog'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createContentBackUp()
|
public function createContentBackUp()
|
||||||
|
@ -133,36 +137,21 @@ class MaintenanceService
|
||||||
\ZipArchive::CREATE | \ZipArchive::OVERWRITE
|
\ZipArchive::CREATE | \ZipArchive::OVERWRITE
|
||||||
);
|
);
|
||||||
//gather data and path info for blog images
|
//gather data and path info for blog images
|
||||||
$blogImagesPath = '../public/assets/images/blog';
|
|
||||||
$yearPaths = glob($blogImagesPath . '/*', GLOB_ONLYDIR);
|
|
||||||
foreach ($yearPaths as $years) {
|
|
||||||
$year = explode('/', $years);
|
|
||||||
$monthsPath = glob($blogImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
|
||||||
foreach ($monthsPath as $months) {
|
|
||||||
$month = explode('/', $months);
|
|
||||||
//once info is collected, add images pages to zip
|
|
||||||
$options = [
|
|
||||||
'add_path' => 'public/assets/images/blog/' . $year[5] . '/' . $month[6] . '/',
|
|
||||||
'remove_all_path' => true,
|
|
||||||
];
|
|
||||||
$zip->addGlob($months . '/*.*', GLOB_BRACE, $options);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//gather data and path info for user images
|
foreach ($this->filePaths as $path) {
|
||||||
$userImagesPath = '../public/assets/images/user';
|
$yearPaths = glob($path . '/*', GLOB_ONLYDIR);
|
||||||
$yearPaths = glob($userImagesPath . '/*', GLOB_ONLYDIR);
|
foreach ($yearPaths as $years) {
|
||||||
foreach ($yearPaths as $years) {
|
$year = explode('/', $years);
|
||||||
$year = explode('/', $years);
|
$monthsPath = glob($path . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
||||||
$monthsPath = glob($userImagesPath . '/' . $year[5] . '/*', GLOB_ONLYDIR);
|
foreach ($monthsPath as $months) {
|
||||||
foreach ($monthsPath as $months) {
|
$month = explode('/', $months);
|
||||||
$month = explode('/', $months);
|
//once info is collected, add images pages to zip
|
||||||
//once info is collected, add images pages to zip
|
$options = [
|
||||||
$options = [
|
'add_path' => substr($path, 3) . '/' . $year[5] . '/' . $month[6] . '/',
|
||||||
'add_path' => 'public/assets/images/user/' . $year[5] . '/' . $month[6] . '/',
|
'remove_all_path' => true,
|
||||||
'remove_all_path' => true,
|
];
|
||||||
];
|
$zip->addGlob($months . '/*.*', GLOB_BRACE, $options);
|
||||||
$zip->addGlob($months . '/*.*', GLOB_BRACE, $options);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ class MaintenanceManager {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
|
if (requestType == REQUEST_TYPE_PUT || requestType == REQUEST_TYPE_POST) {
|
||||||
if (eventType === TASK_UPLOAD_FILES)
|
if (eventType === TASK_UPLOAD_FILES || eventType === TASK_BACKUP_CREATE)
|
||||||
request.setRequestHeader('fipamo-access-token', self.token);
|
request.setRequestHeader('fipamo-access-token', self.token);
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
case CONTENT_TYPE_JSON:
|
case CONTENT_TYPE_JSON:
|
||||||
|
|
Loading…
Add table
Reference in a new issue