[TASK] Implenent *ContainsValueFromField comparison operations
authorOliver Eglseder <oliver.eglseder@in2code.de>
Tue, 8 Sep 2015 14:22:36 +0000 (16:22 +0200)
committerOliver Eglseder <oliver.eglseder@in2code.de>
Tue, 8 Sep 2015 14:22:36 +0000 (16:22 +0200)
Classes/Domain/Comparator/Comparator.php
Classes/Domain/Model/Rule.php

index 1804815..dc6febf 100644 (file)
@@ -87,6 +87,9 @@ class Comparator {
         * @return bool
         */
        public function operationContainsValue($left, $right) {
+               if ($right === '') {
+                       return FALSE;
+               }
                if (is_array($left)) {
                        return in_array($right, $left);
                }
@@ -139,11 +142,11 @@ class Comparator {
        }
 
 
-       public function operationContainsValueFromField($left, $right) {
-               throw new \Exception('NOT YET IMPLEMENTED', 1441276049);
+       public function operationContainsValueFromField($left, $right, $field) {
+               return $this->operationContainsValue($left, $field->getText());
        }
 
-       public function operationNotContainsValueFromField($left, $right) {
-               throw new \Exception('NOT YET IMPLEMENTED', 1441276053);
+       public function operationNotContainsValueFromField($left, $right, $field) {
+               return $this->operationNotContainsValue($left, $field->getText());
        }
 }
index ae4ff02..dce9cd9 100644 (file)
@@ -183,9 +183,18 @@ class Rule extends AbstractEntity {
                foreach ($form->getPages() as $page) {
                        /** @var Field $field */
                        foreach ($page->getFields() as $field) {
+                               if ($field->getUid() === (int) $this->equalField) {
+                                       $equalField = $field;break;
+                               }
+                       }
+               }
+               /** @var Page $page */
+               foreach ($form->getPages() as $page) {
+                       /** @var Field $field */
+                       foreach ($page->getFields() as $field) {
                                if ($field === $this->startField) {
                                        $comparison = $comparator->getCallbackForOperator($this->ops);
-                                       if ($comparison($field->getText(), $this->condString)) {
+                                       if ($comparison($field->getText(), $this->condString, $equalField)) {
                                                return TRUE;
                                        }
                                }