Skip to content

Commit

Permalink
Improved Controllers code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
alongosz committed Nov 20, 2024
1 parent 4ab1bfc commit 4d65580
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions src/lib/Server/Controller/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ public function updateContentMetadata($contentId, Request $request)
}

try {
$locationInfo = $this->repository->getLocationService()->loadLocation($contentInfo->mainLocationId);
$locationInfo = null !== $contentInfo->mainLocationId
? $this->repository->getLocationService()->loadLocation($contentInfo->mainLocationId)
: null;
} catch (NotFoundException $e) {
$locationInfo = null;
}
Expand Down Expand Up @@ -356,16 +358,16 @@ public function deleteContentTranslation($contentId, $languageCode)
* Returns a list of all versions of the content. This method does not
* include fields and relations in the Version elements of the response.
*
* @param mixed $contentId
*
* @return \Ibexa\Rest\Server\Values\VersionList
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\InvalidArgumentException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\NotFoundException
* @throws \Ibexa\Contracts\Core\Repository\Exceptions\UnauthorizedException
*/
public function loadContentVersions($contentId, Request $request)
public function loadContentVersions(int $contentId, Request $request): Values\VersionList
{
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);

return new Values\VersionList(
$this->repository->getContentService()->loadVersions($contentInfo),
iterator_to_array($this->repository->getContentService()->loadVersions($contentInfo)),
$request->getPathInfo()
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/Server/Controller/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class User extends RestController
*
* @var \Ibexa\Contracts\Core\Repository\Repository
*/
protected $repository;
protected Repository $repository;

private PermissionResolver $permissionResolver;

Expand Down

0 comments on commit 4d65580

Please sign in to comment.