Guest User

Untitled

a guest
Jul 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. protected function processForm(sfWebRequest $request, sfForm $form)
  2. {
  3. $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
  4. if ($form->isValid())
  5. {
  6. $notice = $form->getObject()->isNew() ? 'The item was created successfully.' : 'The item was updated successfully.';
  7.  
  8. $icoana_model = $form->save();
  9.  
  10.  
  11. $full = new sfThumbnail(600, 570);
  12. $full->loadFile($form->getValue('path')->getTempName());
  13. $full->save(sfConfig::get('sf_upload_dir').'/full'.$icoana_model->path);
  14.  
  15.  
  16. $small = new sfThumbnail(190, 190);
  17. $small->loadFile($form->getValue('path')->getTempName());
  18. $small->save(sfConfig::get('sf_upload_dir').'/small'.$icoana_model->path);
  19.  
  20. unlink(sfConfig::get('sf_upload_dir').'/'.$icoana_model->path);
  21.  
  22. $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $icoana_model)));
  23.  
  24.  
  25. if ($request->hasParameter('_save_and_add'))
  26. {
  27. $this->getUser()->setFlash('notice', $notice.' You can add another one below.');
  28.  
  29. $this->redirect('@icoana_model_icoana_new');
  30. }
  31. else
  32. {
  33. $this->getUser()->setFlash('notice', $notice);
  34.  
  35. $this->redirect(array('sf_route' => 'icoana_model_icoana_edit', 'sf_subject' => $icoana_model));
  36. }
  37. }
  38. else
  39. {
  40. $this->getUser()->setFlash('error', 'The item has not been saved due to some errors.', false);
  41. }
  42. }
Add Comment
Please, Sign In to add comment