8000 Merge branch 'master' into feature/pagination · sablesoft/laravel-json-api@bf09354 · GitHub
[go: up one dir, main page]

Skip to content

Commit bf09354

Browse files
committed
Merge branch 'master' into feature/pagination
2 parents dc21e30 + 3885101 commit bf09354

File tree

3 files changed

+40
-11
lines changed

3 files changed

+40
-11
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"illuminate/http": "^5.1",
2929
"illuminate/routing": "^5.1",
3030
"neomerx/json-api": "^0.6.0",
31-
"cloudcreativity/json-api": "^0.3.0"
31+
"cloudcreativity/json-api": "^0.4.0"
3232
},
3333
"require-dev": {
3434
"phpunit/phpunit": "^4.7"

src/Http/Controllers/JsonApiController.php

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
namespace CloudCreativity\JsonApi\Http\Controllers;
2020

21-
use CloudCreativity\JsonApi\Error\ThrowableError;
21+
use CloudCreativity\JsonApi\Contracts\Error\ErrorObjectInterface;
22+
use CloudCreativity\JsonApi\Error\ErrorException;
2223
use Illuminate\Http\Response;
2324
use Illuminate\Routing\Controller;
2425

@@ -57,32 +58,60 @@ public function callAction($method, $parameters)
5758
/**
5859
* @param array $parameters
5960
* @return void
60-
* @throws ThrowableError
61+
* @throws ErrorException
6162
*/
6263
public function missingMethod($parameters = [])
6364
{
64-
throw new ThrowableError('Method Not Allowed', Response::HTTP_METHOD_NOT_ALLOWED);
65+
$this->methodNotAllowed();
6566
}
6667

6768
/**
6869
* @param string $method
6970
* @param array $parameters
7071
* @return void
71-
* @throws ThrowableError
72+
* @throws ErrorException
7273
*/
7374
public function __call($method, $parameters)
7475
{
75-
throw new ThrowableError('Not Implemented', Response::HTTP_NOT_IMPLEMENTED);
76+
$this->notImplemented();
7677
}
7778

7879
/**
7980
* Helper method to throw a not found exception.
8081
*
81-
* @return void
82-
* @throws ThrowableError
82+
* @throws ErrorException
8383
*/
8484
public function notFound()
8585
{
86-
throw new ThrowableError('Not Found', Response::HTTP_NOT_FOUND);
86+
throw new ErrorException([
87+
ErrorObjectInterface::TITLE => 'Not Found',
88+
ErrorObjectInterface::STATUS => Response::HTTP_NOT_FOUND,
89+
]);
90+
}
91+
92+
/**
93+
* Helper method to throw a not implemented exception.
94+
*
95+
* @throws ErrorException
96+
*/
97+
public function notImplemented()
98+
{
99+
throw new ErrorException([
100+
ErrorObjectInterface::TITLE => 'Not Implemented',
101+
ErrorObjectInterface::STATUS => Response::HTTP_NOT_IMPLEMENTED,
102+
]);
103+
}
104+
105+
/**
106+
* Helper method to throw a method not allowed exception.
107+
*
108+
* @throws ErrorException
109+
*/
110+
public function methodNotAllowed()
111+
{
112+
throw new ErrorException([
113+
ErrorObjectInterface::TITLE => 'Method Not Allowed',
114+
ErrorObjectInterface::STATUS => Response::HTTP_METHOD_NOT_ALLOWED,
115+
]);
87116
}
88117
}

src/Routing/ResourceRegistrar.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ private function registerHasMany($objectUrl, $controller, array $relations)
116116

117117
$this->router->get($related, sprintf('%s@read%s', $controller, $name));
118118
$this->router->get($identifier, sprintf('%s@read%sRelationship', $controller, $name));
119-
$this->router->patch($identifier, sprintf('%s@read%sRelationship', $controller, $name));
120-
$this->router->delete($identifier, sprintf('%s@read%sRelationship', $controller, $name));
119+
$this->router->patch($identifier, sprintf('%s@update%sRelationship', $controller, $name));
120+
$this->router->delete($identifier, sprintf('%s@delete%sRelationship', $controller, $name));
121121
}
122122

123123
return $this;

0 commit comments

Comments
 (0)
0