getRules() public method

public getRules ( ) : array
return array
Example #1
0
 /**
  * @param Condition $condition
  * @param array $params
  * @param string $objectKey
  * @param array $usedFieldNames
  *
  * @return string
  */
 public function standardConditionToSql(Condition $condition, &$params, $objectKey, array &$usedFieldNames = null)
 {
     if (!$condition->getRules()) {
         return '';
     }
     $rules = $condition->getRules();
     //        $tableName = null;
     //        $def = null;
     //
     //        if ($objectKey) {
     //            $def = $this->getJarves()->getObjects()->getDefinition($objectKey);
     //            if ($def) {
     //                $tableName = $def->getTable();
     //            }
     //        }
     //
     //        if (!$tableName) {
     //            $tableName = $objectKey;
     //        }
     if (is_array($rules) && !is_numeric(key($rules))) {
         //array( 'bla' => 'hui' );
         return $this->standardConditionToSql(Condition::create($this->primaryKeyToCondition($rules, $objectKey), $this->jarves), $params, $objectKey, $usedFieldNames);
     }
     if (isset($rules[0]) && is_array($rules[0]) && !is_numeric(key($rules[0]))) {
         //array( array('bla' => 'bla', ... );
         return $this->standardConditionToSql(Condition::create($this->primaryKeyToCondition($rules, $objectKey), $this->jarves), $params, $objectKey, $usedFieldNames);
     }
     if (!is_array($rules[0]) && !$rules[0] instanceof Condition) {
         //array( 1, 2, 3 );
         return $this->standardConditionToSql(Condition::create($this->primaryKeyToCondition($rules, $objectKey), $this->jarves), $params, $objectKey, $usedFieldNames);
     }
     return $this->conditionToSql($condition, $rules, $params, $objectKey, $usedFieldNames);
 }
Example #2
0
 /**
  * Propel uses for his nested-set objects `lft` and `rgt` fields.
  * So we include with this condition all entries 'inside' the entry
  * defined through $condition.
  *
  * @param Condition $condition
  * @return Condition
  */
 public function getNestedSubCondition(Condition $condition)
 {
     $result = new Condition(null, $this->jarves);
     $sub = new ConditionSubSelect(null, $this->jarves);
     $sub->select('sub.lft');
     $sub->addSelfJoin('sub', 'sub.lft BETWEEN %table%.lft+1 AND %table%.rgt-1');
     $sub->setRules($condition->getRules());
     $subCondition = new Condition();
     $subCondition->addAnd(['lft', 'IN', $sub]);
     $result->addAnd($subCondition);
     return $result;
 }
Example #3
0
 /**
  * @param Condition|array $condition
  *
  * @return array
  */
 private function normalizeToArray($condition)
 {
     if (!$condition) {
         return [];
     }
     if ($condition instanceof Condition) {
         return $condition->getRules();
     } else {
         if (!is_array($condition[0]) && !$condition[0] instanceof Condition) {
             $condition = [$condition];
         }
         return $condition;
     }
 }