Skip to content

Commit

Permalink
Port BookLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
lazka committed Nov 9, 2023
1 parent 99b5458 commit 1332ba7
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 85 deletions.
27 changes: 27 additions & 0 deletions src/ApiPlatform/BookLocation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace Dbp\Relay\SublibraryBundle\ApiPlatform;

use Symfony\Component\Serializer\Annotation\Groups;

class BookLocation
{
/**
* @Groups({"BookLocation:output"})
*
* @var string
*/
private $identifier;

public function getIdentifier(): string
{
return $this->identifier;
}

public function setIdentifier(string $identifier): void
{
$this->identifier = $identifier;
}
}
9 changes: 7 additions & 2 deletions src/ApiPlatform/DummyProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@

namespace Dbp\Relay\SublibraryBundle\ApiPlatform;

use ApiPlatform\Metadata\CollectionOperationInterface;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProviderInterface;

class DummyProvider implements ProviderInterface
{
/**
* @return null
* @return array|null
*/
public function provide(Operation $operation, array $uriVariables = [], array $context = [])
{
return null;
if (!$operation instanceof CollectionOperationInterface) {
return null;
}

return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

declare(strict_types=1);

namespace Dbp\Relay\SublibraryBundle\Controller;
namespace Dbp\Relay\SublibraryBundle\ApiPlatform;

use Dbp\Relay\SublibraryBundle\Controller\AlmaController;
use Dbp\Relay\SublibraryBundle\Helpers\ItemNotLoadedException;
use League\Uri\Contracts\UriException;

Expand Down
80 changes: 0 additions & 80 deletions src/Entity/BookLocation.php

This file was deleted.

48 changes: 47 additions & 1 deletion src/Resources/config/api_resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ resources:
priceCurrency:
iri: "http://schema.org/priceCurrency"


Dbp\Relay\SublibraryBundle\ApiPlatform\BookOrder:
security: "is_granted('IS_AUTHENTICATED_FULLY') and is_granted('ROLE_LIBRARY_MANAGER')"
types: ['http://schema.org/Order']
Expand Down Expand Up @@ -302,3 +301,50 @@ resources:
iri: "http://schema.org/Text"
orderDate:
iri: "http://schema.org/DateTime"

Dbp\Relay\SublibraryBundle\ApiPlatform\BookLocation:
security: "is_granted('IS_AUTHENTICATED_FULLY') and is_granted('ROLE_LIBRARY_MANAGER')"
types: ['https://schema.org/location']
description: "The location, where a book is shelved."
shortName: "BookLocation"
routePrefix: "/sublibrary"
normalizationContext:
groups: ["BookLocation:output"]
jsonld_embed_context: true

operations:

ApiPlatform\Metadata\GetCollection:
security: "is_granted('IS_AUTHENTICATED_FULLY') and is_granted('ROLE_LIBRARY_MANAGER')"
provider: Dbp\Relay\SublibraryBundle\ApiPlatform\DummyProvider
uriTemplate: "/book-locations"
openapiContext:
tags: ["Sublibrary"]

ApiPlatform\Metadata\Get:
security: "is_granted('IS_AUTHENTICATED_FULLY') and is_granted('ROLE_LIBRARY_MANAGER')"
provider: Dbp\Relay\SublibraryBundle\ApiPlatform\DummyProvider
uriTemplate: "/book-locations/{identifier}"
openapiContext:
tags: ["Sublibrary"]

get_location_identifiers:
class: ApiPlatform\Metadata\GetCollection
method: GET
controller: Dbp\Relay\SublibraryBundle\ApiPlatform\GetLocationIdentifiersByBookOffer
uriTemplate: "/book-offers/{identifier}/location-identifiers"
read: false
openapiContext:
tags: ["Sublibrary"]
summary: "Retrieves all location identifiers with in the same holding and with the same location as the book offer."
parameters:
- name: identifier
in: path
description: 'Id of book offer'
type: string
required: true

properties:
identifier:
identifier: true
iri: "http://schema.org/identifier"
2 changes: 1 addition & 1 deletion src/Service/AlmaApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
use Dbp\Relay\CoreBundle\Rest\Options;
use Dbp\Relay\SublibraryBundle\API\SublibraryProviderInterface;
use Dbp\Relay\SublibraryBundle\ApiPlatform\Book;
use Dbp\Relay\SublibraryBundle\ApiPlatform\BookLocation;
use Dbp\Relay\SublibraryBundle\ApiPlatform\BookOrder;
use Dbp\Relay\SublibraryBundle\ApiPlatform\BookOrderItem;
use Dbp\Relay\SublibraryBundle\ApiPlatform\BudgetMonetaryAmount;
use Dbp\Relay\SublibraryBundle\ApiPlatform\DeliveryEvent;
use Dbp\Relay\SublibraryBundle\ApiPlatform\EventStatusType;
use Dbp\Relay\SublibraryBundle\ApiPlatform\ParcelDelivery;
use Dbp\Relay\SublibraryBundle\Entity\BookLoan;
use Dbp\Relay\SublibraryBundle\Entity\BookLocation;
use Dbp\Relay\SublibraryBundle\Entity\BookOffer;
use Dbp\Relay\SublibraryBundle\Entity\Sublibrary;
use Dbp\Relay\SublibraryBundle\Helpers\ItemNotFoundException;
Expand Down

0 comments on commit 1332ba7

Please sign in to comment.