Пример #1
0
 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $transformer = new CompanyTransformer();
     foreach ($this->getFixturesData() as $data) {
         $company = $this->setCompanyEntity($data['name'], $data['mainActivity'], $data['legalCode']);
         $companyEntity = $transformer->toEntity($company, new CompanyEntity());
         $manager->persist($companyEntity);
     }
     $manager->flush();
 }
Пример #2
0
 /**
  * @param Company $company
  *
  * @return CompanyEntity
  */
 private function companyEntityTransformer(Company $company)
 {
     $companyEntity = $this->repository->find($company->id());
     if (null === $companyEntity) {
         $companyEntity = new CompanyEntity();
     }
     return CompanyTransformer::toEntity($company, $companyEntity);
 }
Пример #3
0
 /**
  * @param Request $request
  *
  * @return array
  *
  * @Route("/edit/{id}")
  * @Template(":Company:edit.html.twig")
  */
 public function editAction(Request $request)
 {
     $id = $request->get('id');
     $companyRepository = $this->get('company.form.repository');
     $companyEntity = $companyRepository->find($id);
     $form = $this->createForm(new CompanyType(), $companyEntity);
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             $company = CompanyTransformer::toDomainObject($companyEntity);
             $companyRepository->save($company);
             $this->addFlash('notice', 'Empresa actualizada correctamente.');
             return $this->redirect($this->generateUrl('app_company_edit', ['id' => $id]));
         }
     }
     return ['id' => $id, 'form' => $form->createView()];
 }