Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sourcerepository.php
1<?php
2
4
7
14{
16 private $ormConverter;
17
22 public function __construct(Source\OrmConverter $ormConverter)
23 {
24 $this->ormConverter = $ormConverter;
25 }
26
33 public function findAll(): array
34 {
35 $result = [];
36
37 $queryResult = SourceTable::getList();
38
39 while ($ormSource = $queryResult->fetchObject())
40 {
41 $result[] = $this->ormConverter->convertFromOrm($ormSource);
42 }
43
44 return $result;
45 }
46
54 public function findByCode(string $code): ?Source
55 {
56 $result = null;
57
58 $ormSource = SourceTable::getList(
59 [
60 'filter' => [
61 '=CODE' => $code
62 ],
63 'limit' => 1,
64 ]
65 )->fetchObject();
66
67 if (!$ormSource)
68 {
69 return null;
70 }
71
72 return $this->ormConverter->convertFromOrm($ormSource);
73 }
74
82 public function save(Source $source)
83 {
84 return $this->ormConverter->convertToOrm($source)->save();
85 }
86}
__construct(Source\OrmConverter $ormConverter)