1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
newitem.php
См. документацию.
1<?php
2
4
8use \Bitrix\Location\Service;
9
14final class NewItem extends Save
15{
20 public function save(Location $location): Result
21 {
22 if($existedLocation = $this->findLocalSavedLocation($location))
23 {
24 $location->setId($existedLocation->getId());
25 $location->setCode($existedLocation->getCode());
26 }
27
28 $result = new Result();
29
30 foreach($this->locationRepositories as $repository)
31 {
32 $res = $repository->save($location);
33
34 if(!$res->isSuccess())
35 {
36 $result->addErrors($res->getErrors());
37 }
38 }
39
40 if($parents = $location->getParents())
41 {
42 $res = $this->saveParents($parents);
43
44 if (!$res->isSuccess())
45 {
46 $result->addErrors($res->getErrors());
47 }
48 }
49
50 return $result;
51 }
52
59 {
60 return Service\LocationService::getInstance()->findByExternalId(
61 $location->getExternalId(),
62 $location->getSourceCode(),
63 $location->getLanguageId(),
65 );
66 }
67}
static getInstance()
Определения baseservice.php:21
findLocalSavedLocation(Location $location)
Определения newitem.php:58
saveParents(Location\Parents $parents)
Определения save.php:105
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
const LOCATION_SEARCH_SCOPE_INTERNAL
Определения include.php:4
$location
Определения options.php:2729