mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 07:23:13 +00:00
Merge pull request #2489 from aynsix/PHRAS-569-ajout-info-/api/v1/quarantine
PHRAS-569 Add "reasons" in api/v1/quarantine
This commit is contained in:
@@ -688,8 +688,18 @@ class V1Controller extends Controller
|
||||
|
||||
$checks = array_map(function (LazaretCheck $checker) use ($manager, $translator) {
|
||||
$checkerFQCN = $checker->getCheckClassname();
|
||||
|
||||
return $manager->getCheckerFromFQCN($checkerFQCN)->getMessage($translator);
|
||||
}, iterator_to_array($file->getChecks()));
|
||||
}, $file->getChecksWhithNameKey());
|
||||
|
||||
$recordsMatch = array_map(function ($recordsTab){
|
||||
$record = $recordsTab['record'];
|
||||
$matched['record_id'] = $record->getRecordId();
|
||||
$matched['collection'] = $record->getCollectionName();
|
||||
$matched['checks'] = $recordsTab['reasons'];
|
||||
|
||||
return $matched;
|
||||
}, array_values($file->getRecordsToSubstitute($this->app, true)));
|
||||
|
||||
$usr_id = $user = null;
|
||||
if ($file->getSession()->getUser()) {
|
||||
@@ -708,10 +718,12 @@ class V1Controller extends Controller
|
||||
'quarantine_session' => $session,
|
||||
'base_id' => $file->getBaseId(),
|
||||
'original_name' => $file->getOriginalName(),
|
||||
'collection' => $file->getCollection($this->app)->get_label($this->app['locale']),
|
||||
'sha256' => $file->getSha256(),
|
||||
'uuid' => $file->getUuid(),
|
||||
'forced' => $file->getForced(),
|
||||
'checks' => $file->getForced() ? [] : $checks,
|
||||
'records_match' => $recordsMatch?:[],
|
||||
'created_on' => $file->getCreated()->format(DATE_ATOM),
|
||||
'updated_on' => $file->getUpdated()->format(DATE_ATOM),
|
||||
];
|
||||
|
@@ -386,6 +386,17 @@ class LazaretFile
|
||||
$this->checks->removeElement($checks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LazaretCheck $checks
|
||||
* @return string
|
||||
*/
|
||||
public function getCheckerName(LazaretCheck $checks)
|
||||
{
|
||||
$checkNameTab = explode('\\', $checks->getCheckClassname());
|
||||
|
||||
return $checkNameTab[4];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get checks
|
||||
*
|
||||
@@ -396,6 +407,19 @@ class LazaretFile
|
||||
return $this->checks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array $checkers
|
||||
*/
|
||||
public function getChecksWhithNameKey()
|
||||
{
|
||||
$checkers = [];
|
||||
foreach($this->checks as $check){
|
||||
$checkers[$this->getCheckerName($check)] = $check;
|
||||
}
|
||||
|
||||
return $checkers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set session
|
||||
*
|
||||
@@ -439,7 +463,7 @@ class LazaretFile
|
||||
'reasons' => []
|
||||
];
|
||||
}
|
||||
$merged[$record->getRecordId()]['reasons'][] = $check->getReason($app['translator']);
|
||||
$merged[$record->getRecordId()]['reasons'][$this->getCheckerName($check)] = $check->getReason($app['translator']);
|
||||
}
|
||||
else {
|
||||
$merged[$record->getRecordId()] = $record;
|
||||
|
Reference in New Issue
Block a user