alex19pov31 /
bitrix-linked-data
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Alex19pov31\LinkedData; |
||
| 4 | |||
| 5 | class Storage implements StorgeInterface |
||
| 6 | { |
||
| 7 | /** |
||
| 8 | * Список репозиториев |
||
| 9 | * |
||
| 10 | * @var array|null |
||
| 11 | */ |
||
| 12 | private static $data; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Возвращает репозиторий по названию |
||
| 16 | * |
||
| 17 | * @param string $name |
||
| 18 | * @return RepositoryInterface|null |
||
| 19 | */ |
||
| 20 | public static function getRepository(string $name) |
||
| 21 | { |
||
| 22 | if (!isset(static::$data[$name])) { |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 23 | return static::$data[$name] = new BaseRepository($name); |
||
| 24 | } |
||
| 25 | |||
| 26 | return static::$data[$name]; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Сохранить данные репозиториев в кеш |
||
| 31 | * |
||
| 32 | * @param integer $minutes |
||
| 33 | * @return void |
||
| 34 | */ |
||
| 35 | public static function saveToCache(int $minutes) |
||
| 36 | { |
||
| 37 | if (is_null(static::$data)) { |
||
|
0 ignored issues
–
show
|
|||
| 38 | return; |
||
| 39 | } |
||
| 40 | |||
| 41 | foreach (static::$data as $repository) { |
||
| 42 | $repository->updateCache($minutes); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | } |
||
| 46 |