diff --git a/CHANGELOG.md b/CHANGELOG.md index 624fb50f..9ff63684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## dev-master + +- Removed dependency on JMS Translation Bundle. If you have no other need for this bundle it can be removed by running +`composer remove jms/translation-bundle` and taking the relevant line out of `config/bundles.php` (or +`app/AppKernel.php` for projects that do not use Flex) + ## [2.0.4](https://github.com/comur/ComurImageBundle/tree/2.0.4) (2019-05-31) [Full Changelog](https://github.com/comur/ComurImageBundle/compare/2.0.3...2.0.4) diff --git a/Controller/UploadController.php b/Controller/UploadController.php index 0c5f880a..865e1882 100644 --- a/Controller/UploadController.php +++ b/Controller/UploadController.php @@ -2,19 +2,27 @@ namespace Comur\ImageBundle\Controller; -use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\StreamedResponse; +use Symfony\Contracts\Translation\TranslatorInterface; use Symfony\Component\Finder\Finder; use Comur\ImageBundle\Handler\UploadHandler; -class UploadController extends Controller +class UploadController extends AbstractController { + private $translator; + + public function __construct(TranslatorInterface $translator) + { + $this->translator = $translator; + } + /** * Save uploaded image according to comur_image field configuration * @@ -83,31 +91,31 @@ public function uploadImageAction(Request $request $transDomain = $this->container->getParameter('comur_image.translation_domain'); $errorMessages = array( - 1 => $this->get('translator')->trans('The uploaded file exceeds the upload_max_filesize directive in php.ini', array(), $transDomain), - 2 => $this->get('translator')->trans('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', array(), $transDomain), - 3 => $this->get('translator')->trans('The uploaded file was only partially uploaded', array(), $transDomain), - 4 => $this->get('translator')->trans('No file was uploaded', array(), $transDomain), - 6 => $this->get('translator')->trans('Missing a temporary folder', array(), $transDomain), - 7 => $this->get('translator')->trans('Failed to write file to disk', array(), $transDomain), - 8 => $this->get('translator')->trans('A PHP extension stopped the file upload', array(), $transDomain), - 'post_max_size' => $this->get('translator')->trans('The uploaded file exceeds the post_max_size directive in php.ini', array(), $transDomain), - 'max_file_size' => $this->get('translator')->trans('File is too big', array(), $transDomain), - 'min_file_size' => $this->get('translator')->trans('File is too small', array(), $transDomain), - 'accept_file_types' => $this->get('translator')->trans('Filetype not allowed', array(), $transDomain), - 'max_number_of_files' => $this->get('translator')->trans('Maximum number of files exceeded', array(), $transDomain), - 'max_width' => $this->get('translator')->trans('Image exceeds maximum width', array(), $transDomain), - 'min_width' => $this->get('translator')->trans('Image requires a minimum width (%min%)', array('%min%' => $config['cropConfig']['minWidth']), $transDomain), - 'max_height' => $this->get('translator')->trans('Image exceeds maximum height', array(), $transDomain), - 'min_height' => $this->get('translator')->trans('Image requires a minimum height (%min%)', array('%min%' => $config['cropConfig']['minHeight']), $transDomain), - 'abort' => $this->get('translator')->trans('File upload aborted', array(), $transDomain), - 'image_resize' => $this->get('translator')->trans('Failed to resize image', array(), $transDomain), + 1 => $this->translator->trans('The uploaded file exceeds the upload_max_filesize directive in php.ini', array(), $transDomain), + 2 => $this->translator->trans('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form', array(), $transDomain), + 3 => $this->translator->trans('The uploaded file was only partially uploaded', array(), $transDomain), + 4 => $this->translator->trans('No file was uploaded', array(), $transDomain), + 6 => $this->translator->trans('Missing a temporary folder', array(), $transDomain), + 7 => $this->translator->trans('Failed to write file to disk', array(), $transDomain), + 8 => $this->translator->trans('A PHP extension stopped the file upload', array(), $transDomain), + 'post_max_size' => $this->translator->trans('The uploaded file exceeds the post_max_size directive in php.ini', array(), $transDomain), + 'max_file_size' => $this->translator->trans('File is too big', array(), $transDomain), + 'min_file_size' => $this->translator->trans('File is too small', array(), $transDomain), + 'accept_file_types' => $this->translator->trans('Filetype not allowed', array(), $transDomain), + 'max_number_of_files' => $this->translator->trans('Maximum number of files exceeded', array(), $transDomain), + 'max_width' => $this->translator->trans('Image exceeds maximum width', array(), $transDomain), + 'min_width' => $this->translator->trans('Image requires a minimum width (%min%)', array('%min%' => $config['cropConfig']['minWidth']), $transDomain), + 'max_height' => $this->translator->trans('Image exceeds maximum height', array(), $transDomain), + 'min_height' => $this->translator->trans('Image requires a minimum height (%min%)', array('%min%' => $config['cropConfig']['minHeight']), $transDomain), + 'abort' => $this->translator->trans('File upload aborted', array(), $transDomain), + 'image_resize' => $this->translator->trans('Failed to resize image', array(), $transDomain), ); $response->setCallback(function () use($handlerConfig, $errorMessages) { new UploadHandler($handlerConfig, true, $errorMessages); }); - return $response->send(); + return $response; } /** @@ -430,8 +438,7 @@ private function resizeCropImage($destSrc, $imgSrc, $destX, $destY, $srcX, $srcY */ public function getTranslationCatalogue(Request $request) { $transDomain = $this->container->getParameter('comur_image.translation_domain'); - $translator = $this->container->get('translator'); - $catalogue = $translator->getCatalogue($request->getLocale()); + $catalogue = $this->translator->getCatalogue($request->getLocale()); $messages = $catalogue->all(); return $this->render('@ComurImage/translations.html.twig', array( diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 93a69423..3d2c7155 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -17,8 +17,10 @@ class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('comur_image'); + $treeBuilder = new TreeBuilder('comur_image'); + $rootNode = method_exists($treeBuilder, "getRootNode") + ? $treeBuilder->getRootNode() + : $treeBuilder->root('comur_image'); // BC layer for symfony/config 4.2 and older $rootNode ->children() diff --git a/README.md b/README.md index bd71bc36..377920ce 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,6 @@ return [ // ... Comur\ImageBundle\ComurImageBundle::class => ['all' => true], FOS\JsRoutingBundle\FOSJsRoutingBundle::class => ['all' => true], - JMS\TranslationBundle\JMSTranslationBundle::class => ['all' => true], ]; ``` @@ -165,7 +164,6 @@ class AppKernel extends Kernel // ... new Comur\ImageBundle\ComurImageBundle(), new FOS\JsRoutingBundle\FOSJsRoutingBundle(), - new JMS\TranslationBundle\JMSTranslationBundle(), ]; // ... diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml index 769e7708..366ad1fd 100644 --- a/Resources/config/routing.yml +++ b/Resources/config/routing.yml @@ -1,17 +1,17 @@ comur_api_upload: path: /upload #/{paramName}/{uploadUrl}/{webDir}/{minWidth}/{minHeight} - defaults: {_controller: "ComurImageBundle:Upload:uploadImage"} + defaults: {_controller: \Comur\ImageBundle\Controller\UploadController::uploadImageAction } options: expose: true comur_api_crop: path: /crop #/{uploadUrl}/{webDir}/{imageName}/{x}/{y}/{w}/{h}/{tarW}/{tarH} - defaults: {_controller: "ComurImageBundle:Upload:cropImage"} + defaults: {_controller: \Comur\ImageBundle\Controller\UploadController::cropImageAction } options: expose: true comur_api_image_library: path: /image-library - defaults: {_controller: "ComurImageBundle:Upload:getLibraryImages"} + defaults: {_controller: \Comur\ImageBundle\Controller\UploadController::getLibraryImagesAction } options: expose: true diff --git a/Resources/config/services.yml b/Resources/config/services.yml index 07716a06..c3098801 100644 --- a/Resources/config/services.yml +++ b/Resources/config/services.yml @@ -17,3 +17,8 @@ services: tags: - { name: twig.extension } arguments: ["%comur_image.cropped_image_dir%", "%comur_image.thumbs_dir%", "%comur_image.public_dir%", "%comur_image.translation_domain%", "%comur_image.gallery_dir%"] + + Comur\ImageBundle\Controller\: + autowire: true + resource: '../../Controller' + tags: ['controller.service_arguments'] diff --git a/Twig/ThumbExtension.php b/Twig/ThumbExtension.php index 37c400e9..6fba4e3c 100644 --- a/Twig/ThumbExtension.php +++ b/Twig/ThumbExtension.php @@ -2,9 +2,10 @@ namespace Comur\ImageBundle\Twig; use Twig\Extension\AbstractExtension; +use Twig\Extension\GlobalsInterface; use Twig\TwigFilter; -class ThumbExtension extends AbstractExtension +class ThumbExtension extends AbstractExtension implements GlobalsInterface { protected $croppedDir; protected $thumbsDir; @@ -65,7 +66,7 @@ public function getName() return 'comur_thumb_extension'; } - public function getGlobals() + public function getGlobals(): array { return array('comur_translation_domain' => $this->transDomain); } diff --git a/composer.json b/composer.json index 93b3794a..1c602cbb 100644 --- a/composer.json +++ b/composer.json @@ -15,16 +15,16 @@ "require": { "php": ">=7.1.3", "ext-gd": "*", - "symfony/http-foundation": "~3.4 || ~4.2", - "symfony/form": "~3.4 || ~4.2", - "symfony/validator": "~3.4 || ~4.2", - "symfony/routing": "~3.4 || ~4.2", - "symfony/config": "~3.4 || ~4.2", - "symfony/twig-bridge": "~3.4 || ~4.2", - "twig/twig": "~2.5 || ~3.0", + "symfony/http-foundation": "~4.2 || ~5.0 || ~6.0", + "symfony/form": "~4.2 || ~5.0 || ~6.0", + "symfony/validator": "~4.2 || ~5.0 || ~6.0", + "symfony/routing": "~4.2 || ~5.0 || ~6.0", + "symfony/config": "~4.2 || ~5.0 || ~6.0", + "symfony/translation": "~4.2 || ~5.0 || ~6.0", + "symfony/twig-bridge": "~4.2 || ~5.0 || ~6.0", + "twig/twig": "^1.41 || ^2.10 || ~3.0", "twig/extra-bundle": "@stable", - "friendsofsymfony/jsrouting-bundle": "@stable", - "jms/translation-bundle": "^1.2.2" + "friendsofsymfony/jsrouting-bundle": "@stable" }, "autoload": { "psr-4": {