mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 09:53:15 +00:00
Merge pull request #2638 from aynsix/PHRAS-2098-save-in-technicaldata-table
PHRAS-2098 Sauvegarder les coordonnées GPS du forward geocoding dans le technicalData du record
This commit is contained in:
@@ -358,6 +358,10 @@ class EditController extends Controller
|
||||
$this->dispatch(PhraseaEvents::RECORD_EDIT, new RecordEdit($record));
|
||||
}
|
||||
|
||||
if (isset($rec['technicalsdatas']) && is_array($rec['technicalsdatas'])){
|
||||
$record->insertOrUpdateTechnicalDatas($rec['technicalsdatas']);
|
||||
}
|
||||
|
||||
$newstat = $record->getStatus();
|
||||
$statbits = ltrim($statbits, 'x');
|
||||
if (!in_array($statbits, ['', 'null'])) {
|
||||
|
@@ -1338,6 +1338,37 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert or update technical data
|
||||
* $technicalDatas an array of name => value
|
||||
*
|
||||
* @param array $technicalDatas
|
||||
*/
|
||||
public function insertOrUpdateTechnicalDatas($technicalDatas)
|
||||
{
|
||||
$technicalFields = media_subdef::getTechnicalFieldsList();
|
||||
$sqlValues = null;
|
||||
|
||||
foreach($technicalDatas as $name => $value){
|
||||
if(array_key_exists($name, $technicalFields)){
|
||||
if(is_null($value)){
|
||||
$value = 0;
|
||||
}
|
||||
$sqlValues[] = [$this->getRecordId(), $name, $value, $value];
|
||||
}
|
||||
}
|
||||
|
||||
if($sqlValues){
|
||||
$connection = $this->getDataboxConnection();
|
||||
$connection->transactional(function (Connection $connection) use ($sqlValues) {
|
||||
$statement = $connection->prepare('INSERT INTO technical_datas (record_id, name, value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value = ?');
|
||||
array_walk($sqlValues, [$statement, 'execute']);
|
||||
});
|
||||
|
||||
$this->delete_data_from_cache(self::CACHE_TECHNICAL_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param databox $databox
|
||||
* @param string $sha256
|
||||
|
Reference in New Issue
Block a user