3declare(strict_types=1);
5namespace Bitrix\Socialnetwork\Collab\Onboarding\Entity;
8use Bitrix\Im\V2\Promotion\Entity\PromotionList;
9use Bitrix\Main\Type\Collection;
10use Bitrix\Main\Type\Contract\Arrayable;
11use Bitrix\Main\Validation\Rule\ElementsType;
12use Bitrix\Main\Validation\Rule\Recursive\Validatable;
13use Bitrix\Socialnetwork\Collab\Onboarding\Integration\Im\Promotion\Converter\PromotionListConverter;
14use Bitrix\Socialnetwork\Collab\Onboarding\Internals\Validation\Validator\JobDataValidator;
19 #[ElementsType(className: AbstractJob::class)]
22 private ?ArrayIterator $iterator =
null;
26 $this->jobs = array_filter(
28 static fn($job) => $job !==
null
41 foreach ($jobCollection as $job)
51 $filteredIds = array_flip($jobCollection->getIdList());
53 $this->jobs = array_filter(
63 return $this->getByImmediately(
true);
68 return $this->getByImmediately(
false);
71 private function getByImmediately(
bool $isImmediately): self
73 $jobCollection =
new self();
75 foreach ($this->jobs as $job)
77 if ($isImmediately === $job->isImmediatelyExecuted())
79 $jobCollection->add($job);
83 return $jobCollection;
92 foreach ($this->jobs as $job)
94 $types[] = $job->getType()->value;
97 return array_unique($types);
106 foreach ($this->jobs as $job)
108 $ids[] = $job->getUserId();
111 Collection::normalizeArrayValuesByInt($ids,
false);
122 foreach ($this->jobs as $job)
124 $ids[] = $job->getCollabId();
127 Collection::normalizeArrayValuesByInt($ids,
false);
138 foreach ($this->jobs as $job)
140 $ids[] = $job->getId();
143 Collection::normalizeArrayValuesByInt($ids,
false);
150 return empty($this->jobs);
155 if ($this->iterator ===
null)
157 $this->iterator =
new ArrayIterator($this->jobs);
167 foreach ($this->jobs as $job)
184 $jobCollection =
new self();
187 foreach ($jobCollectionData as $jobData)
189 if (!$jobDataValidator->validate($jobData)->isSuccess())
195 ?->setId($jobData[
'id'])
196 ->setCreatedDate($jobData[
'createdDate'])
197 ->setNextExecution($jobData[
'nextExecution'])
200 $jobCollection->add($job);
203 return $jobCollection;
216 return PromotionListConverter::getInstance()
217 ->convertJobCollection($this)
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
__construct(?AbstractJob ... $jobs)
static mapFromArray(array $jobCollectionData)
cleanIntersectingJobs(self $jobCollection)
merge(JobCollection $jobCollection)
getNotImmediatelyExecuted()
static create(int $collabId, int $userId, string $type)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)