1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
newitem.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Location\Repository\Location\Strategy\Save
;
4
5
use
Bitrix\Location\Entity\Location
;
6
use
Bitrix\Location\Repository\Location\Strategy\Save
;
7
use
Bitrix\Main\Result
;
8
use \Bitrix\Location\Service;
9
14
final
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
58
protected
function
findLocalSavedLocation
(
Location
$location
)
59
{
60
return
Service\LocationService::getInstance
()->findByExternalId(
61
$location
->getExternalId(),
62
$location
->getSourceCode(),
63
$location
->getLanguageId(),
64
LOCATION_SEARCH_SCOPE_INTERNAL
65
);
66
}
67
}
Bitrix\Location\Common\BaseService\getInstance
static getInstance()
Определения
baseservice.php:21
Bitrix\Location\Repository\Location\Strategy\Save\NewItem
Определения
newitem.php:15
Bitrix\Location\Repository\Location\Strategy\Save\NewItem\findLocalSavedLocation
findLocalSavedLocation(Location $location)
Определения
newitem.php:58
Bitrix\Location\Repository\Location\Strategy\Save\NewItem\save
save(Location $location)
Определения
newitem.php:20
Bitrix\Location\Repository\Location\Strategy\Save\saveParents
saveParents(Location\Parents $parents)
Определения
save.php:105
Bitrix\Main\ORM\Data\Result
Определения
result.php:16
$res
$res
Определения
filter_act.php:7
$result
$result
Определения
get_property_values.php:14
LOCATION_SEARCH_SCOPE_INTERNAL
const LOCATION_SEARCH_SCOPE_INTERNAL
Определения
include.php:4
Bitrix\Location\Entity\Location
Определения
collection.php:3
Bitrix\Location\Repository\Location\Strategy\Save
Определения
newitem.php:3
$location
$location
Определения
options.php:2729
bitrix
modules
location
lib
repository
location
strategy
save
newitem.php
Создано системой
1.14.0