public function onUpload(PostPersistEvent $event) { $response = $event->getResponse(); /** @var GaufretteFile $file */ $file = $event->getFile(); $avatarPath = $file->getPathname(); $mimeType = $file->getMimeType(); $rename = $file->getFilesystem()->rename($file->getPathname(), $event->getType() . '/' . $avatarPath); if ($rename) { $avatarPath = $event->getType() . '/' . $avatarPath; } $imageSize = getimagesize('gaufrette://images/' . $avatarPath); $response['path'] = $avatarPath; $response['url'] = $this->fileUploadService->getPublicUrl($avatarPath); $response['type'] = $mimeType; list($response['width'], $response['height']) = $imageSize; if ($event->getType() == 'avatar') { $event->getRequest()->getSession()->set('campaignchain_last_uploaded_avatar', $avatarPath); } }
public function storeImageAsAvatar(BinaryInterface $image) { $path = $this->generateAvatarPath($image->getMimeType()); $this->fileUploadService->storeImage($path, $image->getContent()); return $path; }