Created
May 19, 2011 15:09
-
-
Save johnwards/980976 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace FoodRisc\AccountAdminBundle\Admin\Action; | |
use WhiteOctober\AdminBundle\Action\Action; | |
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | |
use Symfony\Component\HttpFoundation\RedirectResponse; | |
class WaveSendInvitationsAction extends Action | |
{ | |
protected function configure() | |
{ | |
$this | |
->setName('participant.send_invitations') | |
->setRoute('send_invitations', '/{id}/send-invitations') | |
->setDefaultTemplate('FoodRiscAccountAdminBundle::waves/sendInvitations.html.twig') | |
->setDependences(array( | |
'list' => array( | |
'dataActions' => array( | |
'sendInvitations' => array('label' => 'Send Invitations', 'routeName' => '@send_invitations'), | |
), | |
), | |
)) | |
; | |
} | |
public function executeController() | |
{ | |
$findDataByIdClosure = $this->getActionsVars()->get('findDataByIdClosure'); | |
$data = $findDataByIdClosure($this->get('request')->attributes->get('id')); | |
if (!$data) { | |
throw new NotFoundHttpException(); | |
} | |
$form = $this->get('form.factory')->createBuilder('form') | |
->add('text', 'textarea') | |
->getForm() | |
; | |
$request = $this->get('request'); | |
if ('POST' == $request->getMethod()) { | |
$form->bindRequest($request); | |
if ($form->isValid()) { | |
$formData = $form->getData(); | |
$this->get('pablodip_notify.notify_factory')->notify('wave_send_invitations', array( | |
'wave' => $data, | |
'text' => $formData['text'], | |
)); | |
return new RedirectResponse($this->generateUrl('list')); | |
} | |
} | |
return $this->render($this->getTemplate(), array('data' => $data, 'form' => $form->createView())); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment