本文整理汇总了PHP中Sonata\AdminBundle\Datagrid\ProxyQueryInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ProxyQueryInterface类的具体用法?PHP ProxyQueryInterface怎么用?PHP ProxyQueryInterface使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProxyQueryInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: association
/**
* {@inheritdoc}
*/
protected function association(ProxyQueryInterface $queryBuilder, $data)
{
$associationMappings = $this->getParentAssociationMappings();
$associationMappings[] = $this->getAssociationMapping();
$alias = $queryBuilder->entityJoin($associationMappings);
return array($alias, false);
}
示例2: filter
/**
* {@inheritdoc}
*/
public function filter(ProxyQueryInterface $query, $alias, $field, $data)
{
if (!$data || !is_array($data) || !array_key_exists('type', $data) || !array_key_exists('value', $data)) {
return;
}
$data['type'] = !isset($data['type']) ? ChoiceType::TYPE_CONTAINS : $data['type'];
list($firstOperator, $secondOperator) = $this->getOperators((int) $data['type']);
if (is_array($data['value'])) {
if (count($data['value']) == 0) {
return;
}
if (in_array('all', $data['value'], true)) {
return;
}
$queryBuilder = new \Elastica\Query\Builder();
$queryBuilder->fieldOpen($secondOperator)->field($field, Util::escapeTerm($data['value']))->fieldClose();
if ($firstOperator == 'must') {
$query->addMust($queryBuilder);
} else {
$query->addMustNot($queryBuilder);
}
} else {
if ($data['value'] === '' || $data['value'] === null || $data['value'] === false || $data['value'] === 'all') {
return;
}
$queryBuilder = new \Elastica\Query\Builder();
$queryBuilder->fieldOpen($secondOperator)->field($field, Util::escapeTerm(array($data['value'])))->fieldClose();
if ($firstOperator == 'must') {
$query->addMust($queryBuilder);
} else {
$query->addMustNot($queryBuilder);
}
}
}
示例3: 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;
}
}
示例4: 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;
}
示例5: 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;
}
}
示例6: batchActionActivate
public function batchActionActivate(ProxyQueryInterface $selectedModelQuery)
{
$users = $selectedModelQuery->execute();
$modelManager = $this->admin->getModelManager();
$hostname = $this->container->getParameter('hostname');
$hostDirectory = $this->container->getParameter('directory');
try {
foreach ($users as $user) {
$userIsLocked = $user->isLocked();
if ($userIsLocked == true) {
$user->setEnabled(true);
$user->setLocked(false);
if (null === $user->getConfirmationToken()) {
$tokenGenerator = $this->container->get("fos_user.util.token_generator");
$user->setConfirmationToken($tokenGenerator->generateToken());
}
$user->setPasswordRequestedAt(new \DateTime('now'));
$modelManager->update($user);
$activationUrl = $hostname . $hostDirectory . "resetting/reset/" . $user->getConfirmationToken();
$message = \Swift_Message::newInstance()->setSubject('Welcome to Zeega!')->setFrom(array('noreply@zeega.org' => 'Zeega'))->setTo($user->getEmail())->setBody($this->renderView('ZeegaAdminBundle:Users:account_activated.txt.twig', array('username' => $user->getDisplayName(), 'activationURL' => $activationUrl)));
$this->get('mailer')->send($message);
}
}
} catch (\Exception $e) {
$this->get('session')->setFlash('sonata_flash_error', 'Something went wrong...');
return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
}
$this->get('session')->setFlash('sonata_flash_success', 'The users were activated successfully.');
return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
}
示例7: filter
/**
* {@inheritdoc}
*/
public function filter(ProxyQueryInterface $query, $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;
}
if (count($values) == 0) {
return;
}
$queryBuilder = new \Elastica\Query\Builder();
$queryBuilder->fieldOpen('terms')->field($field, $values)->fieldClose();
$query->addMust($queryBuilder);
} else {
if (!in_array($data['value'], array(BooleanType::TYPE_NO, BooleanType::TYPE_YES))) {
return;
}
$queryBuilder = new \Elastica\Query\Builder();
$queryBuilder->fieldOpen('term')->field($field, $data['value'] == BooleanType::TYPE_YES)->fieldClose();
$query->addMust($queryBuilder);
}
}
示例8: 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);
}
示例9: configureQuery
public function configureQuery(AdminInterface $admin, ProxyQueryInterface $query, $content = 'list')
{
if ($admin instanceof ContactAdmin) {
$query->andWhere($query->expr()->eq('o.organization', ':org_id'))->andWhere(':school_id MEMBER OF o.schools')->setParameter(':org_id', $this->session->get($this->orgSessionKey))->setParameter(':school_id', $this->session->get($this->schoolSessionKey));
} else {
$query->innerJoin('o.contact', 'c', 'WITH', 'c.organization = :org_id AND :school_id MEMBER OF c.schools')->setParameter(':org_id', $this->session->get($this->orgSessionKey))->setParameter(':school_id', $this->session->get($this->schoolSessionKey));
}
}
示例10: filter
/**
* Apply the filter to the ModelCriteria instance.
*
* @param ProxyQueryInterface $query
* @param string $alias
* @param string $field
* @param string $value
*/
public function filter(ProxyQueryInterface $query, $alias, $field, $value)
{
$map = $this->getCriteriaMap();
if (!array_key_exists('value', $value) || !array_key_exists($value['value'], $map)) {
return;
}
/* @var $query ModelCriteria */
$query->filterBy($field, true, $map[$value['value']]);
}
示例11: preBatchAction
public function preBatchAction($actionName, ProxyQueryInterface $query, array &$idx, $allElements)
{
if ($actionName == 'delete') {
$query->andWhere($query->expr()->in('o.id', '?1'))->setParameter(1, $idx);
$serviceGroups = $query->execute();
foreach ($serviceGroups as $serviceGroup) {
$this->preRemove($serviceGroup);
}
}
}
示例12: batchDelete
/**
* Deletes a set of $class identified by the provided $idx array
*
* @param string $class
* @param \Sonata\AdminBundle\Datagrid\ProxyQueryInterface $queryProxy
*
* @return void
*/
public function batchDelete($class, ProxyQueryInterface $queryProxy)
{
try {
foreach ($queryProxy->getQuery()->iterate() as $pos => $object) {
$this->delete($object[0]);
}
} catch (\PDOException $e) {
throw new ModelManagerException('', 0, $e);
}
}
示例13: batchActionCancelled
/**
* @param ProxyQueryInterface $query
*
* @throws AccessDeniedException
*
* @return RedirectResponse
*/
public function batchActionCancelled(ProxyQueryInterface $query)
{
if (false === $this->admin->isGranted('EDIT')) {
throw new AccessDeniedException();
}
foreach ($query->execute() as $message) {
$this->getMessageManager()->cancel($message);
}
return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
}
示例14: batchActionDelete
/**
* Batch forms deletion
*
* @param ProxyQueryInterface $query
* @param Request $request
* @return RedirectResponse
*/
public function batchActionDelete(ProxyQueryInterface $query, Request $request = null)
{
/** @var FcForm $fc_form */
foreach ($query->find() as $fc_form) {
if ($fc_form->isUsedAsWidget()) {
$this->addFlash('sonata_flash_error', $this->admin->trans('fc.message.admin.form.is_used_as_widget', array(), 'FenrizbesFormConstructorBundle'));
return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters())));
}
}
return parent::batchActionDelete($query);
}
示例15: filter
/**
* Apply the filter to the ModelCriteria instance.
*
* @param ProxyQueryInterface $query
* @param string $alias
* @param string $field
* @param string $value
*/
public function filter(ProxyQueryInterface $query, $alias, $field, $value)
{
$map = $this->getCriteriaMap();
if ($value['value'] instanceof PropelObjectCollection) {
$comparison = $value['type'] === ChoiceType::TYPE_NOT_CONTAINS ? $map[$value['type']] : Criteria::IN;
$query->filterBy($field, $value['value'], $comparison);
} else {
$comparison = $map[$value['type'] ?: ChoiceType::TYPE_CONTAINS];
$query->filterBy($field, $value['value'], $comparison);
}
}