1
0
mirror of synced 2024-11-22 21:36:10 +03:00
bitrix-module/intaro.retailcrm/lib/repository/hlrepository.php

68 lines
1.5 KiB
PHP
Raw Normal View History

2021-05-31 16:33:02 +03:00
<?php
/**
* @category Integration
* @package Intaro\RetailCrm\Repository
* @author RetailCRM <integration@retailcrm.ru>
* @license MIT
* @link http://retailcrm.ru
* @see http://retailcrm.ru/docs
*/
2021-05-31 16:33:02 +03:00
namespace Intaro\RetailCrm\Repository;
use Bitrix\Main\ArgumentException;
use Bitrix\Main\ObjectPropertyException;
use Bitrix\Main\SystemException;
use Intaro\RetailCrm\Service\Hl;
2021-09-08 10:05:09 +03:00
use Logger;
2021-05-31 16:33:02 +03:00
/**
* Class HlRepository
* @package Intaro\RetailCrm\Repository
*/
class HlRepository
{
/**
* @var \Bitrix\Main\Entity\DataManager|string|null
*/
private $hl;
public function __construct($hlName)
{
$this->hl = Hl::getHlClassByTableName($hlName);
}
/**
* @param string|null $propertyValue
* @return array|null
*/
public function getDataByXmlId(?string $propertyValue): ?array
{
try {
$result = $this->hl::query()
->setSelect(['*'])
->where('UF_XML_ID', '=', $propertyValue)
->fetch();
if ($result === false) {
return null;
}
return $result;
} catch (ObjectPropertyException | ArgumentException | SystemException $exception) {
2021-09-08 10:05:09 +03:00
Logger::getInstance()->write($exception->getMessage(), 'repositoryErrors');
2021-05-31 16:33:02 +03:00
return null;
}
}
/**
* @return \Bitrix\Main\Entity\DataManager|string|null
*/
public function getHl()
{
return $this->hl;
}
}