diff --git a/404.html b/404.html index 6908aebb..8f957465 100644 --- a/404.html +++ b/404.html @@ -4,8 +4,8 @@ Rekalogika.DEV - - + +
Skip to main content

Page Not Found

We could not find what you were looking for.

Please contact the owner of the site that linked you to the original URL and let them know their link is broken.

diff --git a/api-lite.html b/api-lite.html index 7a6e3708..878fa17d 100644 --- a/api-lite.html +++ b/api-lite.html @@ -4,8 +4,8 @@ rekalogika/api-lite | Rekalogika.DEV - - + +
Skip to main content

rekalogika/api-lite

A set of tools to simplify working with API diff --git a/api-lite/abstractstate.html b/api-lite/abstractstate.html index 1a976fd3..9c1eeed9 100644 --- a/api-lite/abstractstate.html +++ b/api-lite/abstractstate.html @@ -4,8 +4,8 @@ AbstractState | Rekalogika.DEV - - + +

AbstractState

Base class for our providers and processors.

diff --git a/api-lite/basic-endpoints.html b/api-lite/basic-endpoints.html index 106bef68..958f2900 100644 --- a/api-lite/basic-endpoints.html +++ b/api-lite/basic-endpoints.html @@ -4,8 +4,8 @@ Use Cases: Basic Endpoints | Rekalogika.DEV - - + + diff --git a/api-lite/basic-endpoints/delete.html b/api-lite/basic-endpoints/delete.html index 9aedcff7..002ed8f0 100644 --- a/api-lite/basic-endpoints/delete.html +++ b/api-lite/basic-endpoints/delete.html @@ -4,8 +4,8 @@ DELETE Endpoint | Rekalogika.DEV - - + +

DELETE Endpoint

src/ApiResource/Admin/BookDto.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Patch;
use App\ApiInput\BookInputDto;
use App\ApiState\Admin\Book\BookRemoveProcessor;

#[ApiResource(
shortName: 'Admin/Book',
routePrefix: '/admin',
operations: [
// ...
new Delete(
uriTemplate: '/books/{id}',
processor: BookRemoveProcessor::class
),
// ...
]
)]
class BookDto
{
// ...
}
diff --git a/api-lite/basic-endpoints/get-collection.html b/api-lite/basic-endpoints/get-collection.html index fb244905..551fe04e 100644 --- a/api-lite/basic-endpoints/get-collection.html +++ b/api-lite/basic-endpoints/get-collection.html @@ -4,8 +4,8 @@ GET Collection Endpoint | Rekalogika.DEV - - + +

GET Collection Endpoint

src/ApiResource/Admin/BookDto.php
namespace App\ApiResource\Admin;

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GetCollection;
use App\ApiState\Admin\Book\BookCollectionProvider;

#[ApiResource(
shortName: 'Admin/Book',
routePrefix: '/admin',
// // Uncomment the following to enable keyset-pagination:
// extraProperties: [
// 'api_lite_rekapager' => true
// ]
operations: [
// ...
new GetCollection(
uriTemplate: '/books',
provider: BookCollectionProvider::class,
),
// ...
]
)]
class BookDto
{
// ...
}

diff --git a/api-lite/basic-endpoints/get.html b/api-lite/basic-endpoints/get.html index c6e7b717..0bbba399 100644 --- a/api-lite/basic-endpoints/get.html +++ b/api-lite/basic-endpoints/get.html @@ -4,8 +4,8 @@ GET Endpoint | Rekalogika.DEV - - + +

GET Endpoint

src/ApiResource/Admin/BookDto.php
namespace App\ApiResource\Admin;

use App\ApiState\Admin\Book\BookProvider;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;

#[ApiResource(
shortName: 'Admin/Book',
routePrefix: '/admin',
operations: [
// ...
new Get(
uriTemplate: '/books/{id}',
provider: BookProvider::class,
),
// ...
]
)]
class BookDto
{
// ...
}
diff --git a/api-lite/basic-endpoints/objects.html b/api-lite/basic-endpoints/objects.html index d03c2730..e38ec247 100644 --- a/api-lite/basic-endpoints/objects.html +++ b/api-lite/basic-endpoints/objects.html @@ -4,8 +4,8 @@ Objects Used in the Examples | Rekalogika.DEV - - + +

Objects Used in the Examples

src/Entity/Book.php
namespace App\Entity;

use App\Repository\BookRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Uid\Uuid;

#[ORM\Entity(repositoryClass: BookRepository::class)]
class Book extends \stdClass
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true, nullable: false)]
private Uuid $id;

#[ORM\Column]
private ?string $title = null;

#[ORM\Column(type: Types::TEXT)]
private ?string $description = null;

#[ORM\Column(type: Types::DATETIME_IMMUTABLE, nullable: true)]
private ?\DateTimeInterface $lastChecked = null;

/**
* @var Collection<array-key,Review>
*/
#[ORM\OneToMany(
targetEntity: Review::class,
mappedBy: 'book',
cascade: ['persist', 'remove'],
orphanRemoval: true,
fetch: 'EXTRA_LAZY',
indexBy: 'id',
)]
private Collection $reviews;

public function __construct()
{
$this->id = Uuid::v7();
$this->reviews = new ArrayCollection();
}

/**
* We want to check our books' conditions every now and then.
*/
public function check(): void
{
$this->lastChecked = new \DateTimeImmutable();
}

public function getId(): Uuid
{
return $this->id;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(?string $title): self
{
$this->title = $title;

return $this;
}

public function getDescription(): ?string
{
return $this->description;
}

public function setDescription(?string $description): self
{
$this->description = $description;

return $this;
}

/**
* @return Collection<array-key,Review>
*/
public function getReviews(): Collection
{
return $this->reviews;
}

public function addReview(Review $review): self
{
if (!$this->reviews->contains($review)) {
$this->reviews[] = $review;
$review->setBook($this);
}

return $this;
}

public function removeReview(Review $review): self
{
if ($this->reviews->removeElement($review)) {
// set the owning side to null (unless already changed)
if ($review->getBook() === $this) {
$review->setBook(null);
}
}

return $this;
}

public function getLastChecked(): ?\DateTimeInterface
{
return $this->lastChecked;
}
}
diff --git a/api-lite/basic-endpoints/patch-put-update.html b/api-lite/basic-endpoints/patch-put-update.html index bed52358..494be1d1 100644 --- a/api-lite/basic-endpoints/patch-put-update.html +++ b/api-lite/basic-endpoints/patch-put-update.html @@ -4,8 +4,8 @@ PATCH and PUT Endpoint for Entity Update | Rekalogika.DEV - - + +

PATCH and PUT Endpoint for Entity Update

src/ApiResource/Admin/BookDto.php
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Patch;
use App\ApiInput\BookInputDto;
use App\ApiState\Admin\Book\BookProvider;
use App\ApiState\Admin\Book\BookUpdateProcessor;

#[ApiResource(
shortName: 'Admin/Book',
routePrefix: '/admin',
operations: [
// ...
new Patch(
uriTemplate: '/books/{id}',
input: BookInputDto::class,
processor: BookUpdateProcessor::class,
read: false,
),
new Put(
uriTemplate: '/books/{id}',
input: BookInputDto::class,
processor: BookUpdateProcessor::class,
read: false,
),
// ...
]
)]
class BookDto
{
// ...
}