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