本文整理匯總了PHP中Sonata\AdminBundle\Datagrid\ProxyQueryInterface::addOr方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProxyQueryInterface::addOr方法的具體用法?PHP ProxyQueryInterface::addOr怎麽用?PHP ProxyQueryInterface::addOr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Sonata\AdminBundle\Datagrid\ProxyQueryInterface
的用法示例。
在下文中一共展示了ProxyQueryInterface::addOr方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: filter
/**
* @param ProxyQueryInterface $queryBuilder
* @param string $alias
* @param string $field
* @param string $data
*
* @return
*/
public function filter(ProxyQueryInterface $queryBuilder, $name, $field, $data)
{
if (!$data || !is_array($data) || !array_key_exists('value', $data)) {
return;
}
$data['value'] = trim($data['value']);
if (strlen($data['value']) == 0) {
return;
}
$data['type'] = isset($data['type']) && !empty($data['type']) ? $data['type'] : ChoiceType::TYPE_CONTAINS;
$obj = $queryBuilder;
if ($this->condition == self::CONDITION_OR) {
$obj = $queryBuilder->expr();
}
if ($data['type'] == ChoiceType::TYPE_EQUAL) {
$obj->field($field)->equals($data['value']);
} elseif ($data['type'] == ChoiceType::TYPE_CONTAINS) {
$obj->field($field)->equals(new \MongoRegex(sprintf('/%s/i', $data['value'])));
} elseif ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
$obj->field($field)->not(new \MongoRegex(sprintf('/%s/i', $data['value'])));
}
if ($this->condition == self::CONDITION_OR) {
$queryBuilder->addOr($obj);
}
$this->active = true;
}