예제 #1
0
 /**
  * @param \Claroline\CoreBundle\Entity\User $user
  */
 public function uploadAvatar(User $user)
 {
     if (null !== $user->getPictureFile()) {
         if (!is_writable($pictureDir = $this->uploadsDirectory . '/pictures/')) {
             throw new \Exception("{$pictureDir} is not writable");
         }
         $user->setPicture(sha1($user->getPictureFile()->getClientOriginalName() . $user->getId()) . '.' . $user->getPictureFile()->guessExtension());
         $user->getPictureFile()->move($pictureDir, $user->getPicture());
     }
 }