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


PHP ProxyQueryInterface::execute方法代碼示例

本文整理匯總了PHP中Sonata\AdminBundle\Datagrid\ProxyQueryInterface::execute方法的典型用法代碼示例。如果您正苦於以下問題:PHP ProxyQueryInterface::execute方法的具體用法?PHP ProxyQueryInterface::execute怎麽用?PHP ProxyQueryInterface::execute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Sonata\AdminBundle\Datagrid\ProxyQueryInterface的用法示例。


在下文中一共展示了ProxyQueryInterface::execute方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: commentChangeStatus

 /**
  * @param ProxyQueryInterface $query
  * @param                     $status
  *
  * @return RedirectResponse
  *
  * @throws AccessDeniedException
  */
 protected function commentChangeStatus(ProxyQueryInterface $query, $status)
 {
     if (false === $this->admin->isGranted('EDIT')) {
         throw new AccessDeniedException();
     }
     foreach ($query->execute() as $comment) {
         $comment->setStatus($status);
         $this->admin->getModelManager()->update($comment);
     }
     return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
 }
開發者ID:Neodork,項目名稱:SonataNewsBundle,代碼行數:19,代碼來源:CommentAdminController.php

示例5: batchActionDelete

 public function batchActionDelete(ProxyQueryInterface $query)
 {
     $this->admin->checkAccess('batchDelete');
     try {
         $this->deleteItems($query->execute());
         $this->addFlash('sonata_flash_success', 'flash_batch_delete_success');
     } catch (ModelManagerException $e) {
         $this->handleModelManagerException($e);
         $this->addFlash('sonata_flash_error', 'flash_batch_delete_error');
     }
     return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters())));
 }
開發者ID:alpixel,項目名稱:AlpixelMenuBundle,代碼行數:12,代碼來源:ItemCRUDController.php

示例6: batchActionSendEmail

 public function batchActionSendEmail(ProxyQueryInterface $query)
 {
     if (!$this->admin->isGranted('ROLE_EMAIL_ADMIN')) {
         throw $this->createAccessDeniedException();
     }
     $modelManager = $this->admin->getModelManager();
     $emailSender = $this->get('bcp.email_sender');
     $contactProvider = $this->get('bcp.contact_provider');
     $templating = $this->get('templating');
     $from = $this->getParameter('newsletter_from');
     $selectedEmails = $query->execute();
     $errors = array();
     try {
         foreach ($selectedEmails as $email) {
             if (null === $email->getEmailFrom()) {
                 $email->setEmailFrom($from);
             } else {
                 $from = $email->getEmailFrom();
             }
             $emails = in_array('all', $email->getContacts()) ? $contactProvider->getContactsEmail() : $email->getContacts();
             $subject = sprintf('[BCP] %s', $email->getSubject());
             $body = $templating->render('@App/Utils/email_structure.html.twig', array('body' => $email->getBody()));
             if (!empty($emails)) {
                 foreach ($emails as $to) {
                     $sent = $emailSender->send($from, array($to), $subject, $body);
                     if (!$sent) {
                         $errors[] = sprintf('%s - %s', $subject, $to);
                     }
                 }
                 $email->setSent(new \Datetime());
                 $modelManager->update($email);
             } else {
                 $errors[] = sprintf('%s - %s', $subject, $this->admin->trans('email_to_empty'));
             }
         }
         if (!empty($errors)) {
             $error = $this->admin->trans('flash_batch_send_email_error');
             $error .= '<ul>';
             foreach ($errors as $err) {
                 $error .= sprintf('<li>%s</li>', $err);
             }
             $error .= '</ul>';
             $this->addFlash('sonata_flash_error', $error, $this->admin->flashIcon);
         } else {
             $this->addFlash('sonata_flash_success', $this->admin->trans('flash_batch_send_email_success'), $this->admin->flashIcon);
         }
     } catch (ModelManagerException $e) {
         $this->handleModelManagerException($e);
         $this->addFlash('sonata_flash_error', $this->admin->trans('flash_batch_send_email_error'), $this->admin->flashIcon);
     }
     return $this->redirect($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
 }
開發者ID:nathix86,項目名稱:bcp-website,代碼行數:52,代碼來源:EmailController.php

示例7: batchActionExtend

 public function batchActionExtend(ProxyQueryInterface $selectedModelQuery)
 {
     if ($this->admin->isGranted('EDIT') === false || $this->admin->isGranted('DELETE') === false) {
         throw new AccessDeniedException();
     }
     $modelManager = $this->admin->getModelManager();
     $selectedModels = $selectedModelQuery->execute();
     try {
         foreach ($selectedModels as $selectedModel) {
             $selectedModel->extend();
             $modelManager->update($selectedModel);
         }
     } catch (Exception $e) {
         $this->get('session')->getFlashBag()->add('sonata_flash_error', $e->getMessage());
         return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
     }
     $this->get('session')->getFlashBag()->add('sonata_flash_success', sprintf('The selected jobs validity has been extended until %s.', date('m/d/Y', time() + 86400 * 30)));
     return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
 }
開發者ID:arossokha,項目名稱:symfonytest,代碼行數:19,代碼來源:JobAdminController.php

示例8: batchActionDeactivate

 public function batchActionDeactivate(ProxyQueryInterface $selectedModelQuery)
 {
     if ($this->admin->isGranted('EDIT') === false || $this->admin->isGranted('DELETE') === false) {
         throw new AccessDeniedException();
     }
     $request = $this->get('request');
     $modelManager = $this->admin->getModelManager();
     $selectedModels = $selectedModelQuery->execute();
     try {
         foreach ($selectedModels as $selectedModel) {
             $selectedModel->deactivate();
             $modelManager->update($selectedModel);
         }
     } catch (Exception $e) {
         $this->get('session')->getFlashBag()->add('sonata_flash_error', $e->getMessage());
         return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
     }
     $this->get('session')->getFlashBag()->add('sonata_flash_success', sprintf('The selected accounts have been deactivated'));
     return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
 }
開發者ID:arossokha,項目名稱:symfonytest,代碼行數:20,代碼來源:AffiliateAdminController.php

示例9: batchActionDispatch

 public function batchActionDispatch(ProxyQueryInterface $selectedModelQuery)
 {
     if (!$this->admin->isGranted('EDIT')) {
         throw new AccessDeniedException();
     }
     $modelManager = $this->admin->getModelManager();
     $selectedModels = $selectedModelQuery->execute();
     $eventDispatcher = $this->get('event_dispatcher');
     $i = 0;
     try {
         foreach ($selectedModels as $selectedModel) {
             if ($selectedModel->getDispatchStatus() == Order::DISPATCH_STATUS_DISPATCHED) {
                 $this->addFlash('sonata_flash_error', sprintf('Order %d has already been dispatched.', $selectedModel->getId()));
                 continue;
             }
             if ($selectedModel->getDispatchStatus() == Order::DISPATCH_STATUS_UNDISPATCHABLE) {
                 $this->addFlash('sonata_flash_error', sprintf('Order %d is not dispatchable.', $selectedModel->getId()));
                 continue;
             }
             if ($selectedModel->getStatus() != GetHumanStatus::STATUS_AUTHORIZED) {
                 $this->addFlash('sonata_flash_error', sprintf('Order %d has not been authorized.', $selectedModel->getId()));
                 continue;
             }
             if ($selectedModel->getDispatchStatus() == Order::DISPATCH_STATUS_PROCESSING) {
                 $selectedModel->setDispatchStatus(Order::DISPATCH_STATUS_DISPATCHED);
                 $eventDispatcher->dispatch('event.dispatch', new GenericEvent(null, ['order' => $selectedModel]));
                 $i++;
             }
         }
         $modelManager->update($selectedModel);
     } catch (\Exception $e) {
         $this->addFlash('sonata_flash_error', 'flash_batch_merge_error');
         return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
     }
     if ($i > 0) {
         $this->addFlash('sonata_flash_success', sprintf('Marked %d orders as dispatched.', $i));
     }
     return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
 }
開發者ID:jackpf,項目名稱:BuffaloSessions,代碼行數:39,代碼來源:OrderAdminController.php

示例10: batchDelete

 /**
  * {@inheritDoc}
  *
  * @throws ModelManagerException if anything goes wrong during query execution.
  */
 public function batchDelete($class, ProxyQueryInterface $queryProxy)
 {
     try {
         $i = 0;
         $res = $queryProxy->execute();
         foreach ($res as $object) {
             $this->dm->remove($object);
             if (++$i % 20 == 0) {
                 $this->dm->flush();
                 $this->dm->clear();
             }
         }
         $this->dm->flush();
         $this->dm->clear();
     } catch (\Exception $e) {
         throw new ModelManagerException('', 0, $e);
     }
 }
開發者ID:Aaike,項目名稱:SonataDoctrinePhpcrAdminBundle,代碼行數:23,代碼來源:ModelManager.php

示例11: batchActionCacheClear

 /**
  * @param ProxyQueryInterface $selectedModelQuery
  * @return RedirectResponse
  * @throws AccessDeniedException
  */
 public function batchActionCacheClear(ProxyQueryInterface $selectedModelQuery)
 {
     if ($this->admin->isGranted('PUBLISH') === false) {
         throw new AccessDeniedException();
     }
     $modelManager = $this->admin->getModelManager();
     $selectedModels = $selectedModelQuery->execute();
     // do the merge work here
     try {
         foreach ($selectedModels as $selectedModel) {
             /** @var \Networking\InitCmsBundle\Lib\PhpCacheInterface $phpCache */
             $phpCache = $this->get('networking_init_cms.lib.php_cache');
             if ($phpCache->isActive()) {
                 /** @var PageInterface $selectedModel */
                 $cacheKey = $selectedModel->getLocale() . $selectedModel->getFullPath();
                 $phpCache->delete($cacheKey);
             }
         }
     } catch (\Exception $e) {
         $this->get('session')->getFlashBag()->add('sonata_flash_error', 'flash_batch_cache_clear_error');
         return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
     }
     $this->get('session')->getFlashBag()->add('sonata_flash_success', 'flash_batch_cache_clear_success');
     return new RedirectResponse($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
 }
開發者ID:rapemer,項目名稱:init-cms-bundle,代碼行數:30,代碼來源:PageAdminController.php

示例12: batchActionNewsletterAndFacebook

 public function batchActionNewsletterAndFacebook(ProxyQueryInterface $query)
 {
     if (!$this->admin->isGranted('ROLE_POST_ADMIN')) {
         throw $this->createAccessDeniedException();
     }
     $selectedPosts = $query->execute();
     try {
         $this->shareNewsletter($selectedPosts);
         $this->publishOnFacebook($selectedPosts);
     } catch (ModelManagerException $e) {
         $this->handleModelManagerException($e);
         $this->addFlash('sonata_flash_error', $this->admin->trans('flash_batch_newsletter_error'), $this->admin->flashNewsletterIcon);
     }
     return $this->redirect($this->admin->generateUrl('list', $this->admin->getFilterParameters()));
 }
開發者ID:nathix86,項目名稱:bcp-website,代碼行數:15,代碼來源:PostController.php


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