1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
MaskImportApp.php
См. документацию.
1<?php
2namespace Bitrix\UI\Integration\Rest;
3
4use Bitrix\Main\Error;
5use Bitrix\UI\Avatar;
6use Bitrix\Rest;
7
9{
10 protected int $ownerId;
11 private int $groupId;
13
14 public function init($event): void
15 {
16 $this->ownerId = (int) $event->getParameter('APP_ID');
17 if ($this->ownerId <= 0)
18 {
19 $this->errorCollection->setError(new Error('Application id is not set.'));
20 return;
21 }
22
23 if (!($app = Rest\AppTable::getById($this->ownerId)->fetch()))
24 {
25 $this->errorCollection->setError(new Error('Application is not found.'));
26 return;
27 }
28
29 $this->owner = new Avatar\Mask\Owner\RestApp($this->ownerId);
30
31 if ($group = Avatar\Mask\GroupTable::getList([
32 'select' => ['ID'],
33 'filter' => [
34 '=OWNER_TYPE' => Avatar\Mask\Owner\RestApp::class,
35 '=OWNER_ID' => $this->ownerId,
36 ]
37 ])->fetch())
38 {
39 $this->groupId = $group['ID'];
40 }
41 else
42 {
43 $this->groupId = Avatar\Mask\Group::createOrGet($this->owner, $app['APP_NAME'])->getId();
44 }
45 }
46
47 public function makeAStep(): void
48 {
49 foreach ($this->data as $res)
50 {
51 $fileInfo = $this->structure->getUnpackFile((int)$res['FILE_ID']);
52 $file = !empty($fileInfo['PATH']) ? \CFile::makeFileArray($fileInfo['PATH']) : null;
53 $file['name'] = $fileInfo['NAME'];
54 if ($file)
55 {
57 $this->owner,
58 $file,
59 [
60 'TITLE' => $res['TITLE'],
61 'DESCRIPTION' => $res['DESCRIPTION'],
62 'GROUP_ID' => $this->groupId,
63 'ACCESS_CODE' => $this->owner->getDefaultAccess()
64 ]
65 );
66 if (!$result->isSuccess())
67 {
68 $this->errorCollection->add($result->getErrors());
69 }
70 }
71 }
72 }
73}
Определения error.php:15
static createOrGet(DefaultOwner $owner, string $title, ?string $description=null)
Определения Group.php:73
static create(Owner\DefaultOwner $owner, array $file, ?array $descriptionParams=[])
Определения Item.php:152
Avatar Mask Owner DefaultOwner $owner
Определения MaskImportApp.php:12
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$app
Определения proxy.php:8
Определения handlers.php:8
$event
Определения prolog_after.php:141