示例#1
0
 public function execute()
 {
     if ($this->photo->isValid()) {
         $name = sha1($this->user->getId() . $this->user->getLogin() . $this->user->getRegisteredAt() . time() . uniqid('ffdf'));
         $photoUploader = new PhotoFormatter($this->photo->getRealPath(), self::MINIMUM_SIZE, self::MAXIMUM_SIZE, $this->output);
         $old = $this->user->getAvatar();
         $photoUploader->setNewName($name);
         $photoUploader->loadAndScale(self::START_SIZE);
         $this->user->setAvatar($name);
         $this->repository->update($this->user);
         if (!empty($old)) {
             $photoUploader->removeOld($old, self::START_SIZE);
         }
     }
 }