function checkColumnName($columnName) { $columnName = Torpor::containerKeyName($columnName); if (!$this->hasColumn($columnName)) { throw new TorporException($columnName . ' is not a valid member of this Grid'); } return $columnName; }
protected function processArgs(array $args) { $flatArgs = array(); while (count($args)) { $arg = array_shift($args); if (is_array($arg)) { $args = array_merge($arg, $args); } else { $flatArgs[] = $arg; } } $preppedArgs = array(); for ($i = 0; $i < count($flatArgs); $i++) { if ($this->isColumnTarget() && $i < count($flatArgs) - 1) { $grid = null; $column = null; if ($flatArgs[$i] instanceof Column) { $grid = Torpor::containerKeyName($flatArgs[$i]->Grid()); $column = Torpor::containerKeyName($flatArgs[$i]); } else { $grid = Torpor::containerKeyName($flatArgs[$i++]); if (!isset($flatArgs[$i])) { throw new TorporException('Grid/Column count mismatch in criteria type ' . $this->getType()); } $column = Torpor::containerKeyName($flatArgs[$i]); } $preppedArgs[] = array($grid, $column); } else { $preppedArgs[] = $flatArgs[$i]; } } $preppedArgCount = count($preppedArgs); $argCountException = new TorporException('Invalid argument count for type ' . $this->getType()); switch ($this->getBaseType()) { case self::TYPE_BETWEEN: if ($preppedArgCount < 2 || $preppedArgCount > 3) { throw $argCountException; } $preppedArgs[] = false; // Default for "inclusive" list($rangeOne, $rangeTwo, $inclusive) = $preppedArgs; $this->addArgument($rangeOne); $this->addArgument($rangeTwo); $this->setInclusive($inclusive); break; case self::TYPE_STARTSWITH: case self::TYPE_CONTAINS: case self::TYPE_ENDSWITH: case self::TYPE_EQUALS: if ($preppedArgCount < 1 || $preppedArgCount > 2) { throw $argCountException; } $preppedArgs[] = false; // Default for "case insensitive" list($targetValue, $caseInsensitive) = $preppedArgs; $this->addArgument($targetValue); $this->setCaseInsensitive($caseInsensitive); break; case self::TYPE_GREATERTHAN: case self::TYPE_LESSTHAN: if ($preppedArgCount < 1 || $preppedArgCount > 2) { throw $argCountException; } $preppedArgs[] = false; // Default for "inclusive" list($targetValue, $inclusive) = $preppedArgs; $this->addArgument($targetValue); $this->setInclusive($inclusive); break; case self::TYPE_CUSTOM: $this->setCustom(array_shift($preppedArgs)); case self::TYPE_IN: if ($preppedArgCount < 1) { throw $argCountException; } foreach ($preppedArgs as $arg) { $this->addArgument($arg); } break; case self::TYPE_IN_SET: if ($preppedArgCount > 2) { throw $argCountException; } $preppedArgs[] = false; // Default for "inclusive" // "inclusive" for gridSet has special meaning. If set // to true, it will be used by the data store to compute // the entire possible affected set and not just the loaded // portion (or calculated page offset) of the target gridSet list($set, $inclusive) = $preppedArgs; if (!$set instanceof GridSet) { throw new TorporException('Argument for ' . $this->getType() . ' criteria type must be an instance of GridSet'); } $this->setInclusive($inclusive); $this->addArgument($set); break; case self::TYPE_PATTERN: if ($preppedArgCount < 1 || $preppedArgCount > 2) { throw $argCountException; } $preppedArgs[] = false; // Default for "case insensitive" list($regex, $caseInsensitive) = $preppedArgs; $this->addArgument($regex); $this->setCaseInsensitive($caseInsensitive); break; case null: default: throw new TorporException('Type invalid or not set'); break; } }