From c19ebe665456325f4ddc6ad96dab5880cc6aa4fb Mon Sep 17 00:00:00 2001 From: Chris Lloyd Date: Mon, 29 Mar 2021 22:32:38 +0100 Subject: [PATCH] WIP --- README.md | 1 + ...ties-V1-AsynchronousRequestsSupported.html | 2 +- ...ion-Capabilities-V1-CallbackSupported.html | 2 +- ...tion-Capabilities-V1-ConformanceLevel.html | 2 +- ...ion-Capabilities-V1-DeepInsertSupport.html | 2 +- ...tion-Capabilities-V1-SupportedFormats.html | 2 +- ...ta-Annotation-Core-V1-ConventionalIDs.html | 2 +- ...a-Annotation-Core-V1-DefaultNamespace.html | 2 +- ...-Annotation-Core-V1-DereferencableIDs.html | 2 +- ...data-Annotation-Core-V1-ODataVersions.html | 2 +- docs/classes/Flat3-Lodata-Annotation.html | 4 +- .../Flat3-Lodata-Controller-Transaction.html | 190 +++--- .../Flat3-Lodata-PathSegment-Entity.html | 254 ++++++++ .../Flat3-Lodata-PathSegment-Type.html | 254 ++++++++ .../Flat3-Lodata-Transaction-Option-Id.html | 570 ++++++++++++++++++ docs/files/src-pathsegment-entity.html | 138 +++++ docs/files/src-pathsegment-type.html | 138 +++++ docs/files/src-transaction-option-id.html | 138 +++++ docs/indices/files.html | 3 + docs/js/searchIndex.js | 35 ++ docs/namespaces/flat3-lodata-pathsegment.html | 4 + .../flat3-lodata-transaction-option.html | 2 + docs/packages/Flat3-Lodata-PathSegment.html | 4 + .../Flat3-Lodata-Transaction-Option.html | 2 + src/Controller/Transaction.php | 23 +- src/PathSegment/Entity.php | 46 ++ src/PathSegment/Type.php | 40 ++ src/Transaction/Option/Id.php | 15 + tests/Unit/Queries/Entity/EntityTest.php | 56 ++ ...t__test_resolve_absolute_entity_id__1.json | 7 + ...EntityTest__test_resolve_entity_id__1.json | 7 + ...test_resolve_entity_id_with_expand__1.json | 24 + ...olve_entity_id_with_incorrect_type__1.json | 4 + ...test_resolve_entity_id_with_select__1.json | 4 + ...__test_resolve_entity_id_with_type__1.json | 7 + 35 files changed, 1902 insertions(+), 86 deletions(-) create mode 100644 docs/classes/Flat3-Lodata-PathSegment-Entity.html create mode 100644 docs/classes/Flat3-Lodata-PathSegment-Type.html create mode 100644 docs/classes/Flat3-Lodata-Transaction-Option-Id.html create mode 100644 docs/files/src-pathsegment-entity.html create mode 100644 docs/files/src-pathsegment-type.html create mode 100644 docs/files/src-transaction-option-id.html create mode 100644 src/PathSegment/Entity.php create mode 100644 src/PathSegment/Type.php create mode 100644 src/Transaction/Option/Id.php create mode 100644 tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_absolute_entity_id__1.json create mode 100644 tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id__1.json create mode 100644 tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_expand__1.json create mode 100644 tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_incorrect_type__1.json create mode 100644 tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_select__1.json create mode 100644 tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_type__1.json diff --git a/README.md b/README.md index e1c906152..2b6f42ddd 100644 --- a/README.md +++ b/README.md @@ -517,6 +517,7 @@ Lodata supports many sections of the OData specification, these are the major ar * [Batch requests](https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_BatchRequests) in both multipart and JSON formats, including entity back-references and asynchronous batch requests * [Deep insert](https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_CreateRelatedEntitiesWhenCreatinganE) support at any depth * [Deep update](https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_UpdateRelatedEntitiesWhenUpdatinganE) support at any depth +* [Resolving](https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_ResolvinganEntityId) entity IDs into representations * Edit links, and POST/PATCH/DELETE requests for new or existing entities * Composable URLs * Declared and navigation properties diff --git a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-AsynchronousRequestsSupported.html b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-AsynchronousRequestsSupported.html index cac7d253b..c3d27482e 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-AsynchronousRequestsSupported.html +++ b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-AsynchronousRequestsSupported.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-CallbackSupported.html b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-CallbackSupported.html index d75a4a0a5..62912d37d 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-CallbackSupported.html +++ b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-CallbackSupported.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-ConformanceLevel.html b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-ConformanceLevel.html index a4078f4fa..3d2fbdf9b 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-ConformanceLevel.html +++ b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-ConformanceLevel.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-DeepInsertSupport.html b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-DeepInsertSupport.html index 047958cb8..95ea61391 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-DeepInsertSupport.html +++ b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-DeepInsertSupport.html @@ -250,7 +250,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-SupportedFormats.html b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-SupportedFormats.html index f6330ef32..040f707df 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-SupportedFormats.html +++ b/docs/classes/Flat3-Lodata-Annotation-Capabilities-V1-SupportedFormats.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Core-V1-ConventionalIDs.html b/docs/classes/Flat3-Lodata-Annotation-Core-V1-ConventionalIDs.html index 04c0ca122..66f072d4a 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Core-V1-ConventionalIDs.html +++ b/docs/classes/Flat3-Lodata-Annotation-Core-V1-ConventionalIDs.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Core-V1-DefaultNamespace.html b/docs/classes/Flat3-Lodata-Annotation-Core-V1-DefaultNamespace.html index f99c4cbae..25251ab62 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Core-V1-DefaultNamespace.html +++ b/docs/classes/Flat3-Lodata-Annotation-Core-V1-DefaultNamespace.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Core-V1-DereferencableIDs.html b/docs/classes/Flat3-Lodata-Annotation-Core-V1-DereferencableIDs.html index 957490a31..96371a4f4 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Core-V1-DereferencableIDs.html +++ b/docs/classes/Flat3-Lodata-Annotation-Core-V1-DereferencableIDs.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation-Core-V1-ODataVersions.html b/docs/classes/Flat3-Lodata-Annotation-Core-V1-ODataVersions.html index 6c52ebd44..bc9329de7 100644 --- a/docs/classes/Flat3-Lodata-Annotation-Core-V1-ODataVersions.html +++ b/docs/classes/Flat3-Lodata-Annotation-Core-V1-ODataVersions.html @@ -236,7 +236,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Annotation.html b/docs/classes/Flat3-Lodata-Annotation.html index a2a38d742..30a9e1e4e 100644 --- a/docs/classes/Flat3-Lodata-Annotation.html +++ b/docs/classes/Flat3-Lodata-Annotation.html @@ -95,7 +95,7 @@

Annotation

@@ -161,7 +161,7 @@

Append the annotation to the provided schema element

diff --git a/docs/classes/Flat3-Lodata-Controller-Transaction.html b/docs/classes/Flat3-Lodata-Controller-Transaction.html index 6da5d6f63..cb4fdbf78 100644 --- a/docs/classes/Flat3-Lodata-Controller-Transaction.html +++ b/docs/classes/Flat3-Lodata-Controller-Transaction.html @@ -99,7 +99,7 @@

Transaction

@@ -257,6 +257,13 @@

Get the transaction ID
+
+ getIdOption() + +  : Id +
+
Get the $id system query option
+
getImplicitParameterAlias() @@ -664,7 +671,7 @@

List of path segment handlers

@@ -673,7 +680,7 @@

protected array<string|int, PipeInterface> $handlers - = [Flat3LodataEntitySet::class, Flat3LodataPathSegmentBatch::class, Flat3LodataPathSegmentMetadata::class, Flat3LodataPathSegmentValue::class, Flat3LodataPathSegmentCount::class, Flat3LodataPathSegmentFilter::class, Flat3LodataPathSegmentReference::class, Flat3LodataOperation::class, Flat3LodataSingleton::class, Flat3LodataHelperPropertyValue::class] + = [Flat3LodataEntitySet::class, Flat3LodataPathSegmentBatch::class, Flat3LodataPathSegmentMetadata::class, Flat3LodataPathSegmentEntity::class, Flat3LodataPathSegmentType::class, Flat3LodataPathSegmentValue::class, Flat3LodataPathSegmentCount::class, Flat3LodataPathSegmentFilter::class, Flat3LodataPathSegmentReference::class, Flat3LodataOperation::class, Flat3LodataSingleton::class, Flat3LodataHelperPropertyValue::class]
@@ -713,7 +720,7 @@

@@ -745,7 +752,7 @@

Attach an entity set to this transaction

@@ -790,7 +797,7 @@

Commit all entity sets attached to this transaction

@@ -824,7 +831,7 @@

Ensure that the request content type is JSON

@@ -873,7 +880,7 @@

Ensure the request method is one of the provided list or throw an exception

@@ -952,7 +959,7 @@

Execute the transaction

@@ -1000,7 +1007,7 @@

Get the content type requested by the client

@@ -1034,7 +1041,7 @@

Get the request body, decoded if JSON is being provided

@@ -1069,7 +1076,7 @@

Get the callback preference URL

@@ -1104,7 +1111,7 @@

Get the requested charset

@@ -1138,7 +1145,7 @@

Get the service document context URL @@ -1174,7 +1181,7 @@

Get request properties to expose in the context URL

@@ -1209,7 +1216,7 @@

Get the $count system query option

@@ -1244,7 +1251,7 @@

Get the $expand system query option

@@ -1279,7 +1286,7 @@

Get the $filter system query option

@@ -1314,7 +1321,7 @@

Get the requested content format

@@ -1349,7 +1356,7 @@

Get the transaction ID

@@ -1370,6 +1377,41 @@

Return values
+ +
+

+ getIdOption() + +

+ + +

Get the $id system query option

+ + + public + getIdOption() : Id + +
+ + + + +
Return values
+ Id + — +

Id

+
+ +

Get implicit parameter aliases

@@ -1431,7 +1473,7 @@

Get the negotiated metadata type

@@ -1466,7 +1508,7 @@

Get the request method

@@ -1501,7 +1543,7 @@

Get the navigation requests embedded in this transaction

@@ -1536,7 +1578,7 @@

Get the $orderby system query option

@@ -1571,7 +1613,7 @@

Get a URL parameter alias

@@ -1631,7 +1673,7 @@

Get the request path with normalization decoding

@@ -1679,7 +1721,7 @@

Get the list of URL-decoded path segments in the request

@@ -1714,7 +1756,7 @@

Get a requested preference as a Parameter object

@@ -1760,7 +1802,7 @@

Get the string value of a requested preference

@@ -1805,7 +1847,7 @@

Get the content type provided by the client

@@ -1839,7 +1881,7 @@

Get a single query parameter

@@ -1886,7 +1928,7 @@

Get all query parameters

@@ -1921,7 +1963,7 @@

Get the request object

@@ -1956,7 +1998,7 @@

Get the first request header of the provided key

@@ -2003,7 +2045,7 @@

Get all request headers of the provided key

@@ -2050,7 +2092,7 @@

Get the request path without any REST prefix

@@ -2085,7 +2127,7 @@

Get the service document resource URL @@ -2121,7 +2163,7 @@

Get request properties to expose in the resource URL

@@ -2156,7 +2198,7 @@

Get the response object

@@ -2191,7 +2233,7 @@

Get the first response header of the provided key

@@ -2238,7 +2280,7 @@

Get the $search system query option

@@ -2273,7 +2315,7 @@

Get the $select system query option

@@ -2308,7 +2350,7 @@

Get the $skip system query option

@@ -2343,7 +2385,7 @@

Get a system query option

@@ -2390,7 +2432,7 @@

Get the $top system query option

@@ -2425,7 +2467,7 @@

Get the negotiated version as a string

@@ -2460,7 +2502,7 @@

Return whether the provided preference was requested

@@ -2506,7 +2548,7 @@

Initialize this transaction using the provided request object

@@ -2552,7 +2594,7 @@

Output the end of a JSON array

@@ -2586,7 +2628,7 @@

Output the start of a JSON array

@@ -2620,7 +2662,7 @@

Output a JSON object key

@@ -2666,7 +2708,7 @@

Output the provided associative array as a set of JSON key/values

@@ -2712,7 +2754,7 @@

Output the end of a JSON object

@@ -2746,7 +2788,7 @@

Output the start of a JSON object

@@ -2780,7 +2822,7 @@

Output a JSON property separator

@@ -2814,7 +2856,7 @@

Encode and output a JSON value

@@ -2860,7 +2902,7 @@

Output a raw text value

@@ -2906,7 +2948,7 @@

Mark as requested preference as having been applied to the response object

@@ -2961,7 +3003,7 @@

Process the request represented by this transaction

@@ -3019,7 +3061,7 @@

Process deltas in the request body

@@ -3085,7 +3127,7 @@

Replace the query parameters in this transaction with the ones from the provided transaction

@@ -3131,7 +3173,7 @@

Rollback all entity sets attached to this transaction

@@ -3165,7 +3207,7 @@

Send the negotiated content type response header

@@ -3211,7 +3253,7 @@

Send a response header

@@ -3266,7 +3308,7 @@

Output the provided string

@@ -3312,7 +3354,7 @@

Set the content encoding response header

@@ -3358,7 +3400,7 @@

Set the content language response header

@@ -3404,7 +3446,7 @@

Update this transaction based on the provided request object

@@ -3450,7 +3492,7 @@

Start transactions on attached entity sets

@@ -3484,7 +3526,7 @@

Process a deep creation

@@ -3529,7 +3571,7 @@

Process a deep modification

@@ -3582,7 +3624,7 @@

Process a deep delete

@@ -3643,7 +3685,7 @@

Get all system query options from the request, optionally returning them with the $ prefix

diff --git a/docs/classes/Flat3-Lodata-PathSegment-Entity.html b/docs/classes/Flat3-Lodata-PathSegment-Entity.html new file mode 100644 index 000000000..175f5c5e4 --- /dev/null +++ b/docs/classes/Flat3-Lodata-PathSegment-Entity.html @@ -0,0 +1,254 @@ + + + + + Lodata + + + + + + + + + + + + + + + + + + +
+

Lodata

+ + + + + +
+ +
+
+ + + + +
+ + +
+

+ Entity + + + + + implements + PipeInterface + +

+ + + +

Entity

+ +
+ + + + + + +

+ Interfaces, Classes and Traits + +

+ +
+
PipeInterface
+
Pipe Interface
+ + +
+ + +

+ Table of Contents + +

+ +
+
+ pipe() + +  : PipeInterface|null +
+
Path component handler
+ +
+ + + + + + + +
+

+ Methods + +

+
+

+ pipe() + +

+ + +

Path component handler

+ + + public + static pipe(Transaction $transaction, string $currentSegment, string|null $nextSegment, PipeInterface|null $argument) : PipeInterface|null + +
+ +
Parameters
+
+
+ $transaction + : Transaction +
+
+

Related transaction

+
+ +
+
+ $currentSegment + : string +
+
+

The current path segment

+
+ +
+
+ $nextSegment + : string|null +
+
+

The next path segment

+
+ +
+
+ $argument + : PipeInterface|null +
+
+

The previous path segment

+
+ +
+
+ + + +
Return values
+ PipeInterface|null + — +

The processed path segment if handled by this implementation

+
+ + +
+
+ +
+
+
+
+

Search results

+ +
+
+
    +
    +
    +
    +
    +
    + + +
    + + + + + + + diff --git a/docs/classes/Flat3-Lodata-PathSegment-Type.html b/docs/classes/Flat3-Lodata-PathSegment-Type.html new file mode 100644 index 000000000..fb4b3b94c --- /dev/null +++ b/docs/classes/Flat3-Lodata-PathSegment-Type.html @@ -0,0 +1,254 @@ + + + + + Lodata + + + + + + + + + + + + + + + + + + +
    +

    Lodata

    + + + + + +
    + +
    +
    + + + + +
    + + +
    +

    + Type + + + + + implements + PipeInterface + +

    + + + +

    Type

    + +
    + + + + + + +

    + Interfaces, Classes and Traits + +

    + +
    +
    PipeInterface
    +
    Pipe Interface
    + + +
    + + +

    + Table of Contents + +

    + +
    +
    + pipe() + +  : PipeInterface|null +
    +
    Path component handler
    + +
    + + + + + + + +
    +

    + Methods + +

    +
    +

    + pipe() + +

    + + +

    Path component handler

    + + + public + static pipe(Transaction $transaction, string $currentSegment, string|null $nextSegment, PipeInterface|null $argument) : PipeInterface|null + +
    + +
    Parameters
    +
    +
    + $transaction + : Transaction +
    +
    +

    Related transaction

    +
    + +
    +
    + $currentSegment + : string +
    +
    +

    The current path segment

    +
    + +
    +
    + $nextSegment + : string|null +
    +
    +

    The next path segment

    +
    + +
    +
    + $argument + : PipeInterface|null +
    +
    +

    The previous path segment

    +
    + +
    +
    + + + +
    Return values
    + PipeInterface|null + — +

    The processed path segment if handled by this implementation

    +
    + + +
    +
    + +
    +
    +
    +
    +

    Search results

    + +
    +
    +
      +
      +
      +
      +
      +
      + + +
      + + + + + + + diff --git a/docs/classes/Flat3-Lodata-Transaction-Option-Id.html b/docs/classes/Flat3-Lodata-Transaction-Option-Id.html new file mode 100644 index 000000000..e85bd8e6a --- /dev/null +++ b/docs/classes/Flat3-Lodata-Transaction-Option-Id.html @@ -0,0 +1,570 @@ + + + + + Lodata + + + + + + + + + + + + + + + + + + +
      +

      Lodata

      + + + + + +
      + +
      +
      + + + + +
      + + +
      +

      + Id + + + extends Option + + + + +

      + + + +

      Id

      + +
      + + +
      + Tags + +
      +
      +
      + link +
      +
      + https://docs.oasis-open.org/odata/odata/v4.01/os/part1-protocol/odata-v4.01-os-part1-protocol.html#sec_ResolvinganEntityId + +
      +
      + + + + + + +

      + Table of Contents + +

      + +
      +
      + param + +  = 'id' +
      +
      + +
      + type + +  = 'string' +
      +
      + +
      + clearValue() + +  : void +
      +
      Clear the value of this option
      + +
      + factory() + +  : static +
      +
      Generate a new instance of this option type from the supplied transaction
      + +
      + getCommaSeparatedValues() + +  : array<string|int, mixed> +
      +
      Get comma separated array values
      + +
      + getValue() + +  : mixed +
      +
      Get the option value
      + +
      + hasValue() + +  : bool +
      +
      Return whether this option is defined
      + +
      + setValue() + +  : void +
      +
      Set the option value
      + +
      + transaction() + +  : $this +
      +
      Generate this option from the provided transaction
      + +
      + + + + +
      +

      + Constants + +

      +
      +

      + param + +

      + + + + + + public + mixed + param + = 'id' + + + + + + +
      +
      +

      + type + +

      + + + + + + public + mixed + type + = 'string' + + + + + + +
      +
      + + + +
      +

      + Methods + +

      +
      +

      + clearValue() + +

      + + +

      Clear the value of this option

      + + + public + clearValue() : void + +
      + + + + +
      Return values
      + void + — +
      + + +
      +
      +

      + factory() + +

      + + +

      Generate a new instance of this option type from the supplied transaction

      + + + public + static factory(Transaction $transaction) : static + +
      + +
      Parameters
      +
      +
      + $transaction + : Transaction +
      +
      +

      Transaction

      +
      + +
      +
      + + + +
      Return values
      + static + — +

      Option

      +
      + + +
      +
      +

      + getCommaSeparatedValues() + +

      + + +

      Get comma separated array values

      + + + public + getCommaSeparatedValues() : array<string|int, mixed> + +
      + + + + +
      Return values
      + array<string|int, mixed> + — +
      + + +
      +
      +

      + getValue() + +

      + + +

      Get the option value

      + + + public + getValue() : mixed + +
      + + + + +
      Return values
      + mixed + — +
      + + +
      +
      +

      + hasValue() + +

      + + +

      Return whether this option is defined

      + + + public + hasValue() : bool + +
      + + + + +
      Return values
      + bool + — +
      + + +
      +
      +

      + setValue() + +

      + + +

      Set the option value

      + + + public + setValue(string|null $value) : void + +
      + +
      Parameters
      +
      +
      + $value + : string|null +
      +
      +
      + +
      +
      + + + +
      Return values
      + void + — +
      + + +
      +
      +

      + transaction() + +

      + + +

      Generate this option from the provided transaction

      + + + public + transaction(Transaction $transaction) : $this + +
      + +
      Parameters
      +
      +
      + $transaction + : Transaction +
      +
      +

      Transaction

      +
      + +
      +
      + + + +
      Return values
      + $this + — +

      Option

      +
      + + +
      +
      + +
      +
      +
      +
      +

      Search results

      + +
      +
      +
        +
        +
        +
        +
        +
        + + +
        + + + + + + + diff --git a/docs/files/src-pathsegment-entity.html b/docs/files/src-pathsegment-entity.html new file mode 100644 index 000000000..c956677ac --- /dev/null +++ b/docs/files/src-pathsegment-entity.html @@ -0,0 +1,138 @@ + + + + + Lodata + + + + + + + + + + + + + + + + + + +
        +

        Lodata

        + + + + + +
        + +
        +
        + + + + +
        +
          +
        + +
        +

        Entity.php

        + + + + + + + + +

        + Interfaces, Classes and Traits + +

        + +
        + +
        Entity
        +
        Entity
        + +
        + + + + + + + + +
        +
        +
        +
        +

        Search results

        + +
        +
        +
          +
          +
          +
          +
          +
          + + +
          + + + + + + + diff --git a/docs/files/src-pathsegment-type.html b/docs/files/src-pathsegment-type.html new file mode 100644 index 000000000..cab805bfe --- /dev/null +++ b/docs/files/src-pathsegment-type.html @@ -0,0 +1,138 @@ + + + + + Lodata + + + + + + + + + + + + + + + + + + +
          +

          Lodata

          + + + + + +
          + +
          +
          + + + + +
          +
            +
          + +
          +

          Type.php

          + + + + + + + + +

          + Interfaces, Classes and Traits + +

          + +
          + +
          Type
          +
          Type
          + +
          + + + + + + + + +
          +
          +
          +
          +

          Search results

          + +
          +
          +
            +
            +
            +
            +
            +
            + + +
            + + + + + + + diff --git a/docs/files/src-transaction-option-id.html b/docs/files/src-transaction-option-id.html new file mode 100644 index 000000000..05c9f8a5e --- /dev/null +++ b/docs/files/src-transaction-option-id.html @@ -0,0 +1,138 @@ + + + + + Lodata + + + + + + + + + + + + + + + + + + +
            +

            Lodata

            + + + + + +
            + +
            +
            + + + + +
            +
              +
            + +
            +

            Id.php

            + + + + + + + + +

            + Interfaces, Classes and Traits + +

            + +
            + +
            Id
            +
            Id
            + +
            + + + + + + + + +
            +
            +
            +
            +

            Search results

            + +
            +
            +
              +
              +
              +
              +
              +
              + + +
              + + + + + + + diff --git a/docs/indices/files.html b/docs/indices/files.html index 7bc04dbc3..77e46bc8a 100644 --- a/docs/indices/files.html +++ b/docs/indices/files.html @@ -157,6 +157,7 @@

              E

            • EndGroup.php
            • EndsWith.php
            • Entity.php
            • +
            • Entity.php
            • EntityArgument.php
            • EntitySet.php
            • EntitySetArgument.php
            • @@ -208,6 +209,7 @@

              H

              I

              diff --git a/docs/js/searchIndex.js b/docs/js/searchIndex.js index f0d031862..026b32fb0 100644 --- a/docs/js/searchIndex.js +++ b/docs/js/searchIndex.js @@ -625,6 +625,11 @@ Search.appendIndex( "name": "getTop", "summary": "Get\u0020the\u0020\u0024top\u0020system\u0020query\u0020option", "url": "classes/Flat3-Lodata-Controller-Transaction.html#method_getTop" + }, { + "fqsen": "\\Flat3\\Lodata\\Controller\\Transaction\u003A\u003AgetIdOption\u0028\u0029", + "name": "getIdOption", + "summary": "Get\u0020the\u0020\u0024id\u0020system\u0020query\u0020option", + "url": "classes/Flat3-Lodata-Controller-Transaction.html#method_getIdOption" }, { "fqsen": "\\Flat3\\Lodata\\Controller\\Transaction\u003A\u003ApreferenceApplied\u0028\u0029", "name": "preferenceApplied", @@ -4780,6 +4785,16 @@ Search.appendIndex( "name": "pipe", "summary": "Path\u0020component\u0020handler", "url": "classes/Flat3-Lodata-PathSegment-Count.html#method_pipe" + }, { + "fqsen": "\\Flat3\\Lodata\\PathSegment\\Entity", + "name": "Entity", + "summary": "Entity", + "url": "classes/Flat3-Lodata-PathSegment-Entity.html" + }, { + "fqsen": "\\Flat3\\Lodata\\PathSegment\\Entity\u003A\u003Apipe\u0028\u0029", + "name": "pipe", + "summary": "Path\u0020component\u0020handler", + "url": "classes/Flat3-Lodata-PathSegment-Entity.html#method_pipe" }, { "fqsen": "\\Flat3\\Lodata\\PathSegment\\Filter", "name": "Filter", @@ -4855,6 +4870,16 @@ Search.appendIndex( "name": "emit", "summary": "Emit\u0020the\u0020service\u0020document", "url": "classes/Flat3-Lodata-PathSegment-Service.html#method_emit" + }, { + "fqsen": "\\Flat3\\Lodata\\PathSegment\\Type", + "name": "Type", + "summary": "Type", + "url": "classes/Flat3-Lodata-PathSegment-Type.html" + }, { + "fqsen": "\\Flat3\\Lodata\\PathSegment\\Type\u003A\u003Apipe\u0028\u0029", + "name": "pipe", + "summary": "Path\u0020component\u0020handler", + "url": "classes/Flat3-Lodata-PathSegment-Type.html#method_pipe" }, { "fqsen": "\\Flat3\\Lodata\\PathSegment\\Value", "name": "Value", @@ -5815,6 +5840,16 @@ Search.appendIndex( "name": "param", "summary": "", "url": "classes/Flat3-Lodata-Transaction-Option-Format.html#constant_param" + }, { + "fqsen": "\\Flat3\\Lodata\\Transaction\\Option\\Id", + "name": "Id", + "summary": "Id", + "url": "classes/Flat3-Lodata-Transaction-Option-Id.html" + }, { + "fqsen": "\\Flat3\\Lodata\\Transaction\\Option\\Id\u003A\u003Aparam", + "name": "param", + "summary": "", + "url": "classes/Flat3-Lodata-Transaction-Option-Id.html#constant_param" }, { "fqsen": "\\Flat3\\Lodata\\Transaction\\Option\\Numeric", "name": "Numeric", diff --git a/docs/namespaces/flat3-lodata-pathsegment.html b/docs/namespaces/flat3-lodata-pathsegment.html index 1b9907cdc..d01af1c8c 100644 --- a/docs/namespaces/flat3-lodata-pathsegment.html +++ b/docs/namespaces/flat3-lodata-pathsegment.html @@ -99,6 +99,8 @@

              Batch
              Count
              Count
              +
              Entity
              +
              Entity
              Filter
              Filter
              Metadata
              @@ -107,6 +109,8 @@

              Reference
              Service
              Service
              +
              Type
              +
              Type
              Value
              Value
              diff --git a/docs/namespaces/flat3-lodata-transaction-option.html b/docs/namespaces/flat3-lodata-transaction-option.html index 553009a4d..715a6e5ac 100644 --- a/docs/namespaces/flat3-lodata-transaction-option.html +++ b/docs/namespaces/flat3-lodata-transaction-option.html @@ -106,6 +106,8 @@

              Filter
              Format
              Format
              +
              Id
              +
              Id
              Numeric
              Numeric
              OrderBy
              diff --git a/docs/packages/Flat3-Lodata-PathSegment.html b/docs/packages/Flat3-Lodata-PathSegment.html index 11dcd3252..a799226c6 100644 --- a/docs/packages/Flat3-Lodata-PathSegment.html +++ b/docs/packages/Flat3-Lodata-PathSegment.html @@ -99,6 +99,8 @@

              Batch
              Count
              Count
              +
              Entity
              +
              Entity
              Filter
              Filter
              Metadata
              @@ -107,6 +109,8 @@

              Reference
              Service
              Service
              +
              Type
              +
              Type
              Value
              Value
              diff --git a/docs/packages/Flat3-Lodata-Transaction-Option.html b/docs/packages/Flat3-Lodata-Transaction-Option.html index 34453dcaa..f44b2cdcf 100644 --- a/docs/packages/Flat3-Lodata-Transaction-Option.html +++ b/docs/packages/Flat3-Lodata-Transaction-Option.html @@ -106,6 +106,8 @@

              Filter
              Format
              Format
              +
              Id
              +
              Id
              Numeric
              Numeric
              OrderBy
              diff --git a/src/Controller/Transaction.php b/src/Controller/Transaction.php index 872b17d4f..cb8a362de 100644 --- a/src/Controller/Transaction.php +++ b/src/Controller/Transaction.php @@ -44,6 +44,7 @@ use Flat3\Lodata\Transaction\Option\Expand; use Flat3\Lodata\Transaction\Option\Filter; use Flat3\Lodata\Transaction\Option\Format; +use Flat3\Lodata\Transaction\Option\Id; use Flat3\Lodata\Transaction\Option\OrderBy; use Flat3\Lodata\Transaction\Option\SchemaVersion; use Flat3\Lodata\Transaction\Option\Search; @@ -177,6 +178,13 @@ class Transaction implements ArgumentInterface */ private $top; + /** + * Id system query option + * @var Id $idOption + * @internal + */ + private $idOption; + /** * Schema version system query option * @var SchemaVersion $schemaVersion @@ -207,6 +215,8 @@ class Transaction implements ArgumentInterface EntitySet::class, PathSegment\Batch::class, PathSegment\Metadata::class, + PathSegment\Entity::class, + PathSegment\Type::class, PathSegment\Value::class, PathSegment\Count::class, PathSegment\Filter::class, @@ -229,6 +239,7 @@ public function __construct() $this->select = new Select(); $this->skip = new Skip(); $this->top = new Top(); + $this->idOption = new Id(); } /** @@ -300,6 +311,7 @@ public function setRequest(RequestInterface $request): self $this->select = Select::factory($this); $this->skip = Skip::factory($this); $this->top = Top::factory($this); + $this->idOption = Id::factory($this); return $this; } @@ -466,6 +478,15 @@ public function getTop(): Top return $this->top; } + /** + * Get the $id system query option + * @return Id Id + */ + public function getIdOption(): Id + { + return $this->idOption; + } + /** * Mark as requested preference as having been applied to the response object * @param string $key Preference @@ -813,7 +834,7 @@ private function getSystemQueryOptions(bool $prefixed = true): array { $options = [ 'apply', 'count', 'compute', 'expand', 'format', 'filter', 'orderby', 'search', 'select', 'skip', 'top', - 'schemaversion' + 'schemaversion', 'id', ]; if ($prefixed) { diff --git a/src/PathSegment/Entity.php b/src/PathSegment/Entity.php new file mode 100644 index 000000000..40162df11 --- /dev/null +++ b/src/PathSegment/Entity.php @@ -0,0 +1,46 @@ +getIdOption(); + + if (!$id->hasValue()) { + throw new BadRequestException('missing_id', 'The entity id system query option must be provided'); + } + + $entityId = $id->getValue(); + if (Str::startsWith($entityId, ServiceProvider::endpoint())) { + $entityId = Str::substr($entityId, strlen(ServiceProvider::endpoint())); + } + + return EntitySet::pipe($transaction, $entityId); + } +} diff --git a/src/PathSegment/Type.php b/src/PathSegment/Type.php new file mode 100644 index 000000000..c087f86f1 --- /dev/null +++ b/src/PathSegment/Type.php @@ -0,0 +1,40 @@ +getType()->getIdentifier() !== $entityType->getIdentifier()) { + throw new NotFoundException('invalid_entity_type', 'The provided type did not match the entity type'); + } + + return $argument; + } +} diff --git a/src/Transaction/Option/Id.php b/src/Transaction/Option/Id.php new file mode 100644 index 000000000..1d6707103 --- /dev/null +++ b/src/Transaction/Option/Id.php @@ -0,0 +1,15 @@ +select('dynamic') ); } + + public function test_resolve_entity_id() + { + $this->assertJsonResponse( + Request::factory() + ->path('/$entity') + ->query('$id', 'flights(1)') + ); + } + + public function test_resolve_absolute_entity_id() + { + $this->assertJsonResponse( + Request::factory() + ->path('/$entity') + ->query('$id', 'http://localhost/odata/flights(1)') + ); + } + + public function test_resolve_entity_id_with_select() + { + $this->assertJsonResponse( + Request::factory() + ->path('/$entity') + ->query('$id', 'flights(1)') + ->query('$select', 'destination') + ); + } + + public function test_resolve_entity_id_with_expand() + { + $this->assertJsonResponse( + Request::factory() + ->path('/$entity') + ->query('$id', 'flights(1)') + ->query('$expand', 'passengers') + ); + } + + public function test_resolve_entity_id_with_type() + { + $this->assertJsonResponse( + Request::factory() + ->path('/$entity/com.example.odata.flight') + ->query('$id', 'flights(1)') + ); + } + + public function test_resolve_entity_id_with_incorrect_type() + { + $this->assertNotFound( + Request::factory() + ->path('/$entity/com.example.odata.passenger') + ->query('$id', 'flights(1)') + ); + } } diff --git a/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_absolute_entity_id__1.json b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_absolute_entity_id__1.json new file mode 100644 index 000000000..c75052592 --- /dev/null +++ b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_absolute_entity_id__1.json @@ -0,0 +1,7 @@ +{ + "@context": "http://localhost/odata/$metadata#flights/$entity", + "id": 1, + "origin": "lhr", + "destination": "lax", + "gate": null +} diff --git a/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id__1.json b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id__1.json new file mode 100644 index 000000000..c75052592 --- /dev/null +++ b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id__1.json @@ -0,0 +1,7 @@ +{ + "@context": "http://localhost/odata/$metadata#flights/$entity", + "id": 1, + "origin": "lhr", + "destination": "lax", + "gate": null +} diff --git a/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_expand__1.json b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_expand__1.json new file mode 100644 index 000000000..24170f156 --- /dev/null +++ b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_expand__1.json @@ -0,0 +1,24 @@ +{ + "@context": "http://localhost/odata/$metadata#flights(passengers())/$entity", + "id": 1, + "origin": "lhr", + "destination": "lax", + "gate": null, + "passengers": [ + { + "id": 1, + "name": "Anne Arbor", + "flight_id": 1 + }, + { + "id": 2, + "name": "Bob Barry", + "flight_id": 1 + }, + { + "id": 3, + "name": "Charlie Carrot", + "flight_id": 1 + } + ] +} diff --git a/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_incorrect_type__1.json b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_incorrect_type__1.json new file mode 100644 index 000000000..266cac850 --- /dev/null +++ b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_incorrect_type__1.json @@ -0,0 +1,4 @@ +{ + "code": "invalid_entity_type", + "message": "The provided type did not match the entity type" +} diff --git a/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_select__1.json b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_select__1.json new file mode 100644 index 000000000..e7c159c82 --- /dev/null +++ b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_select__1.json @@ -0,0 +1,4 @@ +{ + "@context": "http://localhost/odata/$metadata#flights(destination)/$entity", + "destination": "lax" +} diff --git a/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_type__1.json b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_type__1.json new file mode 100644 index 000000000..c75052592 --- /dev/null +++ b/tests/Unit/Queries/Entity/__snapshots__/EntityTest__test_resolve_entity_id_with_type__1.json @@ -0,0 +1,7 @@ +{ + "@context": "http://localhost/odata/$metadata#flights/$entity", + "id": 1, + "origin": "lhr", + "destination": "lax", + "gate": null +}