예제 #1
0
 /**
  * @Template("JumphClientBundle:Employee:form.html.twig")
  * @ParamConverter("company", class="JumphClientBundle:Company", options={"id" = "companyId"})
  *
  * Add employee
  *
  * @param Request $request A Request instance
  * @param Company $company
  *
  * @return Response A Response instance
  */
 public function addAction(Request $request, Company $company)
 {
     $employee = new Employee();
     $employee->setCompany($company);
     $employeeForm = $this->createForm(new EmployeeType(), $employee);
     if ($request->isMethod('POST')) {
         $employeeForm->handleRequest($request);
         if ($employeeForm->isValid()) {
             $employeeManager = $this->get('jumph_client.employee_manager');
             $employeeManager->create($employee);
             $alertMessage = $this->get('jumph_app.alert_message');
             $alertMessage->success('Employee created!');
             return $this->redirect($this->generateUrl('jumph_employee_overview', array('companyId' => $company->getId())));
         }
     }
     return array('employeeForm' => $employeeForm->createView(), 'company' => $company);
 }
 /**
  * @ParamConverter("company", class="JumphClientBundle:Company", options={"id" = "companyId"})
  *
  * Add employee
  *
  * @param Request $request A Request instance
  * @param Company $company
  *
  * @return Response A Response instance
  */
 public function addAction(Request $request, Company $company)
 {
     $employee = new Employee();
     $employee->setCompany($company);
     $employeeForm = $this->createForm(new EmployeeType(), $employee);
     if ($request->isMethod('POST')) {
         $employeeForm->handleRequest($request);
         if ($employeeForm->isValid()) {
             $employeeManager = $this->get('jumph_client.employee_manager');
             $employeeManager->create($employee);
             $dispatcher = $this->container->get('event_dispatcher');
             $dispatcher->dispatch(ClientEvents::CREATE_EMPLOYEE, new Event());
             $alertMessage = $this->get('jumph_app.alert_message');
             $alertMessage->success($this->get('translator')->trans('client.employee.flash.create'));
             return $this->redirect($this->generateUrl('jumph_client_employee_overview', array('companyId' => $company->getId())));
         }
     }
     return $this->render("JumphClientBundle:Employee:form.html.twig", array('employeeForm' => $employeeForm->createView(), 'company' => $company));
 }
예제 #3
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $faker = Factory::create();
     for ($i = 0; $i < 10; $i++) {
         $employee = new Employee();
         $employee->setFirstname($faker->firstName);
         $employee->setLastname($faker->lastName);
         $employee->setEmail($faker->email);
         $employee->setCompany($this->getReference('company-' . $i));
         $this->addReference('employee-' . $i, $employee);
         $manager->persist($employee);
     }
     $manager->flush();
 }
예제 #4
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     // First employee
     $employee = new Employee();
     $employee->setEmail('*****@*****.**');
     $employee->setFirstname('Larry');
     $employee->setLastname('Page');
     $employee->setCompany($this->getReference('google'));
     $manager->persist($employee);
     $manager->flush();
     // Second employee
     $employee = new Employee();
     $employee->setEmail('*****@*****.**');
     $employee->setFirstname('Sergey');
     $employee->setLastname('Brin');
     $employee->setCompany($this->getReference('google'));
     $manager->persist($employee);
     $manager->flush();
     // Third employee
     $employee = new Employee();
     $employee->setEmail('*****@*****.**');
     $employee->setFirstname('Bill');
     $employee->setLastname('Gates');
     $employee->setCompany($this->getReference('microsoft'));
     $manager->persist($employee);
     $manager->flush();
     // Fourth employee
     $employee = new Employee();
     $employee->setEmail('*****@*****.**');
     $employee->setFirstname('Vic');
     $employee->setLastname('Gundotra');
     $employee->setCompany($this->getReference('google'));
     $employee->setDeletedAt(new \DateTime());
     $manager->persist($employee);
     $manager->flush();
 }
예제 #5
0
파일: Company.php 프로젝트: fedegiust/Jumph
 /**
  * Add employees
  *
  * @param Employee $employee
  * @return Company
  */
 public function addEmployee(Employee $employee)
 {
     $this->employees[] = $employee;
     $employee->setCompany($this);
     return $this;
 }
예제 #6
0
 public function testSetDeletedAt()
 {
     $employee = new Employee();
     $dateTime = new \DateTime();
     $employee->setDeletedAt($dateTime);
     $this->assertEquals($dateTime, $employee->getDeletedAt());
 }