Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Bundle\MyBundle\Controller;
- use Symfony\Bundle\FrameworkBundle\Controller\Controller;
- use Bundle\MyBundle\Entity\User;
- use Symfony\Component\EventDispatcher\Event;
- use Bundle\MyBundle\Form\UserForm;
- use Bundle\MyBundle\Form\UserRequest;
- class UserController extends Controller
- {
- protected $data = array();
- public function indexAction()
- {
- $userRequest = new UserRequest();
- $form = UserForm::create($this->get('form.context'));
- $this->data['form'] = $form;
- $form->bind($this->get('request'), $userRequest);
- if ($form->isValid())
- {
- die('Form Submitted');
- }
- return $this->render('MyBundle:User:index.html.php', $this->data);
- }
- protected function getEM()
- {
- return $this->get('doctrine.orm.entity_manager');
- }
- }
- <?php
- namespace Bundle\MyBundle\Form;
- use Symfony\Component\Form\Form;
- use Symfony\Component\Form\TextField;
- use Symfony\Component\Form\EmailField;
- use Symfony\Component\Form\PasswordField;
- class UserForm extends Form
- {
- protected function configure()
- {
- $this->add(new TextField('email', array(
- 'max_length' => 50
- )));
- $this->add(new PasswordField('password'));
- }
- }
- <?php
- namespace Bundle\MyBundle\Form;
- class UserRequest
- {
- protected $email;
- protected $password;
- protected $mailer;
- public function __construct()
- {
- $this->mailer = \Swift_Mailer;
- var_dump($this->mailer); exit;
- }
- public function getEmail()
- {
- return $this->email;
- }
- public function setEmail($email)
- {
- $this->email = $email;
- }
- public function getPassword()
- {
- return $this->password;
- }
- public function setPassword($password)
- {
- $this->password = $password;
- }
- public function signUp()
- {
- // sign up logic goes here
- }
- }
- <?php
- declare(ENCODING = 'utf-8');
- namespace Bundle\MyBundle\Entity;
- /**
- * @orm:Entity
- * @orm:Table(name="schema.user",
- * uniqueConstraints={@orm:UniqueConstraint(name="user_email_unique", columns={"email"})},
- * indexes={@orm:Index(name="user_idx", columns={"email"})}
- * )
- */
- class User
- {
- /**
- * @orm:Id @orm:Column(type="integer")
- * @orm:GeneratedValue
- */
- private $id;
- /** @orm:Column(type="string", length="50", unique="true") */
- private $email;
- /** @orm:Column(type="string", length="50") */
- private $first_name;
- /** @orm:Column(type="string", length="50") */
- private $last_name;
- /** @orm:Column(type="integer", length="15", nullable="true") */
- private $mobile = null;
- /** @orm:Column(type="string", length="60") */
- private $password;
- /** @orm:Column(type="string", length="15", nullable="true") */
- private $reset_password_token = null;
- /** @orm:Column(type="datetime", nullable="true") */
- private $last_login = null;
- /** @orm:Column(type="string", length="15", nullable="true") */
- private $last_login_ip = null;
- /** @orm:Column(type="boolean") */
- private $banned;
- /** @orm:Column(type="datetime") */
- private $created;
- /** @orm:Column(type="datetime") */
- private $updated;
- /**
- * Model Constructor
- *
- * @param User $user
- * @return User
- */
- public function __construct()
- {
- // set updated date
- $this->updated = new \DateTime('now');
- // set created date
- if ($this->created == null) $this->created = new \DateTime('now');
- }
- /**
- * Get id
- *
- * @return integer $id
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set email
- *
- * @param string $email
- */
- public function setEmail($email)
- {
- $this->email = $email;
- }
- /**
- * Get email
- *
- * @return string $email
- */
- public function getEmail()
- {
- return $this->email;
- }
- /**
- * Set first_name
- *
- * @param string $firstName
- */
- public function setFirstName($firstName)
- {
- $this->first_name = $firstName;
- }
- /**
- * Get first_name
- *
- * @return string $firstName
- */
- public function getFirstName()
- {
- return $this->first_name;
- }
- /**
- * Set last_name
- *
- * @param string $lastName
- */
- public function setLastName($lastName)
- {
- $this->last_name = $lastName;
- }
- /**
- * Get last_name
- *
- * @return string $lastName
- */
- public function getLastName()
- {
- return $this->last_name;
- }
- /**
- * Set mobile
- *
- * @param integer $mobile
- */
- public function setMobile($mobile)
- {
- $this->mobile = $mobile;
- }
- /**
- * Get mobile
- *
- * @return integer $mobile
- */
- public function getMobile()
- {
- return $this->mobile;
- }
- /**
- * Set password
- *
- * @param string $password
- */
- public function setPassword($password)
- {
- $this->password = $password;
- }
- /**
- * Get password
- *
- * @return string $password
- */
- public function getPassword()
- {
- return $this->password;
- }
- /**
- * Set reset_password_token
- *
- * @param string $resetPasswordToken
- */
- public function setResetPasswordToken($resetPasswordToken)
- {
- $this->reset_password_token = $resetPasswordToken;
- }
- /**
- * Get reset_password_token
- *
- * @return string $resetPasswordToken
- */
- public function getResetPasswordToken()
- {
- return $this->reset_password_token;
- }
- /**
- * Set last_login_at
- *
- * @param datetime $lastLoginAt
- */
- public function setLastLogin($lastLogin)
- {
- $this->last_login = $lastLogin;
- }
- /**
- * Get last_login_at
- *
- * @return datetime $lastLoginAt
- */
- public function getLastLogin()
- {
- return $this->last_login;
- }
- /**
- * Set last_login_ip
- *
- * @param string $lastLoginIp
- */
- public function setLastLoginIp($lastLoginIp)
- {
- $this->last_login_ip = $lastLoginIp;
- }
- /**
- * Get last_login_ip
- *
- * @return string $lastLoginIp
- */
- public function getLastLoginIp()
- {
- return $this->last_login_ip;
- }
- /**
- * Set banned
- *
- * @param boolean $banned
- */
- public function setBanned($banned)
- {
- $this->banned = $banned;
- }
- /**
- * Get banned
- *
- * @return boolean $banned
- */
- public function getBanned()
- {
- return $this->banned;
- }
- /**
- * Set created_at
- *
- * @param datetime $createdAt
- */
- public function setCreated($created)
- {
- $this->created = $created;
- }
- /**
- * Get created_at
- *
- * @return datetime $createdAt
- */
- public function getCreated()
- {
- return $this->created;
- }
- /**
- * Set updated_at
- *
- * @param datetime $updatedAt
- */
- public function setUpdated($updated)
- {
- $this->updated = $updated;
- }
- /**
- * Get updated_at
- *
- * @return datetime $updatedAt
- */
- public function getUpdated()
- {
- return $this->updated;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement