Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
formatservice.php
1<?php
2
4
5use Bitrix\Location\Common\RepositoryTrait;
6use \Bitrix\Location\Entity;
11
19final class FormatService extends BaseService
20{
21 use RepositoryTrait;
22
24 protected static $instance;
25
27 private $defaultFormatCode;
28
30 protected $repository;
31
39 public function findByCode(string $formatCode, string $languageId)
40 {
41 $result = false;
42
43 try
44 {
45 $result = $this->repository->findByCode($formatCode, $languageId);
46 }
47 catch (RuntimeException $exception)
48 {
49 $this->processException($exception);
50 }
51
52 return $result;
53 }
54
61 public function findAll(string $languageId)
62 {
63 $result = false;
64
65 try
66 {
67 $result = $this->repository->findAll($languageId);
68 }
69 catch (RuntimeException $exception)
70 {
71 $this->processException($exception);
72 }
73
74 return $result;
75 }
76
83 public function findDefault(string $languageId)
84 {
85 $result = false;
86
87 try
88 {
89 $result = $this->repository
90 ->findByCode($this->defaultFormatCode, $languageId);
91
92 }
93 catch (RuntimeException $exception)
94 {
95 $this->processException($exception);
96 }
97
98 return $result;
99 }
100
106 public function getDefaultFormatCode(): string
107 {
108 return $this->defaultFormatCode;
109 }
110
115 public function setDefaultFormatCode($defaultFormatCode)
116 {
117 $this->defaultFormatCode = $defaultFormatCode;
118 return $this;
119 }
120
125 protected function __construct(Container $config)
126 {
127 parent::__construct($config);
128 $this->defaultFormatCode = $config->get('defaultFormatCode');
129 $this->setRepository($config->get('repository'));
130 }
131}
processException(\Exception $exception)
findByCode(string $formatCode, string $languageId)