コード例 #1
0
ファイル: Filter.php プロジェクト: pepakriz/grido
 /**
  * @param string $value
  * @return Condition
  * @throws \Exception
  * @internal
  */
 public function __getCondition($value)
 {
     if ($value === '' || $value === NULL) {
         return FALSE;
         //skip
     }
     $condition = $this->getCondition();
     if ($this->where !== NULL) {
         $condition = Condition::setupFromCallback($this->where, $value);
     } else {
         if (is_string($condition)) {
             $condition = Condition::setup($this->getColumn(), $condition, $this->formatValue($value));
         } elseif ($condition instanceof Condition) {
             $condition = $condition;
         } elseif (is_callable($condition)) {
             $condition = callback($condition)->invokeArgs(array($value));
         } elseif (is_array($condition)) {
             $condition = isset($condition[$value]) ? $condition[$value] : Condition::setupEmpty();
         }
     }
     if (is_array($condition)) {
         //for user-defined condition by array or callback
         $condition = Condition::setupFromArray($condition);
     } elseif ($condition !== NULL && !$condition instanceof Condition) {
         $type = gettype($condition);
         throw new \InvalidArgumentException("Condition must be array or Condition object. {$type} given.");
     }
     return $condition;
 }
コード例 #2
0
ファイル: Date.php プロジェクト: cujan/atlashornin
 /**
  * @param string $value
  * @return Condition
  * @throws \Exception
  * @internal
  */
 public function __getCondition($value)
 {
     if ($this->where === NULL && is_string($this->condition)) {
         return ($date = \DateTime::createFromFormat($this->dateFormatInput, $value)) ? Condition::setupFromArray(array($this->getColumn(), $this->condition, $date->format($this->dateFormatOutput))) : Condition::setupEmpty();
     }
     return parent::__getCondition($value);
 }