File tree Expand file tree Collapse file tree 2 files changed +69
-0
lines changed
Expand file tree Collapse file tree 2 files changed +69
-0
lines changed Original file line number Diff line number Diff line change 2020use statikbe \configvaluesfield \assetbundles \configvalues \ConfigValuesAsset ;
2121use statikbe \configvaluesfield \ConfigValuesField ;
2222
23+
2324/**
2425 * @author Statik.be
2526 * @package ConfigValuesField
@@ -216,4 +217,9 @@ private function getOptions(): array
216217
217218 return $ data ;
218219 }
220+
221+ public function getElementConditionRuleType (): array |string |null
222+ {
223+ return ConfigValuesFieldConditionRule::class;
224+ }
219225}
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace statikbe \configvaluesfield \fields \conditions ;
4+
5+ use statikbe \configvaluesfield \ConfigValuesField ;
6+ use craft \base \conditions \BaseMultiSelectConditionRule ;
7+ use craft \fields \conditions \FieldConditionRuleInterface ;
8+ use craft \fields \conditions \FieldConditionRuleTrait ;
9+ use statikbe \configvaluesfield \fields \ConfigValuesFieldField ;
10+ use yii \base \InvalidConfigException ;
11+
12+ class ConfigValuesFieldConditionRule extends BaseMultiSelectConditionRule implements FieldConditionRuleInterface
13+ {
14+ use FieldConditionRuleTrait;
15+
16+ /**
17+ * @inheritdoc
18+ */
19+ protected function options (): array
20+ {
21+ if (!$ this ->field () instanceof ConfigValuesFieldField) {
22+ return [];
23+ }
24+
25+ return ConfigValuesField::getInstance ()->getSettings ()->data [$ this ->field ()->dataSet ];
26+ }
27+
28+ /**
29+ * @inheritdoc
30+ */
31+ protected function inputHtml (): string
32+ {
33+ if (!$ this ->field () instanceof ConfigValuesFieldField) {
34+ throw new InvalidConfigException ();
35+ }
36+
37+ return parent ::inputHtml ();
38+ }
39+
40+ /**
41+ * @inheritdoc
42+ */
43+ protected function elementQueryParam (): ?array
44+ {
45+ if (!$ this ->field () instanceof ConfigValuesFieldField) {
46+ return null ;
47+ }
48+
49+ return $ this ->paramValue ();
50+ }
51+
52+ /**
53+ * @inheritdoc
54+ */
55+ protected function matchFieldValue ($ value ): bool
56+ {
57+ if (!$ this ->field () instanceof ConfigValuesFieldField) {
58+ return true ;
59+ }
60+
61+ return $ this ->matchValue ($ value );
62+ }
63+ }
You can’t perform that action at this time.
0 commit comments