Reformat ArchiveJob

This commit is contained in:
Benoît Burnichon
2016-03-10 11:51:30 +01:00
parent 435803a2d0
commit ac746bcfd9

View File

@@ -1,9 +1,9 @@
<?php <?php
/* /**
* This file is part of Phraseanet * This file is part of Phraseanet
* *
* (c) 2005-2014 Alchemy * (c) 2005-2016 Alchemy
* *
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
@@ -114,30 +114,25 @@ class ArchiveJob extends AbstractJob
$stat1 = '0'; $stat1 = '0';
} }
// check the data-repository exists $filesystem = $app['filesystem'];
$pathhd = (string) $settings->path;
if ($pathhd) {
$app['filesystem']->mkdir($pathhd, 0750);
}
// load masks // load masks
if ($settings->files && $settings->files->file) { if ($settings->files && $settings->files->file) {
foreach ($settings->files->file as $ft) { foreach ($settings->files->file as $ft) {
$tmask[] = [ $tmask[] = [
"mask" => (string) $ft["mask"] "mask" => (string)$ft["mask"],
, "caption" => (string) $ft["caption"] "caption" => (string)$ft["caption"],
, "accept" => (string) $ft["accept"] "accept" => (string)$ft["accept"],
]; ];
} }
} }
if ($settings->files && $settings->files->grouping) { if ($settings->files && $settings->files->grouping) {
foreach ($settings->files->grouping as $ft) { foreach ($settings->files->grouping as $ft) {
$tmaskgrp[] = [ $tmaskgrp[] = [
"mask" => (string) $ft["mask"] "mask" => (string)$ft["mask"],
, "caption" => (string) $ft["caption"] "caption" => (string)$ft["caption"],
, "representation" => (string) $ft["representation"] "representation" => (string)$ft["representation"],
, "accept" => (string) $ft["accept"] "accept" => (string)$ft["accept"],
]; ];
} }
} }
@@ -158,18 +153,18 @@ class ArchiveJob extends AbstractJob
clearstatcache(); clearstatcache();
if (false === $app['filesystem']->exists($path_in . "/.phrasea.xml")) { if (false === $filesystem->exists($path_in . "/.phrasea.xml")) {
throw new RuntimeException(sprintf('NO .phrasea.xml AT ROOT \'%s\' !', $path_in)); throw new RuntimeException(sprintf('NO .phrasea.xml AT ROOT \'%s\' !', $path_in));
} }
$path_archived = $path_error = null; $path_archived = $path_error = null;
if ($moveArchived) { if ($moveArchived) {
$path_archived = $path_in . '_archived'; $path_archived = $path_in . '_archived';
$app['filesystem']->mkdir($path_archived, 0755); $filesystem->mkdir($path_archived, 0755);
} }
if ($moveError) { if ($moveError) {
$path_error = $path_in . '_error'; $path_error = $path_in . '_error';
$app['filesystem']->mkdir($path_error, 0755); $filesystem->mkdir($path_error, 0755);
} }
$dom = new \DOMDocument(); $dom = new \DOMDocument();