Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sitecurrency.php
1<?php
8namespace Bitrix\Sale;
9
12
13class SiteCurrencyTable extends Entity\DataManager
14{
15 public static function getFilePath()
16 {
17 return __FILE__;
18 }
19
20 public static function getTableName()
21 {
22 return 'b_sale_lang';
23 }
24
25 public static function getMap()
26 {
27 return array(
28 'LID' => array(
29 'data_type' => 'string',
30 'primary' => true,
31 'format' => '/^[A-Za-z0-9_]{2}$/'
32 ),
33 'CURRENCY' => array(
34 'data_type' => 'string',
35 'format' => '/^[A-Z]{3}$/'
36 )
37 );
38 }
39
40 private static $cache = array();
41
46 public static function getCurrency($siteId)
47 {
48 if (! self::$cache)
49 {
50 $managed = Application::getInstance()->getManagedCache();
51 $key = self::getTableName();
52
53 if ($managed->read(3600, $key))
54 self::$cache = $managed->get($key);
55 else
56 {
57 $result = self::getList(array(
58 'select' => array('*')
59 ));
60 while ($row = $result->fetch())
61 self::$cache[$row['LID']] = $row;
62 $managed->set($key, self::$cache);
63 }
64 }
65 return self::$cache[$siteId];
66 }
67
68 public static function onAfterAdd(Entity\Event $event)
69 {
70 Application::getInstance()->getManagedCache()->clean(self::getTableName());
71 self::$cache = array();
72 }
73
74 public static function onAfterUpdate(Entity\Event $event)
75 {
76 Application::getInstance()->getManagedCache()->clean(self::getTableName());
77 self::$cache = array();
78 }
79
80 public static function onAfterDelete(Entity\Event $event)
81 {
82 Application::getInstance()->getManagedCache()->clean(self::getTableName());
83 self::$cache = array();
84 }
85}
static onAfterAdd(Entity\Event $event)
static onAfterUpdate(Entity\Event $event)
static onAfterDelete(Entity\Event $event)