Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copying controller actions to the LumenJSONAPIController #105

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@
use Laravel\Lumen\Application;
use Laravel\Lumen\Routing\Controller;

use Illuminate\Container\Container;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use NilPortugues\Api\JsonApi\Http\Factory\RequestFactory;
use NilPortugues\Api\JsonApi\Http\Response\ResourceNotFound;
use NilPortugues\Laravel5\JsonApi\Actions\CreateResource;
use NilPortugues\Laravel5\JsonApi\Actions\DeleteResource;
use NilPortugues\Laravel5\JsonApi\Actions\GetResource;
use NilPortugues\Laravel5\JsonApi\Actions\ListResource;
use Symfony\Component\HttpFoundation\Response;

/**
* Class LumenJsonApiController.
*/
Expand All @@ -39,4 +50,116 @@ protected function uriGenerator($controllerAction)
}
}
}


/**
* Get many resources.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function index()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 4 spaces, found 5

{
$apiRequest = RequestFactory::create();

$page = $apiRequest->getPage();
if (!$page->size()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 9

$page->setSize($this->pageSize);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 12 spaces, found 9


$fields = $apiRequest->getFields();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$sorting = $apiRequest->getSort();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$included = $apiRequest->getIncludedRelationships();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$filters = $apiRequest->getFilters();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9


$resource = new ListResource($this->serializer, $page, $fields, $sorting, $included, $filters);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9


$totalAmount = $this->totalAmountResourceCallable();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$results = $this->listResourceCallable();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9


$controllerAction = '\\'.get_called_class().'@index';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$uri = $this->uriGenerator($controllerAction);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9


return $this->addHeaders($resource->get($totalAmount, $results, $uri, get_class($this->getDataModel())));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5


/**
* Get single resource.
*
* @param $id
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function show($id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5

{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 8 spaces, found 5

$apiRequest = RequestFactory::create();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9


$resource = new GetResource(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$this->serializer,
$apiRequest->getFields(),
$apiRequest->getIncludedRelationships()
);

$find = $this->findResourceCallable($id);

return $this->addHeaders($resource->get($id, get_class($this->getDataModel()), $find));
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5


/**
* @return ResourceNotFound
*/
public function create()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5

{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 8 spaces, found 5

return new ResourceNotFound();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5


/**
* Post Action.
*
* @param Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function store(Request $request)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5

{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 8 spaces, found 5

$createResource = $this->createResourceCallable();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$resource = new CreateResource($this->serializer);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

return $this->addHeaders(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 12 spaces, found 9

$resource->get((array) $request->get('data'), get_class($this->getDataModel()), $createResource)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Multi-line function call not indented correctly; expected 13 spaces but found 11
  • Line indented incorrectly; expected at least 12 spaces, found 11

);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5


/**
* @param $id
*
* @return Response
*/
public function update(Request $request, $id)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5

{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected at least 8 spaces, found 5

return (strtoupper($request->getMethod()) === 'PUT') ? $this->putAction($request,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Line indented incorrectly; expected at least 12 spaces, found 9
  • Opening parenthesis of a multi-line function call must be the last content on the line

$id) : $this->patchAction($request, $id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Multi-line function call not indented correctly; expected 9 spaces but found 13
  • Closing parenthesis of a multi-line function call must be on a line by itself

}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5


/**
* @return ResourceNotFound
*/
public function edit()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line indented incorrectly; expected 8 spaces, found 5

{
return new ResourceNotFound();
}

/**
* @param $id
*
* @return Response
*/
public function destroy($id)
{
$find = $this->findResourceCallable($id);

$delete = $this->deleteResourceCallable($id);

$resource = new DeleteResource($this->serializer);

return $this->addHeaders($resource->get($id, get_class($this->getDataModel()), $find, $delete));
}
}