Prevent error if no input is given in create actions

This commit is contained in:
Toby Zerner 2015-11-23 14:15:30 +10:30
parent a61929730e
commit 262a934747
4 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ class CreateDiscussionController extends AbstractCreateController
$actor = $request->getAttribute('actor');
$discussion = $this->bus->dispatch(
new StartDiscussion($actor, array_get($request->getParsedBody(), 'data'))
new StartDiscussion($actor, array_get($request->getParsedBody(), 'data', []))
);
// After creating the discussion, we assume that the user has seen all

View File

@ -41,7 +41,7 @@ class CreateGroupController extends AbstractCreateController
protected function data(ServerRequestInterface $request, Document $document)
{
return $this->bus->dispatch(
new CreateGroup($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data'))
new CreateGroup($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data', []))
);
}
}

View File

@ -52,7 +52,7 @@ class CreatePostController extends AbstractCreateController
protected function data(ServerRequestInterface $request, Document $document)
{
$actor = $request->getAttribute('actor');
$data = array_get($request->getParsedBody(), 'data');
$data = array_get($request->getParsedBody(), 'data', []);
$discussionId = array_get($data, 'relationships.discussion.data.id');
$ipAddress = array_get($request->getServerParams(), 'REMOTE_ADDR', '127.0.0.1');

View File

@ -41,7 +41,7 @@ class CreateUserController extends AbstractCreateController
protected function data(ServerRequestInterface $request, Document $document)
{
return $this->bus->dispatch(
new RegisterUser($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data'))
new RegisterUser($request->getAttribute('actor'), array_get($request->getParsedBody(), 'data', []))
);
}
}