@@ 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( |
@@ 57-83 (lines=27) @@ | ||
54 | $app['user'] |
|
55 | ); |
|
56 | ||
57 | if ($request->getMethod() == 'POST') { |
|
58 | $form->handleRequest($request); |
|
59 | ||
60 | if ($form->isValid()) { |
|
61 | $userEntity = $form->getData(); |
|
62 | ||
63 | /*** Image ***/ |
|
64 | $userEntity |
|
65 | ->getProfile() |
|
66 | ->setImageUploadPath($app['baseUrl'].'/assets/uploads/') |
|
67 | ->setImageUploadDir(WEB_DIR.'/assets/uploads/') |
|
68 | ->imageUpload() |
|
69 | ; |
|
70 | ||
71 | $app['orm.em']->persist($userEntity); |
|
72 | $app['orm.em']->flush(); |
|
73 | ||
74 | $app['flashbag']->add( |
|
75 | 'success', |
|
76 | $app['translator']->trans( |
|
77 | 'Your settings were successfully saved!' |
|
78 | ) |
|
79 | ); |
|
80 | } else { |
|
81 | $app['orm.em']->refresh($app['user']); |
|
82 | } |
|
83 | } |
|
84 | ||
85 | $data['form'] = $form->createView(); |
|
86 |