Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/socialnetwork/lib/Collab/ |
Upload File : |
<?php declare(strict_types=1); namespace Bitrix\Socialnetwork\Collab; use ArrayAccess; use ArrayIterator; use Bitrix\Main\Type\Contract\Arrayable; use Countable; use IteratorAggregate; /** * @method array getIdList() * @method array getNameList() */ class CollabCollection implements ArrayAccess, IteratorAggregate, Arrayable, Countable { /** @var Collab[] */ protected array $collabs = []; public function __construct(Collab ...$collabs) { foreach ($collabs as $collab) { $this->collabs[$collab->getId()] = $collab; } } public function isEmpty(): bool { return empty($this->collabs); } public function offsetExists(mixed $offset): bool { return isset($this->collabs[$offset]); } public function offsetGet(mixed $offset): ?Collab { return $this->collabs[$offset] ?? null; } public function offsetSet(mixed $offset, mixed $value): void { $this->collabs[$offset] = $value; } public function offsetUnset(mixed $offset): void { unset($this->collabs[$offset]); } public function getIterator(): ArrayIterator { return new ArrayIterator($this->collabs); } public function toArray(): array { $data = []; foreach ($this->collabs as $collab) { $data[$collab->getId()] = $collab->toArray(); } return $data; } public function getFirst(): ?Collab { foreach ($this->collabs as $collab) { return $collab; } return null; } public function count(): int { return count($this->collabs); } public function __call(string $name, array $arguments = []) { $operation = substr($name, 0, 3); $subOperation = lcfirst(substr($name, -4)); if ($operation === 'get' && $subOperation === 'list') { $property = strtoupper(substr($name, 3, -4)); return array_column($this->toArray(), $property); } return null; } }