本文整理汇总了PHP中Sonata\AdminBundle\Datagrid\ProxyQueryInterface::field方法的典型用法代码示例。如果您正苦于以下问题:PHP ProxyQueryInterface::field方法的具体用法?PHP ProxyQueryInterface::field怎么用?PHP ProxyQueryInterface::field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\AdminBundle\Datagrid\ProxyQueryInterface
的用法示例。
在下文中一共展示了ProxyQueryInterface::field方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter
/**
* @param ProxyQueryInterface $queryBuilder
* @param string $alias
* @param string $field
* @param mixed $data
*
* @return
*/
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
if (!$data || !is_array($data) || !array_key_exists('type', $data) || !array_key_exists('value', $data)) {
return;
}
if (is_array($data['value'])) {
$values = array();
foreach ($data['value'] as $v) {
if (!in_array($v, array(BooleanType::TYPE_NO, BooleanType::TYPE_YES))) {
continue;
}
$values[] = $v == BooleanType::TYPE_YES ? true : false;
}
if (count($values) == 0) {
return;
}
$queryBuilder->field($field)->in($values);
$this->active = true;
} else {
if (!in_array($data['value'], array(BooleanType::TYPE_NO, BooleanType::TYPE_YES))) {
return;
}
$value = BooleanType::TYPE_YES == $data['value'] ? true : false;
$queryBuilder->field($field)->equals($value);
$this->active = true;
}
}
示例2: filter
/**
* @param ProxyQueryInterface $queryBuilder
* @param string $alias
* @param string $field
* @param mixed $data
* @return
*/
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
if (!$data || !is_array($data) || !array_key_exists('type', $data) || !array_key_exists('value', $data)) {
return;
}
if (is_array($data['value'])) {
if (count($data['value']) == 0) {
return;
}
if (in_array('all', $data['value'])) {
return;
}
if ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
$queryBuilder->field($field)->notIn($data['value']);
} else {
$queryBuilder->field($field)->in($data['value']);
}
$this->active = true;
} else {
if ($data['value'] === '' || $data['value'] === null || $data['value'] === false || $data['value'] === 'all') {
return;
}
if ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
$queryBuilder->field($field)->notEqual($data['value']);
} else {
$queryBuilder->field($field)->equals($data['value']);
}
$this->active = true;
}
}
示例3: handleScalar
/**
*
* @param ProxyQueryInterface $queryBuilder
* @param type $alias
* @param type $field
* @param type $data
* @return type
*/
protected function handleScalar(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
if (empty($data['value'])) {
return;
}
$id = self::fixIdentifier($data['value']->getId());
if (isset($data['type']) && $data['type'] == EqualType::TYPE_IS_NOT_EQUAL) {
$queryBuilder->field($field)->notEqual($id);
} else {
$queryBuilder->field($field)->equals($id);
}
$this->active = true;
}
示例4: applyTypeIsEqual
/**
* Because we lack a second variable we select a range covering the entire minute.
*
* @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $queryBuilder
* @param string $field
* @param array $data
*/
protected function applyTypeIsEqual(ProxyQueryInterface $queryBuilder, $field, $data)
{
/** @var \DateTime $end */
$end = clone $data['value'];
$end->add(new \DateInterval('PT1M'));
$queryBuilder->field($field)->range($data['value'], $end);
}
示例5: 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;
if ($data['type'] == ChoiceType::TYPE_EQUAL) {
$queryBuilder->field($field)->equals($data['value']);
} elseif ($data['type'] == ChoiceType::TYPE_CONTAINS) {
$queryBuilder->field($field)->equals(new \MongoRegex(sprintf('/%s/i', $data['value'])));
} elseif ($data['type'] == ChoiceType::TYPE_NOT_CONTAINS) {
$queryBuilder->field($field)->not(new \MongoRegex(sprintf('/%s/i', $data['value'])));
}
$this->active = true;
}
示例6: filter
/**
* @param ProxyQueryInterface $queryBuilder
* @param string $alias
* @param string $field
* @param string $data
* @return
*/
public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $data)
{
if (!$data || !is_array($data) || !array_key_exists('value', $data) || !is_numeric($data['value'])) {
return;
}
$type = isset($data['type']) ? $data['type'] : false;
$operator = $this->getOperator($type);
if (!$operator) {
$operator = 'equals';
}
$queryBuilder->field($field)->{$operator}((double) $data['value']);
$this->active = true;
}
示例7: applyType
/**
* @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $queryBuilder
* @param string $operation
* @param string $field
* @param \DateTime $datetime
*/
protected function applyType(ProxyQueryInterface $queryBuilder, $operation, $field, \DateTime $datetime = null)
{
$queryBuilder->field($field)->{$operation}($datetime);
$this->active = true;
}