1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
objectpool.php
См. документацию.
1<?
2namespace Bitrix\Sale\Delivery\Services;
3
9final class ObjectPool
10{
11 protected $usage = array();
13 protected $objects = array();
14 protected $maxObjectsCount = 0;
15
16 public function __construct($maxObjectsCount = 0)
17 {
18 $this->maxObjectsCount = $maxObjectsCount;
19 }
20
21 public function getObject(array $fields)
22 {
23 $result = null;
24 $index = $this->createIndex($fields);
25
26 if(!isset($this->objects[$index]))
27 {
28 if($this->maxObjectsCount > 0 && count($this->objects) > $this->maxObjectsCount)
29 $this->deleteOutdatedObject();
30
31 $result = $this->createObject($index, $fields);
32 }
33 else
34 {
35 $result = $this->objects[$index];
36 unset($this->usage[array_search($index, $this->usage)]);
37 }
38
39 array_push($this->usage, $index);
40 return $result;
41 }
42
43 protected function createObject($index, array $fields)
44 {
45 $this->objects[$index] = Manager::createObject($fields);
46 return $this->objects[$index];
47 }
48
49 protected function deleteOutdatedObject()
50 {
51 reset($this->usage);
52 unset($this->objects[current($this->usage)]);
53 unset($this->usage[key($this->usage)]);
54 }
55
56 protected function createIndex(array $fields)
57 {
58 return intval($fields['ID']) > 0 ? intval($fields['ID']) : md5(serialize($fields));
59 }
60}
static createObject(array $srvParams)
Определения manager.php:367
getObject(array $fields)
Определения objectpool.php:21
createIndex(array $fields)
Определения objectpool.php:56
createObject($index, array $fields)
Определения objectpool.php:43
__construct($maxObjectsCount=0)
Определения objectpool.php:16
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$fields
Определения yandex_run.php:501