Skip to content

Conversation

@geoidesic
Copy link
Collaborator

The JSONAPI spec allows for PATCH, POST and DELETE of URLs of the format {controller}/{id}/relationships/{foreignTable}

Allowing relationships to be added, altered or deleted.

Crud-json-api doesn't support this yet.

This commit adds support for this. However please note that documentation will need to be updated to reflect config and routing requirements to make this work, since these URLS are not part of Cake's resource RESTful routes format.

Config:

$this->loadComponent('Crud.Crud', [
            'actions' => ['CrudJsonApi.Relationships`]);

Route:

$RouteBuilder->connect('/{controller}/{id}/relationships/{foreignTableName}', ['action' => 'Relationships']);

(Not sure if that route is quite right just yet)

The JSONAPI spec allows for PATCH, POST and DELETE of URLs of the format `{controller}/{id}/relationships/{foreignTable}`

Allowing relationships to be added, altered or deleted.

Crud-json-api doesn't support this yet.

This commit adds support for this. However please note that documentation will need to be updated to reflect config and routing requirements to make this work, since these URLS are not part of Cake's `resource` RESTful routes format.

Config:
```
$this->loadComponent('Crud.Crud', [
            'actions' => ['CrudJsonApi.Relationships`]);
```
Route:
```
$RouteBuilder->connect('/{controller}/{id}/relationships/{foreignTableName}', ['action' => 'Relationships']);
```
Not sure if that's quite right just yet
```
@dakota dakota changed the base branch from master to cake-4.x August 4, 2020 08:37
@dakota
Copy link
Member

dakota commented Aug 4, 2020

DocumentRelationshipValidator seems to be missing

@dakota dakota changed the base branch from cake-4.x to relationship-handling August 5, 2020 06:37
@dakota dakota merged commit d0291ba into FriendsOfCake:relationship-handling Aug 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants