Added new methods:
[core.git] / inc / classes / main / criteria / class_BaseCriteria.php
index 1abb7afe9f531fc8089f085bbf79a4fd30b28434..6c3e7d059fc66e8b0e3c55894561c1403a1d1584 100644 (file)
@@ -177,6 +177,32 @@ class BaseCriteria extends BaseFrameworkSystem implements Criteria {
                $this->appendStringToGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
        }
 
+       /**
+        * Set criteria, this method converts dashes to underscores because dashes
+        * are not valid for criteria keys.
+        *
+        * @param       $criteriaKey    Criteria key
+        * @param       $criteriaValue  Criteria value
+        * @param       $criteriaType   Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
+        * @return      void
+        */
+       public final function setCriteria ($criteriaKey, $criteriaValue, $criteriaType = 'default') {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue . ',criteriaType=' . $criteriaType . ' - CALLED!');
+
+               // Make sure no 'my-' or 'my_' passes this point
+               assert((strpos($criteriaKey, 'my-') === FALSE) && (strpos($criteriaKey, 'my_') === FALSE) && (!is_bool($criteriaValue)));
+
+               // Convert dashes to underscore
+               $criteriaKey = self::convertDashesToUnderscores($criteriaKey);
+
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA[' . __METHOD__ . ':' . __LINE__ . ']: criteriaKey=' . $criteriaKey);
+
+               // Set it
+               $this->setStringGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey, $criteriaValue);
+       }
+
        /**
         * Add "choice" criteria, this method converts dashes to underscores because
         * dashes are not valid for criteria keys.