| @@ 32-179 (lines=148) @@ | ||
| 29 | * |
|
| 30 | * @Route("/admin/settings/application") |
|
| 31 | */ |
|
| 32 | class ApplicationController extends AbstractController |
|
| 33 | { |
|
| 34 | /** |
|
| 35 | * Lists all Settings entities. |
|
| 36 | * |
|
| 37 | * @Route("/", name="admin_application") |
|
| 38 | * @Method("GET") |
|
| 39 | * @Template() |
|
| 40 | */ |
|
| 41 | public function indexAction() |
|
| 42 | { |
|
| 43 | $em = $this->getDoctrine()->getManager(); |
|
| 44 | $entities = $em->getRepository('AppBundle:Settings')->findAll(); |
|
| 45 | ||
| 46 | return array( |
|
| 47 | 'entities' => $entities, |
|
| 48 | 'ctEntity' => count($entities), |
|
| 49 | ); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Finds and displays a Settings entity. |
|
| 54 | * |
|
| 55 | * @Route("/{id}/show", name="admin_application_show", requirements={"id"="\d+"}) |
|
| 56 | * @Method("GET") |
|
| 57 | * @Template() |
|
| 58 | */ |
|
| 59 | public function showAction(Settings $settings) |
|
| 60 | { |
|
| 61 | $deleteForm = $this->createDeleteForm($settings->getId(), 'admin_application_delete'); |
|
| 62 | ||
| 63 | return array( |
|
| 64 | 'settings' => $settings, |
|
| 65 | 'delete_form' => $deleteForm->createView(), |
|
| 66 | ); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * Displays a form to create a new Settings entity. |
|
| 71 | * |
|
| 72 | * @Route("/new", name="admin_application_new") |
|
| 73 | * @Method("GET") |
|
| 74 | * @Template() |
|
| 75 | */ |
|
| 76 | public function newAction() |
|
| 77 | { |
|
| 78 | $settings = new Settings(); |
|
| 79 | $form = $this->createForm(new SettingsType(), $settings); |
|
| 80 | ||
| 81 | return array( |
|
| 82 | 'settings' => $settings, |
|
| 83 | 'form' => $form->createView(), |
|
| 84 | ); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Creates a new Settings entity. |
|
| 89 | * |
|
| 90 | * @Route("/create", name="admin_application_create") |
|
| 91 | * @Method("POST") |
|
| 92 | * @Template("AppBundle:Application:new.html.twig") |
|
| 93 | */ |
|
| 94 | public function createAction(Request $request) |
|
| 95 | { |
|
| 96 | $settings = new Settings(); |
|
| 97 | $form = $this->createForm(new SettingsType(), $settings); |
|
| 98 | if ($form->handleRequest($request)->isValid()) { |
|
| 99 | $em = $this->getDoctrine()->getManager(); |
|
| 100 | $em->persist($settings); |
|
| 101 | $em->flush(); |
|
| 102 | ||
| 103 | return $this->redirectToRoute('admin_application_show', array('id' => $settings->getId())); |
|
| 104 | } |
|
| 105 | ||
| 106 | return array( |
|
| 107 | 'settings' => $settings, |
|
| 108 | 'form' => $form->createView(), |
|
| 109 | ); |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * Displays a form to edit an existing Settings entity. |
|
| 114 | * |
|
| 115 | * @Route("/{id}/edit", name="admin_application_edit", requirements={"id"="\d+"}) |
|
| 116 | * @Method("GET") |
|
| 117 | * @Template() |
|
| 118 | */ |
|
| 119 | public function editAction(Settings $settings = null) |
|
| 120 | { |
|
| 121 | $editForm = $this->createForm(new SettingsType(), $settings, array( |
|
| 122 | 'action' => $this->generateUrl('admin_application_update', array('id' => $settings->getId())), |
|
| 123 | 'method' => 'PUT', |
|
| 124 | )); |
|
| 125 | $deleteForm = $this->createDeleteForm($settings->getId(), 'admin_application_delete'); |
|
| 126 | ||
| 127 | return array( |
|
| 128 | 'settings' => $settings, |
|
| 129 | 'edit_form' => $editForm->createView(), |
|
| 130 | 'delete_form' => $deleteForm->createView(), |
|
| 131 | ); |
|
| 132 | } |
|
| 133 | ||
| 134 | /** |
|
| 135 | * Edits an existing Settings entity. |
|
| 136 | * |
|
| 137 | * @Route("/{id}/update", name="admin_application_update", requirements={"id"="\d+"}) |
|
| 138 | * @Method("PUT") |
|
| 139 | * @Template("AppBundle:Application:edit.html.twig") |
|
| 140 | */ |
|
| 141 | public function updateAction(Request $request, Settings $settings = null) |
|
| 142 | { |
|
| 143 | $editForm = $this->createForm(new SettingsType(), $settings, array( |
|
| 144 | 'action' => $this->generateUrl('admin_application_update', array('id' => $settings->getId())), |
|
| 145 | 'method' => 'PUT', |
|
| 146 | )); |
|
| 147 | if ($editForm->handleRequest($request)->isValid()) { |
|
| 148 | $this->getDoctrine()->getManager()->flush(); |
|
| 149 | $this->addFlash('info', 'gestock.settings.edit_ok'); |
|
| 150 | ||
| 151 | return $this->redirectToRoute('admin_application_edit', array('id' => $settings->getId())); |
|
| 152 | } |
|
| 153 | $deleteForm = $this->createDeleteForm($settings->getId(), 'admin_application_delete'); |
|
| 154 | ||
| 155 | return array( |
|
| 156 | 'settings' => $settings, |
|
| 157 | 'edit_form' => $editForm->createView(), |
|
| 158 | 'delete_form' => $deleteForm->createView(), |
|
| 159 | ); |
|
| 160 | } |
|
| 161 | ||
| 162 | /** |
|
| 163 | * Deletes a Settings entity. |
|
| 164 | * |
|
| 165 | * @Route("/{id}/delete", name="admin_application_delete", requirements={"id"="\d+"}) |
|
| 166 | * @Method("DELETE") |
|
| 167 | */ |
|
| 168 | public function deleteAction(Request $request, Settings $settings = null) |
|
| 169 | { |
|
| 170 | $form = $this->createDeleteForm($settings->getId(), 'admin_application_delete'); |
|
| 171 | if ($form->handleRequest($request)->isValid()) { |
|
| 172 | $em = $this->getDoctrine()->getManager(); |
|
| 173 | $em->remove($settings); |
|
| 174 | $em->flush(); |
|
| 175 | } |
|
| 176 | ||
| 177 | return $this->redirectToRoute('admin_application'); |
|
| 178 | } |
|
| 179 | } |
|
| 180 | ||
| @@ 32-179 (lines=148) @@ | ||
| 29 | * |
|
| 30 | * @Route("/admin/settings/company") |
|
| 31 | */ |
|
| 32 | class CompanyController extends AbstractController |
|
| 33 | { |
|
| 34 | /** |
|
| 35 | * Lists all Company entities. |
|
| 36 | * |
|
| 37 | * @Route("/", name="admin_company") |
|
| 38 | * @Method("GET") |
|
| 39 | * @Template() |
|
| 40 | */ |
|
| 41 | public function indexAction() |
|
| 42 | { |
|
| 43 | $em = $this->getDoctrine()->getManager(); |
|
| 44 | $entities = $em->getRepository('AppBundle:Company')->findAll(); |
|
| 45 | ||
| 46 | return array( |
|
| 47 | 'entities' => $entities, |
|
| 48 | 'ctEntity' => count($entities), |
|
| 49 | ); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Finds and displays a Company entity. |
|
| 54 | * |
|
| 55 | * @Route("/{id}/show", name="admin_company_show", requirements={"id"="\d+"}) |
|
| 56 | * @Method("GET") |
|
| 57 | * @Template() |
|
| 58 | */ |
|
| 59 | public function showAction(Company $company) |
|
| 60 | { |
|
| 61 | $deleteForm = $this->createDeleteForm($company->getId(), 'admin_company_delete'); |
|
| 62 | ||
| 63 | return array( |
|
| 64 | 'company' => $company, |
|
| 65 | 'delete_form' => $deleteForm->createView(), |
|
| 66 | ); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * Displays a form to create a new Company entity. |
|
| 71 | * |
|
| 72 | * @Route("/new", name="admin_company_new") |
|
| 73 | * @Method("GET") |
|
| 74 | * @Template() |
|
| 75 | */ |
|
| 76 | public function newAction() |
|
| 77 | { |
|
| 78 | $company = new Company(); |
|
| 79 | $form = $this->createForm(new CompanyType(), $company); |
|
| 80 | ||
| 81 | return array( |
|
| 82 | 'company' => $company, |
|
| 83 | 'form' => $form->createView(), |
|
| 84 | ); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * Creates a new Company entity. |
|
| 89 | * |
|
| 90 | * @Route("/create", name="admin_company_create") |
|
| 91 | * @Method("POST") |
|
| 92 | * @Template("AppBundle:Settings/Company:new.html.twig") |
|
| 93 | */ |
|
| 94 | public function createAction(Request $request) |
|
| 95 | { |
|
| 96 | $company = new Company(); |
|
| 97 | $form = $this->createForm(new CompanyType(), $company); |
|
| 98 | if ($form->handleRequest($request)->isValid()) { |
|
| 99 | $em = $this->getDoctrine()->getManager(); |
|
| 100 | $em->persist($company); |
|
| 101 | $em->flush(); |
|
| 102 | ||
| 103 | return $this->redirectToRoute('admin_company_show', array('id' =>$company->getId())); |
|
| 104 | } |
|
| 105 | ||
| 106 | return array( |
|
| 107 | 'company' => $company, |
|
| 108 | 'form' => $form->createView(), |
|
| 109 | ); |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * Displays a form to edit an existing Company entity. |
|
| 114 | * |
|
| 115 | * @Route("/{id}/edit", name="admin_company_edit", requirements={"id"="\d+"}) |
|
| 116 | * @Method("GET") |
|
| 117 | * @Template() |
|
| 118 | */ |
|
| 119 | public function editAction(Company $company = null) |
|
| 120 | { |
|
| 121 | $editForm = $this->createForm(new CompanyType(), $company, array( |
|
| 122 | 'action' => $this->generateUrl('admin_company_update', array('id' => $company->getId())), |
|
| 123 | 'method' => 'PUT', |
|
| 124 | )); |
|
| 125 | $deleteForm = $this->createDeleteForm($company->getId(), 'admin_company_delete'); |
|
| 126 | ||
| 127 | return array( |
|
| 128 | 'company' => $company, |
|
| 129 | 'edit_form' => $editForm->createView(), |
|
| 130 | 'delete_form' => $deleteForm->createView(), |
|
| 131 | ); |
|
| 132 | } |
|
| 133 | ||
| 134 | /** |
|
| 135 | * Edits an existing Company entity. |
|
| 136 | * |
|
| 137 | * @Route("/{id}/update", name="admin_company_update", requirements={"id"="\d+"}) |
|
| 138 | * @Method("PUT") |
|
| 139 | * @Template("AppBundle:Company:edit.html.twig") |
|
| 140 | */ |
|
| 141 | public function updateAction(Request $request, Company $company = null) |
|
| 142 | { |
|
| 143 | $editForm = $this->createForm(new CompanyType(), $company, array( |
|
| 144 | 'action' => $this->generateUrl('admin_company_update', array('id' => $company->getId())), |
|
| 145 | 'method' => 'PUT', |
|
| 146 | )); |
|
| 147 | if ($editForm->handleRequest($request)->isValid()) { |
|
| 148 | $this->getDoctrine()->getManager()->flush(); |
|
| 149 | $this->addFlash('info', 'gestock.settings.edit_ok'); |
|
| 150 | ||
| 151 | return $this->redirectToRoute('admin_company_show', array('id' => $company->getId())); |
|
| 152 | } |
|
| 153 | $deleteForm = $this->createDeleteForm($company->getId(), 'admin_company_delete'); |
|
| 154 | ||
| 155 | return array( |
|
| 156 | 'company' => $company, |
|
| 157 | 'edit_form' => $editForm->createView(), |
|
| 158 | 'delete_form' => $deleteForm->createView(), |
|
| 159 | ); |
|
| 160 | } |
|
| 161 | ||
| 162 | /** |
|
| 163 | * Deletes a Company entity. |
|
| 164 | * |
|
| 165 | * @Route("/{id}/delete", name="admin_company_delete", requirements={"id"="\d+"}) |
|
| 166 | * @Method("DELETE") |
|
| 167 | */ |
|
| 168 | public function deleteAction(Request $request, Company $company = null) |
|
| 169 | { |
|
| 170 | $form = $this->createDeleteForm($company->getId(), 'admin_company_delete'); |
|
| 171 | if ($form->handleRequest($request)->isValid()) { |
|
| 172 | $em = $this->getDoctrine()->getManager(); |
|
| 173 | $em->remove($company); |
|
| 174 | $em->flush(); |
|
| 175 | } |
|
| 176 | ||
| 177 | return $this->redirectToRoute('admin_company'); |
|
| 178 | } |
|
| 179 | } |
|
| 180 | ||