當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Datagrid\ProxyQueryInterface類代碼示例

本文整理匯總了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);
 }
開發者ID:netounet,項目名稱:SonataDoctrineORMAdminBundle,代碼行數:10,代碼來源:ModelAutocompleteFilter.php

示例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);
         }
     }
 }
開發者ID:Kertudex,項目名稱:SonataAdminSearchBundle,代碼行數:37,代碼來源:ChoiceFilter.php

示例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;
     }
 }
開發者ID:chovan-zoltan,項目名稱:SonataDoctrineMongoDBAdminBundle,代碼行數:37,代碼來源:ChoiceFilter.php

示例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;
 }
開發者ID:zajca,項目名稱:SonataDoctrineMongoDBAdminBundle,代碼行數:34,代碼來源:StringFilter.php

示例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;
     }
 }
開發者ID:zajca,項目名稱:SonataDoctrineMongoDBAdminBundle,代碼行數:35,代碼來源:BooleanFilter.php

示例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()));
 }
開發者ID:holtchesley,項目名稱:Zeega,代碼行數:30,代碼來源:UserAdminController.php

示例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);
     }
 }
開發者ID:Kertudex,項目名稱:SonataAdminSearchBundle,代碼行數:31,代碼來源:BooleanFilter.php

示例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);
 }
開發者ID:kamillo1888,項目名稱:SonataDoctrineMongoDBAdminBundle,代碼行數:14,代碼來源:DateTimeFilter.php

示例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));
     }
 }
開發者ID:sgh1986915,項目名稱:symfony-tsk,代碼行數:8,代碼來源:ContactAdminExtension.php

示例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']]);
 }
開發者ID:kosolapovvp,項目名稱:SonataPropelAdminBundle,代碼行數:17,代碼來源:BooleanFilter.php

示例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);
         }
     }
 }
開發者ID:mdstorage,項目名稱:simpleshop,代碼行數:10,代碼來源:ServiceGroupAdmin.php

示例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);
     }
 }
開發者ID:novatex,項目名稱:SonataMediaBundle,代碼行數:18,代碼來源:DoctrineORMManager.php

示例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()));
 }
開發者ID:Neodork,項目名稱:SonataNotificationBundle,代碼行數:17,代碼來源:MessageAdminController.php

示例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);
 }
開發者ID:it-blaster,項目名稱:form-constructor-bundle,代碼行數:18,代碼來源:FcFormAdminController.php

示例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);
     }
 }
開發者ID:kosolapovvp,項目名稱:SonataPropelAdminBundle,代碼行數:19,代碼來源:ModelFilter.php


注:本文中的Sonata\AdminBundle\Datagrid\ProxyQueryInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。