mirror of
https://code.castopod.org/adaures/castopod
synced 2025-05-12 17:25:45 +00:00

- update .devcontainer settings: remove auto-formatting for php + set intelephense as default formatter - remove prettier php plugin as it lacks php 8 support - add captain hook action for checking style pre-commit - fix style with ecs on all files except views
49 lines
1.2 KiB
PHP
49 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* This class defines a Paginated OrderedCollection based on CodeIgniter4 Pager to get the pagination metadata
|
|
*
|
|
* @copyright 2021 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace ActivityPub\Objects;
|
|
|
|
use ActivityPub\Core\ObjectType;
|
|
use CodeIgniter\Pager\Pager;
|
|
|
|
class OrderedCollectionObject extends ObjectType
|
|
{
|
|
protected string $type = 'OrderedCollection';
|
|
|
|
protected int $totalItems;
|
|
|
|
protected ?string $first;
|
|
|
|
protected ?string $current;
|
|
|
|
protected ?string $last;
|
|
|
|
/**
|
|
* @param ObjectType[] $orderedItems
|
|
*/
|
|
public function __construct(
|
|
protected ?array $orderedItems = null,
|
|
?Pager $pager = null
|
|
) {
|
|
$this->id = current_url();
|
|
|
|
if ($pager !== null) {
|
|
$totalItems = $pager->getTotal();
|
|
$this->totalItems = $totalItems;
|
|
|
|
if ($totalItems !== 0) {
|
|
$this->first = $pager->getPageURI($pager->getFirstPage());
|
|
$this->current = $pager->getPageURI();
|
|
$this->last = $pager->getPageURI($pager->getLastPage());
|
|
}
|
|
}
|
|
}
|
|
}
|