1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AccessDecorator.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
5namespace Bitrix\Socialnetwork\Control\Decorator;
6
7use Bitrix\Socialnetwork\Control\Command\AddCommand;
8use Bitrix\Socialnetwork\Control\Command\DeleteCommand;
9use Bitrix\Socialnetwork\Control\Command\UpdateCommand;
10use Bitrix\Socialnetwork\Control\Exception\GroupNotAddedException;
11use Bitrix\Socialnetwork\Control\Exception\GroupNotDeletedException;
12use Bitrix\Socialnetwork\Control\Exception\GroupNotUpdatedException;
13use Bitrix\Socialnetwork\Control\GroupResult;
14
16{
20 public function add(AddCommand $command): GroupResult
21 {
22 $result = new GroupResult();
23
24 $controller = $command->getAccessControllerByInitiator();
25 if ($controller === null)
26 {
27 throw new GroupNotAddedException('Access controller not found');
28 }
29
30 $model = $controller->getModel($command);
31 $action = $controller->getDictionary()->create();
32
33 if (!$controller->check($action, $model))
34 {
35 $result->addErrors($controller->getErrors());
36
37 return $this->source->finalizeAddResult($result);
38 }
39
40 return $this->source->add($command);
41 }
42
46 public function update(UpdateCommand $command): GroupResult
47 {
48 $result = new GroupResult();
49
50 $controller = $command->getAccessControllerByInitiator();
51 if ($controller === null)
52 {
53 throw new GroupNotUpdatedException('Access controller not found');
54 }
55
56 $action = $controller->getDictionary()->update();
57 $model = $controller->getModel($command);
58 $entity = $this->source->registry->get($command->getId());
59
60 if (!$controller->check($action, $model, $entity))
61 {
62 $result->addErrors($controller->getErrors());
63
64 return $this->source->finalizeUpdateResult($result);
65 }
66
67 return $this->source->update($command);
68 }
69
73 public function delete(DeleteCommand $command): GroupResult
74 {
75 $result = new GroupResult();
76
77 $controller = $command->getAccessControllerByInitiator();
78 if ($controller === null)
79 {
80 throw new GroupNotDeletedException('Access controller not found');
81 }
82
83 $action = $controller->getDictionary()->delete();
84
85 if (!$controller->checkByItemId($action, $command->getId()))
86 {
87 $result->addErrors($controller->getErrors());
88
89 return $this->finalizeDeleteResult($result);
90 }
91
92 return $this->source->delete($command);
93 }
94}
$result
Определения get_property_values.php:14
$entity
$action
Определения file_dialog.php:21