14 public function init($event): void
16 $this->ownerId = (int) $event->getParameter(
'APP_ID');
17 if ($this->ownerId <= 0)
19 $this->errorCollection->setError(
new Error(
'Application id is not set.'));
23 if (!($app = Rest\AppTable::getById($this->ownerId)->fetch()))
25 $this->errorCollection->setError(
new Error(
'Application is not found.'));
31 if ($group = Avatar\Mask\GroupTable::getList([
34 '=OWNER_TYPE' => Avatar\Mask\Owner\RestApp::class,
35 '=OWNER_ID' => $this->ownerId,
39 $this->groupId = $group[
'ID'];
43 $this->groupId = Avatar\Mask\Group::createOrGet($this->owner, $app[
'APP_NAME'])->getId();
49 foreach ($this->data as $res)
51 $fileInfo = $this->structure->getUnpackFile((
int)$res[
'FILE_ID']);
52 $file = !empty($fileInfo[
'PATH']) ? \CFile::makeFileArray($fileInfo[
'PATH']) :
null;
53 $file[
'name'] = $fileInfo[
'NAME'];
56 $result = Avatar\Mask\Item::create(
60 'TITLE' => $res[
'TITLE'],
61 'DESCRIPTION' => $res[
'DESCRIPTION'],
62 'GROUP_ID' => $this->groupId,
63 'ACCESS_CODE' => $this->owner->getDefaultAccess()
66 if (!$result->isSuccess())
68 $this->errorCollection->add($result->getErrors());