17 private const DEFAULT_ORDER = 50;
18 private const SETTING_NAME =
'im_placement';
32 $orderList = $this->getOrderList();
34 foreach ($this->generateApplicationList($placementList) as
$application)
52 ->addParams([
'site' =>
SITE_ID])
59 $orderList = $this->getOrderList();
60 $orderList[$applicationsId] =
$order;
61 $orderList = $this->filterDeletedApplications($orderList);
63 return $this->setOrderList($orderList);
66 private function getOrderList():
array
68 return \CUserOptions::GetOption(
'im', self::SETTING_NAME, []);
71 private function setOrderList(
array $orderList):
Result
74 $isSuccess = \CUserOptions::SetOption(
'im', self::SETTING_NAME, $orderList);
78 $result->addError(
new Error(
'Error writing the parameter order',
'SERVER_ERROR'));
84 private function isApplicationAvailable(Application\Entity
$application): bool
88 && $this->checkExtranet(
$application->options[
'extranet'])
92 private function checkExtranet(
string $extranetOption): bool
94 if ($this->getContext()->getUser()->isExtranet())
96 return $extranetOption ===
'Y';
102 private function checkRole(
string $roleOptions): bool
106 return mb_strtoupper($roleOptions) === Role::USER;
112 private function filterDeletedApplications(
array $userApplications):
array
114 $applicationIdList = $this->getApplicationIdList();
117 foreach ($userApplications as $applicationId =>
$order)
119 if (in_array($applicationId, $applicationIdList,
true))
131 private function generateApplicationList(?
array $placementList =
null): \Iterator
135 foreach (PlacementTable::getHandlersList($placement) as $handler)
137 yield
new Application\Entity([
138 'id' => $handler[
'ID'],
139 'placement' => $placement,
140 'options' => $handler[
'OPTIONS'],
141 'restApplicationId' => $handler[
'APP_ID'],
142 'title' => $handler[
'TITLE'],
148 private function getApplicationIdList():
array
151 foreach ($this->generateApplicationList() as
$application)
164 return 'placementApplications';
170 'items' => array_map(
171 static fn ($appEntity) => $appEntity->toRestFormat(),
172 $this->getApplications()