mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 04:23:19 +00:00
PHRAS-374 Add command to rebuild subdefs
This commit is contained in:
@@ -1202,7 +1202,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
*
|
||||
* @return record_adapter
|
||||
*/
|
||||
public function rebuild_subdefs()
|
||||
public function rebuild_subdefs()
|
||||
{
|
||||
$connbas = connection::getPDOConnection($this->app, $this->get_sbas_id());
|
||||
$sql = 'UPDATE record SET jeton=(jeton | ' . JETON_MAKE_SUBDEF . ') WHERE record_id = :record_id';
|
||||
@@ -1213,6 +1213,38 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get_missing_subdefs()
|
||||
{
|
||||
$databox = $this->get_databox();
|
||||
|
||||
try {
|
||||
$this->get_hd_file();
|
||||
} catch (\Exception $e) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$subDefDefinitions = $databox->get_subdef_structure()->getSubdefGroup($this->get_type());
|
||||
if (!$subDefDefinitions) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$record = $this;
|
||||
$wanted_subdefs = array_map(function($subDef) {
|
||||
return $subDef->get_name();
|
||||
}, array_filter($subDefDefinitions, function($subDef) use ($record) {
|
||||
return !$record->has_subdef($subDef->get_name());
|
||||
}));
|
||||
|
||||
|
||||
$missing_subdefs = array_map(function($subDef) {
|
||||
return $subDef->get_name();
|
||||
}, array_filter($this->get_subdefs(), function($subdef) {
|
||||
return !$subdef->is_physically_present();
|
||||
}));
|
||||
|
||||
return array_values(array_merge($wanted_subdefs, $missing_subdefs));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return record_adapter
|
||||
|
Reference in New Issue
Block a user