Call a validator handler
@param string $condition_id
@param array $args
@return mixed
480699
protected function validateConditionTrigger($condition_id, array $args)
    {
        try {
            $handlers = $this->condition->getHandlers();
            return static::call($handlers, $condition_id, 'validate', $args);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
334897
public function Base_ConnectData_Handler($Sender, $Args) {
      if (GetValue(0, $Args) != 'openid')
         return;

      $Mode = $Sender->Request->Get('openid_mode');
      if ($Mode != 'id_res')
         return; // this will error out

      $this->EventArguments = $Args;
      
      // Check session before retrieving
      $Session = Gdn::Session();
      $OpenID = $Session->Stash('OpenID', '', FALSE);
      if (!$OpenID)
         $OpenID = $this->GetOpenID();
      
      if ($Session->Stash('OpenID', '', FALSE) || $OpenID->validate()) {
         $Attr = $OpenID->getAttributes();

         $Form = $Sender->Form; //new Gdn_Form();
         $ID = $OpenID->identity;
         $Form->SetFormValue('UniqueID', $ID);
         $Form->SetFormValue('Provider', self::$ProviderKey);
         $Form->SetFormValue('ProviderName', 'OpenID');
         $Form->SetFormValue('FullName', GetValue('namePerson/first', $Attr).' '.GetValue('namePerson/last', $Attr));
         
         if ($Email = GetValue('contact/email', $Attr)) {
            $Form->SetFormValue('Email', $Email);
         }
         
         $Sender->SetData('Verified', TRUE);
         $Session->Stash('OpenID', $OpenID);
      }
   }
912318
static function writeError( $conditionName, $string, $label = "" )
    {
        if ( !eZDebugSetting::isConditionTrue( $conditionName, eZDebug::LEVEL_ERROR ) )
            return false;
        eZDebug::writeError( $string, eZDebugSetting::changeLabel( $conditionName, $label ) );
    }
946646
public static function update($arr, $condition=null, $params=[]) {
        return static::dao()->update(
            $arr,
            $condition,
            $params
        );
    }
574676
protected function callHandler($handler_id, $method, array $arguments)
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $handler_id, $method, $arguments);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
1062335
protected function validateSlug($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if ($value === '') {
            return null;
        }

        if (!Validate::isSlug($value)) {
            return Message::getMessage(Message::SLUG, [
                'param' => $parameter,
                'value' => $value
            ]);
        }

        return null;
    }
527144
public static function call($handlers, $handler_id, $method, $arguments = array())
    {
        $callback = static::get($handlers, $handler_id, $method);
        return call_user_func_array($callback, $arguments);
    }
729587
protected function validateEmail($value, string $parameter, array $args = [], array $rules = null, array $context = null): ?string
    {
        //$value = $this->getValue($parameter);

        if ($value === null) {
            return null;
        }

        if (!is_scalar($value)) {
            return Message::getMessage(Message::PRIMITIVE, [
                'param' => $parameter
            ]);
        }

        $value = trim((string)$value);

        if ($value === '') {
            return null;
        }

        if (!Validate::isEmail($value)) {
            return Message::getMessage(Message::EMAIL, [
                'param' => $parameter,
                'value' => $value
            ]);
        }

        return null;
    }
819493
public function validateConditionsTrigger()
    {
        $field = 'data.conditions';

        if ($this->isExcluded($field)) {
            return null;
        }

        $value = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($value)) {
            $this->unsetSubmitted($field);
            return null;
        }

        $label = $this->translation->text('Conditions');

        if (empty($value)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (!is_array($value)) {
            $this->setErrorInvalid($field, $label);
            return false;
        }

        $submitted = $this->getSubmitted();
        $operators = array_map('htmlspecialchars', array_keys($this->condition->getOperators()));

        $errors = $modified = array();

        foreach ($value as $line => $condition) {

            $line++;

            $parts = gplcart_string_explode_whitespace($condition, 3);
            $condition_id = array_shift($parts);
            $operator = array_shift($parts);
            $parameters = array_filter(explode(',', implode('', $parts)), function ($value) {
                return $value !== '';
            });

            if (empty($parameters)) {
                $errors[] = $line;
                continue;
            }

            if (!in_array(htmlspecialchars($operator), $operators)) {
                $errors[] = $line;
                continue;
            }

            $args = array($parameters, $operator, $condition_id, $submitted);
            $result = $this->validateConditionTrigger($condition_id, $args);

            if ($result !== true) {
                $errors[] = $line;
                continue;
            }

            $modified[] = array(
                'weight' => $line,
                'id' => $condition_id,
                'value' => $parameters,
                'operator' => $operator,
                'original' => "$condition_id $operator " . implode(',', $parameters),
            );
        }

        if (!empty($errors)) {
            $error = $this->translation->text('Error in @num definition', array('@num' => implode(',', $errors)));
            $this->setError($field, $error);
        }

        if ($this->isError()) {
            return false;
        }

        $this->setSubmitted($field, $modified);
        return true;
    }
1226707
function _raiseError($id, $info = array())
    {
        $code = $this->errorCode[$id]['code'];
        $msg = $this->errorCode[$id]['msg'];

        // include info to messages
        if (!empty($info)) {
            $search = array();
            $replace = array();

            foreach ($info as $key => $value) {
                array_push($search, '{' . strtoupper($key) . '}');
                array_push($replace, $value);
            }

            $msg = str_replace($search, $replace, $msg);
        }

        return PEAR::raiseError($msg, $code);
    }
559373
public function push($handler, $condition = '*')
    {
        list($handler, $condition) = $this->resolveHandlerAndCondition($handler, $condition);

        if (!isset($this->handlers[$condition])) {
            $this->handlers[$condition] = [];
        }

        array_push($this->handlers[$condition], $handler);

        return $this->newClause($handler);
    }
99504
public function set($handler_id, array $arguments)
    {
        try {
            $handlers = $this->getHandlers();
            $data = Handler::call($handlers, $handler_id, 'data', $arguments);
            return call_user_func_array(array($this, 'send'), $data);
        } catch (Exception $ex) {
            trigger_error($ex->getMessage());
            return false;
        }
    }
119482
public function getConditionEmptyInputAjaxAction($conditionId)
    {
        if (null !== $response = $this->checkAuth(AdminResources::COUPON, [], AccessManager::VIEW)) {
            return $response;
        }

        $this->checkXmlHttpRequest();

        if (! empty($conditionId)) {
            /** @var ConditionFactory $conditionFactory */
            $conditionFactory = $this->container->get('thelia.condition.factory');
            $inputs = $conditionFactory->getInputsFromServiceId($conditionId);

            if (!$this->container->has($conditionId)) {
                return false;
            }

            if ($inputs === null) {
                return $this->pageNotFound();
            }

            /** @var ConditionInterface $condition */
            $condition = $this->container->get($conditionId);

            $html      = $condition->drawBackOfficeInputs();
            $serviceId = $condition->getServiceId();
        } else {
            $html = '';
            $serviceId = '';
        }

        return $this->render(
            'coupon/condition-input-ajax',
            [
                'inputsDrawn' => $html,
                'conditionServiceId' => $serviceId,
                'conditionIndex' => ''
            ]
        );
    }
1357028
public function status($status, array $args = []): PostTypeInterface
    {
        if (is_array($status)) {
            foreach ($status as $key => $params) {
                if (is_int($key)) {
                    $this->status($params);
                } elseif (is_string($key) && is_array($params)) {
                    $this->status($key, $params);
                }
            }

            return $this;
        }

        $this->prepareStatus($status, $args);

        return $this;
    }
186256
protected function makeWhere(Condition $condition, array $data = NULL)
    {
        $data = $data === NULL
            ? $this->data
            : $data;

        return array_filter($data, function ($row) use ($condition) {
            if ($condition->callback) {
                return call_user_func_array($condition->callback, [$condition->value, $row]);
            }

            $i = 0;
            $results = [];
            foreach ($condition->column as $column) {
                if (Condition::isOperator($column)) {
                    $results[] = " $column ";

                } else {
                    $i = count($condition->condition) > 1 ? $i : 0;
                    $results[] = (int) $this->compare(
                        $row[$column],
                        $condition->condition[$i],
                        isset($condition->value[$i]) ? $condition->value[$i] : NULL
                    );

                    $i++;
                }
            }

            $result = implode('', $results);
            return count($condition->column) === 1
                ? (bool) $result
                : eval("return $result;"); // QUESTION: How to remove this eval? hmmm?
        });
    }
364371
private static function handleConditions($conditionArray) {
        $return = '';
        $i = 0;
        foreach($conditionArray as $key => $value) {
            if(is_numeric($key)) {
                $key = self::$_ops->addBackticks(substr($value, 1));
            }
            $key = self::sanitizeKey($key);
            $val = self::$_ops->operandi($value, false, $key);
            $return .= ($i > 0 ? "  AND " : ' WHERE ') . self::$_ops->addBackticks($key) . $val;
            $i++;
        }
        return $return;
    }
841296
protected function validateElement($field, $handler_id, $arguments = array())
    {
        if (is_array($field)) {
            $label = reset($field);
            $field = key($field);
        }

        $options = array(
            'field' => $field,
            'arguments' => (array) $arguments,
            'label' => empty($label) ? $this->text('Field') : $label
        );

        $result = $this->validator->run($handler_id, $this->submitted, $options);

        if ($result === true) {
            return true;
        }

        settype($result, 'array');
        $this->errors = gplcart_array_merge($this->errors, $result);
        return false;
    }