diff --git a/examples/Module.php b/examples/Module.php index 9c4ef79f..8a9c4a92 100644 --- a/examples/Module.php +++ b/examples/Module.php @@ -5,6 +5,7 @@ use Craft; use craft\base\conditions\BaseCondition; use craft\events\RegisterConditionRulesEvent; +use modules\conditions\segments\ContactIsAttendingConditionRule; use modules\conditions\segments\ContactIsUserConditionRule; use modules\conditions\sendouts\LastEntryHasImageConditionRule; use modules\conditions\sendouts\MondayMorningSendoutConditionRule; @@ -26,6 +27,7 @@ public function init(): void BaseCondition::EVENT_REGISTER_CONDITION_RULES, function(RegisterConditionRulesEvent $event) { $event->conditionRules[] = ContactIsUserConditionRule::class; + $event->conditionRules[] = ContactIsAttendingConditionRule::class; } ); diff --git a/examples/conditions/segments/ContactIsAttendingConditionRule.php b/examples/conditions/segments/ContactIsAttendingConditionRule.php new file mode 100644 index 00000000..9762723c --- /dev/null +++ b/examples/conditions/segments/ContactIsAttendingConditionRule.php @@ -0,0 +1,68 @@ +section('rsvp') + ->one(); + + $ids = $rsvp->attending->ids(); + + $query->andWhere([ + 'id' => $ids, + ]); + } + + /** + * @inheritdoc + */ + public function matchElement(ElementInterface $element): bool + { + return true; + } + + /** + * @inheritdoc + */ + protected function inputHtml(): string + { + return ''; + } +}