Skip to content

Commit 860a5f4

Browse files
author
Ian Thomas
committed
1 parent c54a82a commit 860a5f4

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

Controller/UploadController.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
namespace Comur\ImageBundle\Controller;
44

5-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
5+
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
66

77
use Symfony\Component\HttpFoundation\Request;
88
use Symfony\Component\HttpFoundation\Response;
99
use Symfony\Component\HttpFoundation\File\UploadedFile;
1010
use Symfony\Component\HttpFoundation\StreamedResponse;
11+
use Symfony\Component\Translation\Translator;
1112

1213
use Symfony\Component\Finder\Finder;
1314

1415
use Comur\ImageBundle\Handler\UploadHandler;
1516

16-
class UploadController extends Controller
17+
class UploadController extends AbstractController
1718
{
1819
/**
1920
* Save uploaded image according to comur_image field configuration
2021
*
2122
* @param Request $request
2223
*/
23-
public function uploadImageAction(Request $request
24+
public function uploadImageAction(Request $request, Translator $translator
2425
/*, $uploadUrl, $paramName, $webDir, $minWidth=1, $minHeight=1*/
2526
){
2627
$config = json_decode($request->request->get('config'),true);
@@ -83,24 +84,24 @@ public function uploadImageAction(Request $request
8384
$transDomain = $this->container->getParameter('comur_image.translation_domain');
8485

8586
$errorMessages = array(
86-
1 => $this->get('translator')->trans('The uploaded file exceeds the upload_max_filesize directive in php.ini', array(), $transDomain),
87-
2 => $this->get('translator')->trans('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', array(), $transDomain),
88-
3 => $this->get('translator')->trans('The uploaded file was only partially uploaded', array(), $transDomain),
89-
4 => $this->get('translator')->trans('No file was uploaded', array(), $transDomain),
90-
6 => $this->get('translator')->trans('Missing a temporary folder', array(), $transDomain),
91-
7 => $this->get('translator')->trans('Failed to write file to disk', array(), $transDomain),
92-
8 => $this->get('translator')->trans('A PHP extension stopped the file upload', array(), $transDomain),
93-
'post_max_size' => $this->get('translator')->trans('The uploaded file exceeds the post_max_size directive in php.ini', array(), $transDomain),
94-
'max_file_size' => $this->get('translator')->trans('File is too big', array(), $transDomain),
95-
'min_file_size' => $this->get('translator')->trans('File is too small', array(), $transDomain),
96-
'accept_file_types' => $this->get('translator')->trans('Filetype not allowed', array(), $transDomain),
97-
'max_number_of_files' => $this->get('translator')->trans('Maximum number of files exceeded', array(), $transDomain),
98-
'max_width' => $this->get('translator')->trans('Image exceeds maximum width', array(), $transDomain),
99-
'min_width' => $this->get('translator')->trans('Image requires a minimum width (%min%)', array('%min%' => $config['cropConfig']['minWidth']), $transDomain),
100-
'max_height' => $this->get('translator')->trans('Image exceeds maximum height', array(), $transDomain),
101-
'min_height' => $this->get('translator')->trans('Image requires a minimum height (%min%)', array('%min%' => $config['cropConfig']['minHeight']), $transDomain),
102-
'abort' => $this->get('translator')->trans('File upload aborted', array(), $transDomain),
103-
'image_resize' => $this->get('translator')->trans('Failed to resize image', array(), $transDomain),
87+
1 => $translator->trans('The uploaded file exceeds the upload_max_filesize directive in php.ini', array(), $transDomain),
88+
2 => $translator->trans('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', array(), $transDomain),
89+
3 => $translator->trans('The uploaded file was only partially uploaded', array(), $transDomain),
90+
4 => $translator->trans('No file was uploaded', array(), $transDomain),
91+
6 => $translator->trans('Missing a temporary folder', array(), $transDomain),
92+
7 => $translator->trans('Failed to write file to disk', array(), $transDomain),
93+
8 => $translator->trans('A PHP extension stopped the file upload', array(), $transDomain),
94+
'post_max_size' => $translator->trans('The uploaded file exceeds the post_max_size directive in php.ini', array(), $transDomain),
95+
'max_file_size' => $translator->trans('File is too big', array(), $transDomain),
96+
'min_file_size' => $translator->trans('File is too small', array(), $transDomain),
97+
'accept_file_types' => $translator->trans('Filetype not allowed', array(), $transDomain),
98+
'max_number_of_files' => $translator->trans('Maximum number of files exceeded', array(), $transDomain),
99+
'max_width' => $translator->trans('Image exceeds maximum width', array(), $transDomain),
100+
'min_width' => $translator->trans('Image requires a minimum width (%min%)', array('%min%' => $config['cropConfig']['minWidth']), $transDomain),
101+
'max_height' => $translator->trans('Image exceeds maximum height', array(), $transDomain),
102+
'min_height' => $translator->trans('Image requires a minimum height (%min%)', array('%min%' => $config['cropConfig']['minHeight']), $transDomain),
103+
'abort' => $translator->trans('File upload aborted', array(), $transDomain),
104+
'image_resize' => $translator->trans('Failed to resize image', array(), $transDomain),
104105
);
105106

106107
$response->setCallback(function () use($handlerConfig, $errorMessages) {

0 commit comments

Comments
 (0)