1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
RelationCursor.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
12
14{
15 public function __construct(
16 #[InArray([Chat::ROLE_MEMBER, Chat::ROLE_MANAGER, Chat::ROLE_OWNER])]
17 public readonly string $role,
19 public readonly int $relationId,
20 ){}
21
22 public static function getRestEntityName(): string
23 {
24 return 'nextCursor';
25 }
26
27 public function toRestFormat(array $option = []): ?array
28 {
29 return [
30 'role' => mb_strtolower($this->role),
31 'relationId' => $this->relationId,
32 ];
33 }
34
35 public static function createFromArray(array $parameters): static
36 {
37 return new static(mb_strtoupper($parameters['role'] ?? ''), (int)($parameters['relationId'] ?? 0));
38 }
39
40 public static function getNext(RelationCollection $relations, int $limit): ?static
41 {
42 if ($relations->count() < $limit)
43 {
44 return null;
45 }
46
47 $maxRole = null;
48 $maxRolePriority = 0;
49 $maxId = 0;
50
51 foreach ($relations as $relation)
52 {
53 $rolePriority = RelationProvider::ROLE_PRIORITY_MAP[$relation->getRole()];
54 if ($rolePriority > $maxRolePriority)
55 {
56 $maxRole = $relation->getRole();
57 $maxRolePriority = $rolePriority;
58 $maxId = $relation->getId();
59 }
60 if ($relation->getId() > $maxId)
61 {
62 $maxId = $relation->getId();
63 }
64 }
65
66 if ($maxRole === null || $maxId === null)
67 {
68 return null;
69 }
70
71 return new RelationCursor($maxRole, $maxId);
72 }
73}
__construct(#[InArray([Chat::ROLE_MEMBER, Chat::ROLE_MANAGER, Chat::ROLE_OWNER])] public readonly string $role, #[PositiveNumber] public readonly int $relationId,)
Определения RelationCursor.php:15
toRestFormat(array $option=[])
Определения RelationCursor.php:27
static createFromArray(array $parameters)
Определения RelationCursor.php:35
static getNext(RelationCollection $relations, int $limit)
Определения RelationCursor.php:40
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$option
Определения options.php:1711