| @@ 88-120 (lines=33) @@ | ||
| 85 | new PostEntity() |
|
| 86 | ); |
|
| 87 | ||
| 88 | if ($request->getMethod() == 'POST') { |
|
| 89 | $form->handleRequest($request); |
|
| 90 | ||
| 91 | if ($form->isValid()) { |
|
| 92 | $postEntity = $form->getData(); |
|
| 93 | ||
| 94 | /*** Image ***/ |
|
| 95 | $postEntity |
|
| 96 | ->setImageUploadPath($app['baseUrl'].'/assets/uploads/') |
|
| 97 | ->setImageUploadDir(WEB_DIR.'/assets/uploads/') |
|
| 98 | ->imageUpload() |
|
| 99 | ; |
|
| 100 | ||
| 101 | $app['orm.em']->persist($postEntity); |
|
| 102 | $app['orm.em']->flush(); |
|
| 103 | ||
| 104 | $app['flashbag']->add( |
|
| 105 | 'success', |
|
| 106 | $app['translator']->trans( |
|
| 107 | 'A new post was successfully created!' |
|
| 108 | ) |
|
| 109 | ); |
|
| 110 | ||
| 111 | return $app->redirect( |
|
| 112 | $app['url_generator']->generate( |
|
| 113 | 'members-area.posts.edit', |
|
| 114 | array( |
|
| 115 | 'id' => $postEntity->getId(), |
|
| 116 | ) |
|
| 117 | ) |
|
| 118 | ); |
|
| 119 | } |
|
| 120 | } |
|
| 121 | ||
| 122 | return new Response( |
|
| 123 | $app['twig']->render( |
|
| @@ 159-191 (lines=33) @@ | ||
| 156 | $post |
|
| 157 | ); |
|
| 158 | ||
| 159 | if ($request->getMethod() == 'POST') { |
|
| 160 | $form->handleRequest($request); |
|
| 161 | ||
| 162 | if ($form->isValid()) { |
|
| 163 | $postEntity = $form->getData(); |
|
| 164 | ||
| 165 | /*** Image ***/ |
|
| 166 | $postEntity |
|
| 167 | ->setImageUploadPath($app['baseUrl'].'/assets/uploads/') |
|
| 168 | ->setImageUploadDir(WEB_DIR.'/assets/uploads/') |
|
| 169 | ->imageUpload() |
|
| 170 | ; |
|
| 171 | ||
| 172 | $app['orm.em']->persist($postEntity); |
|
| 173 | $app['orm.em']->flush(); |
|
| 174 | ||
| 175 | $app['flashbag']->add( |
|
| 176 | 'success', |
|
| 177 | $app['translator']->trans( |
|
| 178 | 'The post was successfully edited!' |
|
| 179 | ) |
|
| 180 | ); |
|
| 181 | ||
| 182 | return $app->redirect( |
|
| 183 | $app['url_generator']->generate( |
|
| 184 | 'members-area.posts.edit', |
|
| 185 | array( |
|
| 186 | 'id' => $postEntity->getId(), |
|
| 187 | ) |
|
| 188 | ) |
|
| 189 | ); |
|
| 190 | } |
|
| 191 | } |
|
| 192 | ||
| 193 | return new Response( |
|
| 194 | $app['twig']->render( |
|
| @@ 92-127 (lines=36) @@ | ||
| 89 | if ($request->getMethod() == 'POST') { |
|
| 90 | $form->handleRequest($request); |
|
| 91 | ||
| 92 | if ($form->isValid()) { |
|
| 93 | $userEntity = $form->getData(); |
|
| 94 | ||
| 95 | /*** Image ***/ |
|
| 96 | $userEntity |
|
| 97 | ->getProfile() |
|
| 98 | ->setImageUploadPath($app['baseUrl'].'/assets/uploads/') |
|
| 99 | ->setImageUploadDir(WEB_DIR.'/assets/uploads/') |
|
| 100 | ->imageUpload() |
|
| 101 | ; |
|
| 102 | ||
| 103 | /*** Password ***/ |
|
| 104 | $userEntity->setPlainPassword( |
|
| 105 | $userEntity->getPlainPassword(), // This getPassword() is here just the plain password. That's why we need to convert it |
|
| 106 | $app['security.encoder_factory'] |
|
| 107 | ); |
|
| 108 | ||
| 109 | $app['orm.em']->persist($userEntity); |
|
| 110 | $app['orm.em']->flush(); |
|
| 111 | ||
| 112 | $app['flashbag']->add( |
|
| 113 | 'success', |
|
| 114 | $app['translator']->trans( |
|
| 115 | 'A new user was successfully created!' |
|
| 116 | ) |
|
| 117 | ); |
|
| 118 | ||
| 119 | return $app->redirect( |
|
| 120 | $app['url_generator']->generate( |
|
| 121 | 'members-area.users.edit', |
|
| 122 | array( |
|
| 123 | 'id' => $userEntity->getId(), |
|
| 124 | ) |
|
| 125 | ) |
|
| 126 | ); |
|
| 127 | } |
|
| 128 | } |
|
| 129 | ||
| 130 | return new Response( |
|
| @@ 60-87 (lines=28) @@ | ||
| 57 | // Security fix |
|
| 58 | $currentUserUsername = $app['user']->getUsername(); |
|
| 59 | ||
| 60 | if ($request->getMethod() == 'POST') { |
|
| 61 | $form->handleRequest($request); |
|
| 62 | ||
| 63 | // Security fix |
|
| 64 | $app['user']->setUsername($currentUserUsername); |
|
| 65 | ||
| 66 | if ($form->isValid()) { |
|
| 67 | $userEntity = $form->getData(); |
|
| 68 | ||
| 69 | /*** Image ***/ |
|
| 70 | $userEntity |
|
| 71 | ->getProfile() |
|
| 72 | ->setImageUploadPath($app['baseUrl'].'/assets/uploads/') |
|
| 73 | ->setImageUploadDir(WEB_DIR.'/assets/uploads/') |
|
| 74 | ->imageUpload() |
|
| 75 | ; |
|
| 76 | ||
| 77 | $app['orm.em']->persist($userEntity); |
|
| 78 | $app['orm.em']->flush(); |
|
| 79 | ||
| 80 | $app['flashbag']->add( |
|
| 81 | 'success', |
|
| 82 | $app['translator']->trans( |
|
| 83 | 'Your settings were successfully saved!' |
|
| 84 | ) |
|
| 85 | ); |
|
| 86 | } |
|
| 87 | } |
|
| 88 | ||
| 89 | $data['form'] = $form->createView(); |
|
| 90 | ||