PHP Interface Webiny\Component\Rest\Interfaces\CrudInterface

--------------------------------------------------------------------------------------------------------------- | Request type | Url | Mapping | Description | --------------------------------------------------------------------------------------------------------------- | GET | foo-class/ | FooClass::crudList | Retrieve all records in a collection. | | POST | foo-class/ | FooClass::crudCreate() | Create new record. | | DELETE | foo-class/{id} | FooClass::crudDelete($id) | Delete a record with the given id. | | GET | foo-class/{id} | FooClass::crudGet($id) | Retrieve a single record. | | PUT | foo-class/{id} | FooClass::crudReplace($id) | Replace a single record. | | PATCH | foo-class/{id} | FooClass::crudUpdate($id) | Update a single record. | ---------------------------------------------------------------------------------------------------------------
显示文件 Open project: Webiny/Framework

Public Methods

Method Description
crudCreate ( ) : array | mixed Create new record.
crudDelete ( string $id ) : boolean Delete a record with the given id.
crudGet ( string $id ) : array | mixed Retrieve a single record.
crudList ( ) : array | mixed Retrieve all records in a collection.
crudReplace ( string $id ) : array | mixed Replace a single record.
crudUpdate ( string $id ) : array | mixed Update a single record.

Method Details

crudCreate() public method

Create new record.
public crudCreate ( ) : array | mixed
return array | mixed Array containing the newly created record.

crudDelete() public method

Delete a record with the given id.
public crudDelete ( string $id ) : boolean
$id string Id of the record to be deleted.
return boolean True if delete was successful or false.

crudGet() public method

Retrieve a single record.
public crudGet ( string $id ) : array | mixed
$id string Id of the record that should be retrieved.
return array | mixed The requested record.

crudList() public method

Retrieve all records in a collection.
public crudList ( ) : array | mixed
return array | mixed A list of retrieved records. As an array with properties [records, totalCount, perPage, page].

crudReplace() public method

Note that the difference between crudUpdate and crudReplace is that in crudReplace, all current record attributes should be removed and the new attributes should be added, while in crudUpdate the attributes would only be added or deleted. In crudUpdate, if the record doesn't exist, it can be created.
See also: http://tools.ietf.org/html/rfc5789
public crudReplace ( string $id ) : array | mixed
$id string Id of the record that should be replaced.
return array | mixed The replaced record.

crudUpdate() public method

Note that the difference between crudUpdate and crudReplace is that in crudReplace, all current record attributes should be removed and the new attributes should be added, while in crudUpdate the attributes would only be added or deleted. In crudUpdate, if the record doesn't exist, it can be created.
See also: http://tools.ietf.org/html/rfc5789
public crudUpdate ( string $id ) : array | mixed
$id string Id of the record that should be replaced.
return array | mixed The updated, or created, record.