Oihana PHP Arango

PropertyControllerPatchTrait uses trait:short

Table of Contents

Methods

patch()  : mixed
Update a part of a document in a collection with a specific identifier (by default use the _key attribute).
update()  : mixed
Provides the functionality to update or replace documents in an ArangoDB collection using PATCH or PUT HTTP methods. This trait handles: - Document existence verification.
reloadProperty()  : mixed
Re-reads the updated property so the response carries the stored value rather than the submitted one (`Arango::RAW` skips this round-trip).

Methods

patch()

Update a part of a document in a collection with a specific identifier (by default use the _key attribute).

public patch([ServerRequestInterface|null $request = null ][, ResponseInterface|null $response = null ][, array<string|int, mixed> $args = [] ][, array<string|int, mixed> $init = [] ]) : mixed

Example: PATCH ../collection/{id}

Parameters
$request : ServerRequestInterface|null = null
$response : ResponseInterface|null = null
$args : array<string|int, mixed> = []

An associative array that contains values for the current route’s named placeholders.

$init : array<string|int, mixed> = []

An optional associative array to initialize the method.

Tags
throws
ContainerExceptionInterface
NotFoundExceptionInterface

update()

Provides the functionality to update or replace documents in an ArangoDB collection using PATCH or PUT HTTP methods. This trait handles: - Document existence verification.

public update([ServerRequestInterface|null $request = null ][, ResponseInterface|null $response = null ][, array<string|int, mixed> $args = [] ][, array<string|int, mixed> $init = [] ]) : mixed
  • Preparation and filtering of document data.
  • Validation against defined rules.
  • Conditional update (PATCH) or replacement (PUT) of documents.
  • Hooks for pre- and post-update actions (beforeUpdate and afterUpdate).

Usage:

  • PATCH ../collection/{id} -> Partial update
  • PUT ../collection/{id} -> Full replacement
Parameters
$request : ServerRequestInterface|null = null

Optional PSR-7 ServerRequest instance.

$response : ResponseInterface|null = null

Optional PSR-7 Response instance.

$args : array<string|int, mixed> = []

Route parameters (e.g., ['id' => '_key']).

$init : array<string|int, mixed> = []

Initialization options and additional context.

Return values
mixed

The updated document data on success, or a standardized error response on failure.

reloadProperty()

Re-reads the updated property so the response carries the stored value rather than the submitted one (`Arango::RAW` skips this round-trip).

private reloadProperty(ServerRequestInterface|null $request, array<string|int, mixed> $args, array<string|int, mixed> $init, object|null $document) : mixed

It is a read, so it goes through the same hooks and carries the same Arango::CONDITIONS as PropertyControllerGetTrait::get() : a write whose response bypassed the scope would hand back exactly what the scope is meant to withhold.

Parameters
$request : ServerRequestInterface|null

The current PSR-7 request.

$args : array<string|int, mixed>

The route placeholders.

$init : array<string|int, mixed>

The method init array (source of the declared conditions).

$document : object|null

The document returned by the write.

Tags
throws
ContainerExceptionInterface
NotFoundExceptionInterface
Return values
mixed

The stored property value, or null when the re-read returns nothing.

On this page

Search results