PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Services/FieldOptions/FieldOptionsService.php +11 -17 0.4 → 1.5 View file →
@@ -1,14 +1,8 @@
1 1 <?php
2 2
3 3 namespace IvyForms\Services\FieldOptions;
4 4
5 -// phpcs:disable PSR1.Files.SideEffects
6 -if (!defined('ABSPATH')) {
7 - exit; // Exit if accessed directly
8 -}
9 -
10 -
11 5 use IvyForms\Common\Exceptions\InvalidArgumentException;
12 6 use IvyForms\Repository\FieldOptions\FieldOptionsRepositoryInterface;
13 7 use IvyForms\Entity\FieldOptions\FieldOptions;
14 8
@@ -16,16 +10,16 @@
16 10 {
17 11 /**
18 12 * @var FieldOptionsRepositoryInterface
19 13 */
20 - private FieldOptionsRepositoryInterface $repository;
14 + private FieldOptionsRepositoryInterface $fieldOptionsRepository;
21 15
22 16 /**
23 - * @param FieldOptionsRepositoryInterface $repository
17 + * @param FieldOptionsRepositoryInterface $fieldOptionsRepository
24 18 */
25 - public function __construct(FieldOptionsRepositoryInterface $repository)
19 + public function __construct(FieldOptionsRepositoryInterface $fieldOptionsRepository)
26 20 {
27 - $this->repository = $repository;
21 + $this->fieldOptionsRepository = $fieldOptionsRepository;
28 22 }
29 23
30 24 /**
31 25 * @param FieldOptions $option
@@ -32,9 +26,9 @@
32 26 * @return int
33 27 */
34 28 public function addOption(FieldOptions $option): int
35 29 {
36 - return $this->repository->add($option);
30 + return $this->fieldOptionsRepository->add($option);
37 31 }
38 32
39 33 /**
40 34 * Batch add FieldOptions entities.
@@ -42,9 +36,9 @@
42 36 * @return array<int> Inserted IDs
43 37 */
44 38 public function addOptions(array $options): array
45 39 {
46 - return $this->repository->addMany($options);
40 + return $this->fieldOptionsRepository->addMany($options);
47 41 }
48 42
49 43 /**
50 44 * @param FieldOptions $option
@@ -51,9 +45,9 @@
51 45 * @return bool
52 46 */
53 47 public function updateOption(FieldOptions $option): bool
54 48 {
55 - return $this->repository->update($option->getId(), $option);
49 + return $this->fieldOptionsRepository->update($option->getId(), $option);
56 50 }
57 51
58 52 /**
59 53 * Batch update FieldOptions entities.
@@ -61,9 +55,9 @@
61 55 * @return int Number of updated rows
62 56 */
63 57 public function updateOptions(array $options): int
64 58 {
65 - return $this->repository->updateMany($options);
59 + return $this->fieldOptionsRepository->updateMany($options);
66 60 }
67 61
68 62 /**
69 63 * @param int $fieldId
@@ -70,9 +64,9 @@
70 64 * @return bool
71 65 */
72 66 public function deleteOptionsByFieldId(int $fieldId): bool
73 67 {
74 - return $this->repository->deleteByFieldId($fieldId);
68 + return $this->fieldOptionsRepository->deleteByFieldId($fieldId);
75 69 }
76 70
77 71 /**
78 72 * Delete all options for multiple field IDs in one query.
@@ -84,9 +78,9 @@
84 78 {
85 79 if (empty($fieldIds)) {
86 80 return 0;
87 81 }
88 - return $this->repository->deleteManyByForeignKeyValues($fieldIds, 'fieldId');
82 + return $this->fieldOptionsRepository->deleteByFieldIds($fieldIds);
89 83 }
90 84
91 85 /**
92 86 * @param int $fieldId
@@ -93,7 +87,7 @@
93 87 * @return array<FieldOptions>
94 88 */
95 89 public function getByFieldId(int $fieldId): array
96 90 {
97 - return $this->repository->getByFieldId($fieldId);
91 + return $this->fieldOptionsRepository->getByFieldId($fieldId);
98 92 }
99 93 }