Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.71 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Bundle\MyBundle\Controller;
  4.  
  5. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  6. use Bundle\MyBundle\Entity\User;
  7. use Symfony\Component\EventDispatcher\Event;
  8. use Bundle\MyBundle\Form\UserForm;
  9. use Bundle\MyBundle\Form\UserRequest;
  10.  
  11. class UserController extends Controller
  12. {
  13.     protected $data = array();
  14.    
  15.     public function indexAction()
  16.     {
  17.         $userRequest = new UserRequest();
  18.         $form = UserForm::create($this->get('form.context'));
  19.        
  20.         $this->data['form'] = $form;
  21.        
  22.         $form->bind($this->get('request'), $userRequest);
  23.        
  24.         if ($form->isValid())
  25.         {
  26.             die('Form Submitted');
  27.         }
  28.                
  29.         return $this->render('MyBundle:User:index.html.php', $this->data);
  30.     }
  31.    
  32.     protected function getEM()
  33.     {
  34.         return $this->get('doctrine.orm.entity_manager');
  35.     }
  36. }
  37.  
  38.  
  39. <?php
  40.  
  41. namespace Bundle\MyBundle\Form;
  42.  
  43. use Symfony\Component\Form\Form;
  44. use Symfony\Component\Form\TextField;
  45. use Symfony\Component\Form\EmailField;
  46. use Symfony\Component\Form\PasswordField;
  47.  
  48. class UserForm extends Form
  49. {
  50.     protected function configure()
  51.     {
  52.         $this->add(new TextField('email', array(
  53.             'max_length' => 50
  54.         )));
  55.        
  56.         $this->add(new PasswordField('password'));
  57.     }
  58. }
  59.  
  60. <?php
  61. namespace Bundle\MyBundle\Form;
  62.  
  63. class UserRequest
  64. {
  65.     protected $email;
  66.    
  67.     protected $password;
  68.    
  69.     protected $mailer;
  70.    
  71.     public function __construct()
  72.     {
  73.         $this->mailer = \Swift_Mailer;
  74.        
  75.         var_dump($this->mailer); exit;
  76.     }
  77.    
  78.     public function getEmail()
  79.     {
  80.         return $this->email;
  81.     }
  82.    
  83.     public function setEmail($email)
  84.     {
  85.         $this->email = $email;
  86.     }
  87.    
  88.     public function getPassword()
  89.     {
  90.         return $this->password;
  91.     }
  92.    
  93.     public function setPassword($password)
  94.     {
  95.         $this->password = $password;
  96.     }
  97.    
  98.     public function signUp()
  99.     {
  100.         // sign up logic goes here
  101.     }
  102. }
  103.  
  104. <?php
  105.  
  106. declare(ENCODING = 'utf-8');
  107. namespace Bundle\MyBundle\Entity;
  108.  
  109. /**
  110. * @orm:Entity
  111. * @orm:Table(name="schema.user",
  112. *     uniqueConstraints={@orm:UniqueConstraint(name="user_email_unique", columns={"email"})},
  113. *     indexes={@orm:Index(name="user_idx", columns={"email"})}
  114. * )
  115. */
  116. class User
  117. {
  118.     /**
  119.     * @orm:Id @orm:Column(type="integer")
  120.     * @orm:GeneratedValue
  121.     */
  122.     private $id;
  123.        
  124.     /** @orm:Column(type="string", length="50", unique="true") */
  125.     private $email;
  126.    
  127.     /** @orm:Column(type="string", length="50") */
  128.     private $first_name;
  129.    
  130.     /** @orm:Column(type="string", length="50") */
  131.     private $last_name;
  132.  
  133.     /** @orm:Column(type="integer", length="15", nullable="true") */
  134.     private $mobile = null;
  135.  
  136.     /** @orm:Column(type="string", length="60") */
  137.     private $password;
  138.    
  139.     /** @orm:Column(type="string", length="15", nullable="true") */
  140.     private $reset_password_token = null;
  141.    
  142.     /** @orm:Column(type="datetime", nullable="true") */
  143.     private $last_login = null;
  144.    
  145.     /** @orm:Column(type="string", length="15", nullable="true") */
  146.     private $last_login_ip = null;
  147.    
  148.     /** @orm:Column(type="boolean") */
  149.     private $banned;
  150.    
  151.     /** @orm:Column(type="datetime") */
  152.     private $created;
  153.    
  154.     /** @orm:Column(type="datetime") */
  155.     private $updated;  
  156.  
  157.     /**
  158.     * Model Constructor
  159.     *
  160.     * @param User $user
  161.     * @return User
  162.     */
  163.     public function __construct()
  164.     {
  165.         // set updated date
  166.         $this->updated = new \DateTime('now');
  167.        
  168.         // set created date
  169.         if ($this->created == null) $this->created = new \DateTime('now');
  170.     }
  171.    
  172.     /**
  173.      * Get id
  174.      *
  175.      * @return integer $id
  176.      */
  177.     public function getId()
  178.     {
  179.         return $this->id;
  180.     }
  181.  
  182.     /**
  183.      * Set email
  184.      *
  185.      * @param string $email
  186.      */
  187.     public function setEmail($email)
  188.     {
  189.         $this->email = $email;
  190.     }
  191.  
  192.     /**
  193.      * Get email
  194.      *
  195.      * @return string $email
  196.      */
  197.     public function getEmail()
  198.     {
  199.         return $this->email;
  200.     }
  201.  
  202.     /**
  203.      * Set first_name
  204.      *
  205.      * @param string $firstName
  206.      */
  207.     public function setFirstName($firstName)
  208.     {
  209.         $this->first_name = $firstName;
  210.     }
  211.  
  212.     /**
  213.      * Get first_name
  214.      *
  215.      * @return string $firstName
  216.      */
  217.     public function getFirstName()
  218.     {
  219.         return $this->first_name;
  220.     }
  221.  
  222.     /**
  223.      * Set last_name
  224.      *
  225.      * @param string $lastName
  226.      */
  227.     public function setLastName($lastName)
  228.     {
  229.         $this->last_name = $lastName;
  230.     }
  231.  
  232.     /**
  233.      * Get last_name
  234.      *
  235.      * @return string $lastName
  236.      */
  237.     public function getLastName()
  238.     {
  239.         return $this->last_name;
  240.     }
  241.  
  242.     /**
  243.      * Set mobile
  244.      *
  245.      * @param integer $mobile
  246.      */
  247.     public function setMobile($mobile)
  248.     {
  249.         $this->mobile = $mobile;
  250.     }
  251.  
  252.     /**
  253.      * Get mobile
  254.      *
  255.      * @return integer $mobile
  256.      */
  257.     public function getMobile()
  258.     {
  259.         return $this->mobile;
  260.     }
  261.  
  262.     /**
  263.      * Set password
  264.      *
  265.      * @param string $password
  266.      */
  267.     public function setPassword($password)
  268.     {
  269.         $this->password = $password;
  270.     }
  271.  
  272.     /**
  273.      * Get password
  274.      *
  275.      * @return string $password
  276.      */
  277.     public function getPassword()
  278.     {
  279.         return $this->password;
  280.     }
  281.  
  282.     /**
  283.      * Set reset_password_token
  284.      *
  285.      * @param string $resetPasswordToken
  286.      */
  287.     public function setResetPasswordToken($resetPasswordToken)
  288.     {
  289.         $this->reset_password_token = $resetPasswordToken;
  290.     }
  291.  
  292.     /**
  293.      * Get reset_password_token
  294.      *
  295.      * @return string $resetPasswordToken
  296.      */
  297.     public function getResetPasswordToken()
  298.     {
  299.         return $this->reset_password_token;
  300.     }
  301.  
  302.     /**
  303.      * Set last_login_at
  304.      *
  305.      * @param datetime $lastLoginAt
  306.      */
  307.     public function setLastLogin($lastLogin)
  308.     {
  309.         $this->last_login = $lastLogin;
  310.     }
  311.  
  312.     /**
  313.      * Get last_login_at
  314.      *
  315.      * @return datetime $lastLoginAt
  316.      */
  317.     public function getLastLogin()
  318.     {
  319.         return $this->last_login;
  320.     }
  321.  
  322.     /**
  323.      * Set last_login_ip
  324.      *
  325.      * @param string $lastLoginIp
  326.      */
  327.     public function setLastLoginIp($lastLoginIp)
  328.     {
  329.         $this->last_login_ip = $lastLoginIp;
  330.     }
  331.  
  332.     /**
  333.      * Get last_login_ip
  334.      *
  335.      * @return string $lastLoginIp
  336.      */
  337.     public function getLastLoginIp()
  338.     {
  339.         return $this->last_login_ip;
  340.     }
  341.    
  342.     /**
  343.      * Set banned
  344.      *
  345.      * @param boolean $banned
  346.      */
  347.     public function setBanned($banned)
  348.     {
  349.         $this->banned = $banned;
  350.     }
  351.  
  352.     /**
  353.      * Get banned
  354.      *
  355.      * @return boolean $banned
  356.      */
  357.     public function getBanned()
  358.     {
  359.         return $this->banned;
  360.     }
  361.  
  362.     /**
  363.      * Set created_at
  364.      *
  365.      * @param datetime $createdAt
  366.      */
  367.     public function setCreated($created)
  368.     {
  369.         $this->created = $created;
  370.     }
  371.  
  372.     /**
  373.      * Get created_at
  374.      *
  375.      * @return datetime $createdAt
  376.      */
  377.     public function getCreated()
  378.     {
  379.         return $this->created;
  380.     }
  381.  
  382.     /**
  383.      * Set updated_at
  384.      *
  385.      * @param datetime $updatedAt
  386.      */
  387.     public function setUpdated($updated)
  388.     {
  389.         $this->updated = $updated;
  390.     }
  391.  
  392.     /**
  393.      * Get updated_at
  394.      *
  395.      * @return datetime $updatedAt
  396.      */
  397.     public function getUpdated()
  398.     {
  399.         return $this->updated;
  400.     }
  401. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement