Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
PropertyFeatureRepository.php
1<?php
2
4
9
19{
21 protected $factory;
22
24 {
25 $this->factory = $factory;
26 }
27
28 public function getEntityById(int $id)
29 {
30 return $this->getEntitiesBy([
31 'filter' => ['=ID' => $id],
32 'limit' => 1,
33 ]);
34 }
35
36 public function getEntitiesBy($params)
37 {
38 return PropertyFeatureTable::getList($params)->fetchAll();
39 }
40
41 public function save(BaseEntity ...$entities): Result
42 {
43 return new Result();
44 }
45
46 public function delete(BaseEntity ...$entities): Result
47 {
48 return new Result();
49 }
50
52 {
53 $collection = $this->factory->createCollection();
54
55 $featureSettings = $this->getEntitiesBy([
56 'filter' => ['=PROPERTY_ID' => $entity->getId()],
57 ]);
58
59 foreach ($featureSettings as $settings)
60 {
61 $feature = $this->createEntity();
62 $feature->setSettings($settings);
63 $collection->add($feature);
64 }
65
66 return $collection;
67 }
68
69 protected function createEntity(array $fields = []): PropertyFeature
70 {
71 $entity = $this->factory->createEntity();
72
73 $entity->initFields($fields);
74
75 return $entity;
76 }
77}