Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
MaskImportPersonal.php
1<?php
3
5use Bitrix\UI\Avatar;
6
8{
9 protected int $ownerId;
11
12 public function init($event): void
13 {
14 $this->ownerId = (int) $event->getParameter('USER_ID');
15 if ($this->ownerId <= 0)
16 {
17 $this->errorCollection->setError(new Error('User owner is not set'));
18 return;
19 }
20 $this->owner = new Avatar\Mask\Owner\User($this->ownerId);
21 }
22
23 public function makeAStep(): void
24 {
25 foreach ($this->data as $res)
26 {
27 $fileInfo = $this->structure->getUnpackFile((int)$res['FILE_ID']);
28 $file = !empty($fileInfo['PATH']) ? \CFile::makeFileArray($fileInfo['PATH']) : null;
29 $file['name'] = $fileInfo['NAME'];
30 if ($file)
31 {
32 $result = Avatar\Mask\Item::create(
33 $this->owner,
34 $file,
35 [
36 'TITLE' => $res['TITLE'],
37 'DESCRIPTION' => $res['DESCRIPTION'],
38 'ACCESS_CODE' => $this->owner->getDefaultAccess()
39 ]
40 );
41 if (!$result->isSuccess())
42 {
43 $this->errorCollection->add($result->getErrors());
44 }
45 }
46 }
47 }
48}