Select Git revision
StockImagesIndex.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Marcus Eibrink-Lunzenauer authored
Closes #2482 Merge request studip/studip!1788
Marcus Eibrink-Lunzenauer authoredCloses #2482 Merge request studip/studip!1788
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
StockImagesIndex.php 1008 B
<?php
namespace JsonApi\Routes\StockImages;
use JsonApi\Errors\AuthorizationFailedException;
use JsonApi\Errors\RecordNotFoundException;
use JsonApi\JsonApiController;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
/**
* Displays all stock images.
*/
class StockImagesIndex extends JsonApiController
{
protected $allowedPagingParameters = ['offset', 'limit'];
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __invoke(Request $request, Response $response): Response
{
if (!Authority::canIndexStockImages($this->getUser($request))) {
throw new AuthorizationFailedException();
}
list($offset, $limit) = $this->getOffsetAndLimit();
$total = \StockImage::countBySQL('1');
$stockImages = \StockImage::findBySQL("1 ORDER BY title ASC LIMIT {$offset}, {$limit}");
return $this->getPaginatedContentResponse($stockImages, $total);
}
}