@@ 159-195 (lines=37) @@ | ||
156 | $post |
|
157 | ); |
|
158 | ||
159 | if ($request->getMethod() == 'POST') { |
|
160 | $form->handleRequest($request); |
|
161 | ||
162 | if ($form->isValid()) { |
|
163 | $postEntity = $form->getData(); |
|
164 | ||
165 | if ($postEntity->getRemoveImage()) { |
|
166 | $postEntity->setImageUrl(null); |
|
167 | } |
|
168 | ||
169 | /*** Image ***/ |
|
170 | $postEntity |
|
171 | ->setImageUploadPath($app['baseUrl'].'/assets/uploads/') |
|
172 | ->setImageUploadDir(WEB_DIR.'/assets/uploads/') |
|
173 | ->imageUpload() |
|
174 | ; |
|
175 | ||
176 | $app['orm.em']->persist($postEntity); |
|
177 | $app['orm.em']->flush(); |
|
178 | ||
179 | $app['flashbag']->add( |
|
180 | 'success', |
|
181 | $app['translator']->trans( |
|
182 | 'The post was successfully edited!' |
|
183 | ) |
|
184 | ); |
|
185 | ||
186 | return $app->redirect( |
|
187 | $app['url_generator']->generate( |
|
188 | 'members-area.posts.edit', |
|
189 | array( |
|
190 | 'id' => $postEntity->getId(), |
|
191 | ) |
|
192 | ) |
|
193 | ); |
|
194 | } |
|
195 | } |
|
196 | ||
197 | return new Response( |
|
198 | $app['twig']->render( |
@@ 89-128 (lines=40) @@ | ||
86 | new UserEntity() |
|
87 | ); |
|
88 | ||
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( |
|
131 | $app['twig']->render( |