mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Rename method to be consistent accross library
This commit is contained in:
@@ -133,13 +133,13 @@ class DbalMediaSubdefDataRepository implements MediaSubdefDataRepository
|
|||||||
|
|
||||||
$sql = <<<'SQL'
|
$sql = <<<'SQL'
|
||||||
INSERT INTO subdef (record_id, name, path, file, width, height, mime, size, substit, etag, created_on, updated_on, dispatched)
|
INSERT INTO subdef (record_id, name, path, file, width, height, mime, size, substit, etag, created_on, updated_on, dispatched)
|
||||||
VALUES (:recordId, :name, :path, :file, :width, :height, :mime, :size, :substit, :etag, NOW(), NOW(), 1)
|
VALUES (:record_id, :name, :path, :file, :width, :height, :mime, :size, :substit, :etag, NOW(), NOW(), 1)
|
||||||
SQL;
|
SQL;
|
||||||
$statement = $this->connection->prepare($sql);
|
$statement = $this->connection->prepare($sql);
|
||||||
|
|
||||||
foreach ($toInsert as $index => $partition) {
|
foreach ($toInsert as $index => $partition) {
|
||||||
try {
|
try {
|
||||||
$statement->execute($this->getParametersFromArray($partition));
|
$statement->execute($this->phpToSql($partition));
|
||||||
} catch (DriverException $exception) {
|
} catch (DriverException $exception) {
|
||||||
$updateNeeded[$index] = $partition;
|
$updateNeeded[$index] = $partition;
|
||||||
}
|
}
|
||||||
@@ -148,26 +148,6 @@ SQL;
|
|||||||
return $updateNeeded;
|
return $updateNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param array $data
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
private function getParametersFromArray(array $data)
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'recordId' => $data['record_id'],
|
|
||||||
'name' => $data['name'],
|
|
||||||
'path' => $data['path'],
|
|
||||||
'file' => $data['file'],
|
|
||||||
'width' => $data['width'],
|
|
||||||
'height' => $data['height'],
|
|
||||||
'mime' => $data['mime'],
|
|
||||||
'size' => $data['size'],
|
|
||||||
'substit' => $data['substit'],
|
|
||||||
'etag' => $data['etag'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $toUpdate
|
* @param array $toUpdate
|
||||||
* @throws DBALException
|
* @throws DBALException
|
||||||
@@ -182,12 +162,12 @@ SQL;
|
|||||||
UPDATE subdef
|
UPDATE subdef
|
||||||
SET path = :path, file = :file, width = :width, height = :height, mime = :mime,
|
SET path = :path, file = :file, width = :width, height = :height, mime = :mime,
|
||||||
size = :size, substit = :substit, etag = :etag, updated_on = NOW()
|
size = :size, substit = :substit, etag = :etag, updated_on = NOW()
|
||||||
WHERE record_id = :recordId AND name = :name
|
WHERE record_id = :record_id AND name = :name
|
||||||
SQL;
|
SQL;
|
||||||
$statement = $this->connection->prepare($sql);
|
$statement = $this->connection->prepare($sql);
|
||||||
|
|
||||||
foreach ($toUpdate as $index => $partition) {
|
foreach ($toUpdate as $index => $partition) {
|
||||||
$statement->execute($this->getParametersFromArray($partition));
|
$statement->execute($this->phpToSql($partition));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,6 +179,26 @@ FROM subdef
|
|||||||
SQL;
|
SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
private function phpToSql(array $data)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'record_id' => $data['record_id'],
|
||||||
|
'name' => $data['name'],
|
||||||
|
'path' => $data['path'],
|
||||||
|
'file' => $data['file'],
|
||||||
|
'width' => $data['width'],
|
||||||
|
'height' => $data['height'],
|
||||||
|
'mime' => $data['mime'],
|
||||||
|
'size' => $data['size'],
|
||||||
|
'substit' => $data['is_substituted'],
|
||||||
|
'etag' => $data['etag'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private function sqlToPhp(array $data)
|
private function sqlToPhp(array $data)
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
Reference in New Issue
Block a user