Skip to content

Commit

Permalink
Breaking change: Add scalar types for the CRUD Handler
Browse files Browse the repository at this point in the history
  • Loading branch information
cundd committed Mar 12, 2019
1 parent b151929 commit 2a0ea1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Classes/Handler/CrudHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function getDescription()
return 'Default Handler for CRUD requests';
}

public function getProperty(RestRequestInterface $request, $identifier, $propertyKey)
public function getProperty(RestRequestInterface $request, string $identifier, string $propertyKey)
{
$resourceType = $request->getResourceType();
$dataProvider = $this->getDataProvider($resourceType);
Expand All @@ -70,7 +70,7 @@ public function getProperty(RestRequestInterface $request, $identifier, $propert
return $dataProvider->getModelProperty($model, $propertyKey);
}

public function show(RestRequestInterface $request, $identifier)
public function show(RestRequestInterface $request, string $identifier)
{
$resourceType = $request->getResourceType();
$dataProvider = $this->getDataProvider($resourceType);
Expand Down Expand Up @@ -111,7 +111,7 @@ public function create(RestRequestInterface $request)
return $this->prepareResult($request, $result);
}

public function update(RestRequestInterface $request, $identifier)
public function update(RestRequestInterface $request, string $identifier)
{
$resourceType = $request->getResourceType();
$dataProvider = $this->getDataProvider($resourceType);
Expand Down Expand Up @@ -143,7 +143,7 @@ public function update(RestRequestInterface $request, $identifier)
return $this->prepareResult($request, $result);
}

public function delete(RestRequestInterface $request, $identifier)
public function delete(RestRequestInterface $request, string $identifier)
{
$resourceType = $request->getResourceType();
$dataProvider = $this->getDataProvider($resourceType);
Expand Down
20 changes: 12 additions & 8 deletions Classes/Handler/CrudHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,42 @@ interface CrudHandlerInterface extends HandlerInterface
* Return the given property of the requested Model
*
* @param RestRequestInterface $request
* @param int|string $identifier
* @param string $identifier
* @param string $propertyKey
* @return mixed
*/
public function getProperty(RestRequestInterface $request, $identifier, $propertyKey);
public function getProperty(
RestRequestInterface $request,
string $identifier,
string $propertyKey
);

/**
* Return the data of the current Model
*
* @param RestRequestInterface $request
* @param int|string $identifier
* @param string $identifier
* @return array|int|ResponseInterface Returns the Model's data on success, otherwise a descriptive error code
*/
public function show(RestRequestInterface $request, $identifier);
public function show(RestRequestInterface $request, string $identifier);

/**
* Replace the requested Model with the data from the request
*
* @param RestRequestInterface $request
* @param int|string $identifier
* @param string $identifier
* @return array|int|ResponseInterface Returns the Model's data on success, otherwise a descriptive error code
*/
public function update(RestRequestInterface $request, $identifier);
public function update(RestRequestInterface $request, string $identifier);

/**
* Delete the requested Model
*
* @param RestRequestInterface $request
* @param int|string $identifier
* @param string $identifier
* @return int|ResponseInterface Returns 200 an success
*/
public function delete(RestRequestInterface $request, $identifier);
public function delete(RestRequestInterface $request, string $identifier);

/**
* Create a new Model with the data from the request
Expand Down

0 comments on commit 2a0ea1b

Please sign in to comment.