
Untitled
By: a guest on
Apr 28th, 2012 | syntax:
None | size: 1.73 KB | hits: 13 | expires: Never
<?php
namespace JStout\MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller,
Sensio\Bundle\FrameworkExtraBundle\Configuration as Extra,
JStout\MainBundle\Component\Form\FormHandlerInterface,
JStout\MainBundle\Entity\User,
JStout\MainBundle\Entity\Vendor,
JStout\MainBundle\Entity\Location,
JStout\MainBundle\Form\Vendor\SignupType,
JStout\MainBundle\Form\Vendor\SignupHandler;
/**
* @Extra\Route("/vendor")
*/
class VendorController extends Controller
{
/**
* @Extra\Route(name="vendor_index")
* @Extra\Template()
*/
public function indexAction()
{
return array();
}
/**
* @Extra\Route("/sign-up", name="vendor_signup")
* @Extra\Template()
*/
public function signupAction()
{
// initialize new vendor
$vendor = new Vendor();
if (($user = $this->get('request')->getSession()->get('user')) instanceOf User) {
$vendor->setOwner($user);
}
// get vendor signup form
$form = $this->get('form.factory')->create(new SignupType(), $vendor);
// get form handler for vendor form
$formHandler = $this->get('form.handler')->create(new SignupHandler(), $form);
// extra data for form handler
$extras = array(
'encoderFactory' => $this->get('security.encoder_factory'),
'aclProvider' => $this->get('security.acl.provider')
);
// redirect if form submission was valid
if (($vendor = $formHandler->process($extras)) instanceOf Vendor) {
return $this->redirect($this->generateUrl('vendor_index'));
}
return array(
'form' => $form->createView()
);
}
}