Example #1
0
 /**
  * Handles the upload of a user image.
  *
  * @param \MusicBox\Entity\User $user
  *
  * @param boolean TRUE if a new user image was uploaded, FALSE otherwise.
  */
 protected function handleFileUpload($user)
 {
     // If a temporary file is present, move it to the correct directory
     // and set the filename on the user.
     $file = $user->getFile();
     if ($file) {
         $newFilename = $user->getUsername() . '.' . $file->guessExtension();
         $file->move(MUSICBOX_PUBLIC_ROOT . '/img/users', $newFilename);
         $user->setFile(null);
         $user->setImage($newFilename);
         return TRUE;
     }
     return FALSE;
 }