diff --git a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php index 7a09187ae2..6c072c2fdb 100644 --- a/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php +++ b/lib/Alchemy/Phrasea/Controller/Api/V1Controller.php @@ -1316,7 +1316,7 @@ class V1Controller extends Controller */ public function getRecordMetadataAction(Request $request, $databox_id, $record_id) { - $record = \record_adapter::getRecordLoaded($this->app, $databox_id, $record_id); + $record = $this->findDataboxById($databox_id)->get_record($record_id); $ret = ["record_metadatas" => $this->listRecordCaption($record->get_caption())]; return Result::create($request, $ret)->createResponse(); @@ -2417,7 +2417,8 @@ class V1Controller extends Controller public function ensureCanAccessToRecord(Request $request) { $user = $this->getApiAuthenticatedUser(); - $record = \record_adapter::getRecordLoaded($this->app, $request->attributes->get('databox_id'), $request->attributes->get('record_id')); + $record = $this->findDataboxById($request->attributes->get('databox_id')) + ->get_record($request->attributes->get('record_id')); if (!$this->getAclForUser($user)->has_access_to_record($record)) { return Result::createError($request, 401, 'You are not authorized')->createResponse(); } diff --git a/lib/classes/databox.php b/lib/classes/databox.php index 2ca3633dd1..40d9fda99e 100644 --- a/lib/classes/databox.php +++ b/lib/classes/databox.php @@ -250,7 +250,7 @@ class databox extends base implements ThumbnailedElement */ public function get_record($record_id, $number = null) { - return record_adapter::getRecordLoaded($this->app, $this->id, $record_id, $number); + return new record_adapter($this->app, $this->id, $record_id, $number); } public function get_label($code, $substitute = true) diff --git a/lib/classes/record/adapter.php b/lib/classes/record/adapter.php index 78e40e8c8c..331af3c5bd 100644 --- a/lib/classes/record/adapter.php +++ b/lib/classes/record/adapter.php @@ -107,28 +107,6 @@ class record_adapter implements RecordInterface, cache_cacheableInterface $this->mirror($record); } - /** - * returns a loaded record, same thing as calling new record_adapter(..., load=true) - * but does instantiate only one record, no need to mirror(). - * - * @param Application $app - * @param $sbas_id - * @param $record_id - * @param null $number - * - * @return null|record_adapter - */ - public static function getRecordLoaded(Application $app, $sbas_id, $record_id, $number = null) - { - if (null === ($record = $app->findDataboxById((int) $sbas_id)->getRecordRepository()->find($record_id))) { - throw new Exception_Record_AdapterNotFound('Record ' . $record_id . ' on database ' . $sbas_id . ' not found '); - } - $record->app = $app; - $record->number = $number; - - return $record; - } - /** * @param record_adapter $record */