Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/location/lib/service/ |
Upload File : |
<?php namespace Bitrix\Location\Service; use Bitrix\Location\Common\RepositoryTrait; use \Bitrix\Location\Entity; use Bitrix\Location\Exception\RuntimeException; use Bitrix\Location\Common\BaseService; use Bitrix\Location\Infrastructure\Service\Config\Container; use Bitrix\Location\Repository\FormatRepository; /** * Class FormatService * * Service to work with addresses formats * * @package Bitrix\Location\Service */ final class FormatService extends BaseService { use RepositoryTrait; /** @var FormatService */ protected static $instance; /** @var string */ private $defaultFormatCode; /** @var FormatRepository */ protected $repository; /** * Find format by format code * * @param string $formatCode * @param string $languageId * @return Entity\Format|null|bool */ public function findByCode(string $formatCode, string $languageId) { $result = false; try { $result = $this->repository->findByCode($formatCode, $languageId); } catch (RuntimeException $exception) { $this->processException($exception); } return $result; } /** * Find all existing formats * * @param string $languageId * @return array|bool */ public function findAll(string $languageId) { $result = false; try { $result = $this->repository->findAll($languageId); } catch (RuntimeException $exception) { $this->processException($exception); } return $result; } /** * Find default (current) format * * @param string $languageId * @return Entity\Format|bool|null */ public function findDefault(string $languageId) { $result = false; try { $result = $this->repository ->findByCode($this->defaultFormatCode, $languageId); } catch (RuntimeException $exception) { $this->processException($exception); } return $result; } /** * Returns default (current) format code * * @return string */ public function getDefaultFormatCode(): string { return $this->defaultFormatCode; } /** * @param string $defaultFormatCode * @return FormatService */ public function setDefaultFormatCode($defaultFormatCode) { $this->defaultFormatCode = $defaultFormatCode; return $this; } /** * FormatService constructor. * @param Container $config */ protected function __construct(Container $config) { parent::__construct($config); $this->defaultFormatCode = $config->get('defaultFormatCode'); $this->setRepository($config->get('repository')); } }