Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
inventorymanagementsourcebuilder.php
1<?php
2
3namespace Bitrix\Catalog\Url;
4
6{
7 private const INVENTORY_MANAGEMENT_SOURCE_PARAM_NAME = 'inventoryManagementSource';
8
9 private static ?InventoryManagementSourceBuilder $instance = null;
10 private ?string $inventoryManagementSource;
11
13 {
14 if (!self::$instance)
15 {
16 self::$instance = new self();
17 }
18
19 return self::$instance;
20 }
21
22 public function __construct()
23 {
24 $param =
25 \Bitrix\Main\Context::getCurrent()
26 ->getRequest()
27 ->get(self::INVENTORY_MANAGEMENT_SOURCE_PARAM_NAME)
28 ;
29
30 $this->inventoryManagementSource = $param ? urlencode((string)$param) : null;
31 }
32
38 public function getInventoryManagementSource(): ?string
39 {
40 return $this->inventoryManagementSource;
41 }
42
49 public function addInventoryManagementSourceParam(string $uri): string
50 {
51 if (!$this->inventoryManagementSource)
52 {
53 return $uri;
54 }
55
56 $uriEntity = new \Bitrix\Main\Web\Uri($uri);
57 $uriEntity->addParams([self::INVENTORY_MANAGEMENT_SOURCE_PARAM_NAME => $this->inventoryManagementSource]);
58
59 return $uriEntity->getUri();
60 }
61}