Handle metadata formats as entities
This commit is contained in:
parent
152bc9030f
commit
1e275422bf
|
@ -219,17 +219,17 @@ class Database
|
||||||
* Get a single record.
|
* Get a single record.
|
||||||
*
|
*
|
||||||
* @param string $identifier The record identifier
|
* @param string $identifier The record identifier
|
||||||
* @param string $metadataPrefix The metadata prefix
|
* @param Format $format The metadata format
|
||||||
*
|
*
|
||||||
* @return ?Record The record or NULL on failure
|
* @return ?Record The record or NULL on failure
|
||||||
*/
|
*/
|
||||||
public function getRecord(string $identifier, string $metadataPrefix): ?Record
|
public function getRecord(string $identifier, Format $format): ?Record
|
||||||
{
|
{
|
||||||
return $this->entityManager->find(
|
return $this->entityManager->find(
|
||||||
Record::class,
|
Record::class,
|
||||||
[
|
[
|
||||||
'identifier' => $identifier,
|
'identifier' => $identifier,
|
||||||
'format' => $metadataPrefix
|
'format' => $format
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ declare(strict_types=1);
|
||||||
namespace OCC\OaiPmh2\Middleware;
|
namespace OCC\OaiPmh2\Middleware;
|
||||||
|
|
||||||
use OCC\OaiPmh2\Database;
|
use OCC\OaiPmh2\Database;
|
||||||
|
use OCC\OaiPmh2\Database\Format;
|
||||||
use OCC\OaiPmh2\Document;
|
use OCC\OaiPmh2\Document;
|
||||||
use OCC\OaiPmh2\Middleware;
|
use OCC\OaiPmh2\Middleware;
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
@ -46,7 +47,9 @@ class GetRecord extends Middleware
|
||||||
protected function prepareResponse(ServerRequestInterface $request): void
|
protected function prepareResponse(ServerRequestInterface $request): void
|
||||||
{
|
{
|
||||||
$params = $request->getAttributes();
|
$params = $request->getAttributes();
|
||||||
$oaiRecord = Database::getInstance()->getRecord($params['identifier'], $params['metadataPrefix']);
|
/** @var Format */
|
||||||
|
$format = Database::getInstance()->getEntityManager()->getReference(Format::class, $params['metadataPrefix']);
|
||||||
|
$oaiRecord = Database::getInstance()->getRecord($params['identifier'], $format);
|
||||||
|
|
||||||
if (!isset($oaiRecord)) {
|
if (!isset($oaiRecord)) {
|
||||||
if (Database::getInstance()->idDoesExist($params['identifier'])) {
|
if (Database::getInstance()->idDoesExist($params['identifier'])) {
|
||||||
|
|
Loading…
Reference in New Issue