From 720998bb93379758ab86ebe610510d6c5b28f1fe Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Thu, 26 May 2016 22:47:45 +0200 Subject: [PATCH 01/77] 4.x-dev --- UPGRADE-4.0.md | 10 ++++++++++ composer.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 UPGRADE-4.0.md diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md new file mode 100644 index 0000000000..c9d6994190 --- /dev/null +++ b/UPGRADE-4.0.md @@ -0,0 +1,10 @@ +UPGRADE FROM 3.x to 4.0 +======================= + +## Deprecations + +All the deprecated code introduced on 3.x is removed on 4.0. + +Please read [3.x](https://github.com/sonata-project/SonataMediaBundle/tree/3.x) upgrade guides for more information. + +See also the [diff code](https://github.com/sonata-project/SonataMediaBundle/compare/3.x...4.0.0). diff --git a/composer.json b/composer.json index 50502ada59..ec2328f43f 100644 --- a/composer.json +++ b/composer.json @@ -74,7 +74,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "4.x-dev" } } } From 9d34acc4fe3e97a26a0a674e697a02487e9b5f52 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Thu, 26 May 2016 23:22:40 +0200 Subject: [PATCH 02/77] DevKit updates (#1009) --- CONTRIBUTING.md | 8 ++++---- README.md | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c56c377d17..38c993e9dc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -114,15 +114,15 @@ Here is a short table resuming on which you have to start: Kind of modification | Backward Compatible (BC) | Type of release | Branch to target | Label | -------------------- | ------------------------ | --------------- | ----------------------- | ----- | -Bug fixes | Yes | Patch | `master` | | +Bug fixes | Yes | Patch | `3.x` | | Bug fixes | No (Only if no choice) | Major | `master` | | -Feature | Yes | Minor | `master` | | +Feature | Yes | Minor | `3.x` | | Feature | No (Only if no choice) | Major | `master` | | -Deprecation | Yes (Have to) | Minor | `master` | | +Deprecation | Yes (Have to) | Minor | `3.x` | | Deprecation removal | No (Can't be) | Major | `master` | | Notes: - * Branch `master` is the branch of the **latest stable** minor release and + * Branch `3.x` is the branch of the **latest stable** minor release and has to be used for Backward compatible PRs. * If you PR is not **Backward Compatible** but can be, it **must** be: * Changing a function/method signature? Prefer create a new one and deprecated the old one. diff --git a/README.md b/README.md index fc56a40d05..de8146916a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ Symfony SonataMediaBundle [![Monthly Downloads](https://poser.pugx.org/sonata-project/media-bundle/d/monthly)](https://packagist.org/packages/sonata-project/media-bundle) [![Daily Downloads](https://poser.pugx.org/sonata-project/media-bundle/d/daily)](https://packagist.org/packages/sonata-project/media-bundle) -[![Build Status](https://travis-ci.org/sonata-project/SonataMediaBundle.svg?branch=master)](https://travis-ci.org/sonata-project/SonataMediaBundle) +3.x status: [![Build Status](https://travis-ci.org/sonata-project/SonataMediaBundle.svg?branch=3.x)](https://travis-ci.org/sonata-project/SonataMediaBundle) + +master status: [![Build Status](https://travis-ci.org/sonata-project/SonataMediaBundle.svg?branch=master)](https://travis-ci.org/sonata-project/SonataMediaBundle) ## Documentation From ca9a64291850289d9e0d6f0ac4c23da1a44f8811 Mon Sep 17 00:00:00 2001 From: core23 Date: Sat, 14 Nov 2015 22:52:36 +0100 Subject: [PATCH 03/77] Remove 'wrap' property from GalleryBlock --- Block/GalleryBlockService.php | 5 ----- Resources/translations/SonataMediaBundle.bg.xliff | 4 ---- Resources/translations/SonataMediaBundle.de.xliff | 4 ---- Resources/translations/SonataMediaBundle.en.xliff | 4 ---- Resources/translations/SonataMediaBundle.es.xliff | 4 ---- Resources/translations/SonataMediaBundle.fa.xliff | 4 ---- Resources/translations/SonataMediaBundle.fi.xliff | 4 ---- Resources/translations/SonataMediaBundle.fr.xliff | 4 ---- Resources/translations/SonataMediaBundle.hu.xliff | 4 ---- Resources/translations/SonataMediaBundle.it.xliff | 4 ---- Resources/translations/SonataMediaBundle.ja.xliff | 4 ---- Resources/translations/SonataMediaBundle.lt.xliff | 4 ---- Resources/translations/SonataMediaBundle.nl.xliff | 4 ---- Resources/translations/SonataMediaBundle.pl.xliff | 4 ---- Resources/translations/SonataMediaBundle.pt_BR.xliff | 4 ---- Resources/translations/SonataMediaBundle.ro.xliff | 4 ---- Resources/translations/SonataMediaBundle.ru.xliff | 4 ---- Resources/translations/SonataMediaBundle.sl.xliff | 4 ---- Resources/translations/SonataMediaBundle.uk.xliff | 4 ---- UPGRADE-4.0.md | 4 ++++ 20 files changed, 4 insertions(+), 77 deletions(-) diff --git a/Block/GalleryBlockService.php b/Block/GalleryBlockService.php index dd25f66561..dd741cac47 100644 --- a/Block/GalleryBlockService.php +++ b/Block/GalleryBlockService.php @@ -90,7 +90,6 @@ public function configureSettings(OptionsResolver $resolver) 'format' => false, 'pauseTime' => 3000, 'startPaused' => false, - 'wrap' => true, 'template' => 'SonataMediaBundle:Block:block_gallery.html.twig', 'galleryId' => null, )); @@ -159,10 +158,6 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) 'required' => false, 'label' => 'form.label_start_paused', )), - array('wrap', 'checkbox', array( - 'required' => false, - 'label' => 'form.label_wrap', - )), ), 'translation_domain' => 'SonataMediaBundle', )); diff --git a/Resources/translations/SonataMediaBundle.bg.xliff b/Resources/translations/SonataMediaBundle.bg.xliff index 19a3916236..97f1e732b5 100644 --- a/Resources/translations/SonataMediaBundle.bg.xliff +++ b/Resources/translations/SonataMediaBundle.bg.xliff @@ -481,10 +481,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.de.xliff b/Resources/translations/SonataMediaBundle.de.xliff index 60e3ad0dac..ea669d8b54 100644 --- a/Resources/translations/SonataMediaBundle.de.xliff +++ b/Resources/translations/SonataMediaBundle.de.xliff @@ -489,10 +489,6 @@ form.label_start_paused Pausiert starten - - form.label_wrap - Umbrechen - form.label_orientation_left Linksbündig diff --git a/Resources/translations/SonataMediaBundle.en.xliff b/Resources/translations/SonataMediaBundle.en.xliff index c6ca9158d5..a6d86e80b0 100644 --- a/Resources/translations/SonataMediaBundle.en.xliff +++ b/Resources/translations/SonataMediaBundle.en.xliff @@ -489,10 +489,6 @@ form.label_start_paused Start paused - - form.label_wrap - Wrap - form.label_orientation_left Left diff --git a/Resources/translations/SonataMediaBundle.es.xliff b/Resources/translations/SonataMediaBundle.es.xliff index f6fe4c9d6e..bbe729e810 100644 --- a/Resources/translations/SonataMediaBundle.es.xliff +++ b/Resources/translations/SonataMediaBundle.es.xliff @@ -461,10 +461,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.fa.xliff b/Resources/translations/SonataMediaBundle.fa.xliff index f32d2b81bb..ac89e47551 100644 --- a/Resources/translations/SonataMediaBundle.fa.xliff +++ b/Resources/translations/SonataMediaBundle.fa.xliff @@ -485,10 +485,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.fi.xliff b/Resources/translations/SonataMediaBundle.fi.xliff index d335a8bd0c..7b68b7a233 100644 --- a/Resources/translations/SonataMediaBundle.fi.xliff +++ b/Resources/translations/SonataMediaBundle.fi.xliff @@ -489,10 +489,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.fr.xliff b/Resources/translations/SonataMediaBundle.fr.xliff index 4483266ac9..db66e26bcb 100644 --- a/Resources/translations/SonataMediaBundle.fr.xliff +++ b/Resources/translations/SonataMediaBundle.fr.xliff @@ -489,10 +489,6 @@ form.label_start_paused Démarrer en pause - - form.label_wrap - Encapsuleur HTML - form.label_orientation_left Gauche diff --git a/Resources/translations/SonataMediaBundle.hu.xliff b/Resources/translations/SonataMediaBundle.hu.xliff index 5a13d638b2..fbf62122c5 100644 --- a/Resources/translations/SonataMediaBundle.hu.xliff +++ b/Resources/translations/SonataMediaBundle.hu.xliff @@ -489,10 +489,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.it.xliff b/Resources/translations/SonataMediaBundle.it.xliff index 727caf9578..475a9f8eb6 100644 --- a/Resources/translations/SonataMediaBundle.it.xliff +++ b/Resources/translations/SonataMediaBundle.it.xliff @@ -489,10 +489,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.ja.xliff b/Resources/translations/SonataMediaBundle.ja.xliff index ee23efa6f2..bddcfdc623 100644 --- a/Resources/translations/SonataMediaBundle.ja.xliff +++ b/Resources/translations/SonataMediaBundle.ja.xliff @@ -457,10 +457,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.lt.xliff b/Resources/translations/SonataMediaBundle.lt.xliff index 365b6a3b95..fc50c25376 100644 --- a/Resources/translations/SonataMediaBundle.lt.xliff +++ b/Resources/translations/SonataMediaBundle.lt.xliff @@ -461,10 +461,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.nl.xliff b/Resources/translations/SonataMediaBundle.nl.xliff index 6e9b755bcd..9eeeea185a 100644 --- a/Resources/translations/SonataMediaBundle.nl.xliff +++ b/Resources/translations/SonataMediaBundle.nl.xliff @@ -489,10 +489,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.pl.xliff b/Resources/translations/SonataMediaBundle.pl.xliff index eb912d7957..1c1098125f 100644 --- a/Resources/translations/SonataMediaBundle.pl.xliff +++ b/Resources/translations/SonataMediaBundle.pl.xliff @@ -461,10 +461,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.pt_BR.xliff b/Resources/translations/SonataMediaBundle.pt_BR.xliff index 41ac766dd2..1a26bab7c6 100644 --- a/Resources/translations/SonataMediaBundle.pt_BR.xliff +++ b/Resources/translations/SonataMediaBundle.pt_BR.xliff @@ -453,10 +453,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.ro.xliff b/Resources/translations/SonataMediaBundle.ro.xliff index 82052d894b..4cf4b97ae2 100644 --- a/Resources/translations/SonataMediaBundle.ro.xliff +++ b/Resources/translations/SonataMediaBundle.ro.xliff @@ -489,10 +489,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.ru.xliff b/Resources/translations/SonataMediaBundle.ru.xliff index db187805bd..17f69badb8 100644 --- a/Resources/translations/SonataMediaBundle.ru.xliff +++ b/Resources/translations/SonataMediaBundle.ru.xliff @@ -461,10 +461,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.sl.xliff b/Resources/translations/SonataMediaBundle.sl.xliff index 9371f1fae5..aacbe88226 100644 --- a/Resources/translations/SonataMediaBundle.sl.xliff +++ b/Resources/translations/SonataMediaBundle.sl.xliff @@ -461,10 +461,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/Resources/translations/SonataMediaBundle.uk.xliff b/Resources/translations/SonataMediaBundle.uk.xliff index 27c635e058..7492ebe8d3 100644 --- a/Resources/translations/SonataMediaBundle.uk.xliff +++ b/Resources/translations/SonataMediaBundle.uk.xliff @@ -425,10 +425,6 @@ form.label_start_paused form.label_start_paused - - form.label_wrap - form.label_wrap - form.label_orientation_left form.label_orientation_left diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index c9d6994190..c70c480ee8 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -8,3 +8,7 @@ All the deprecated code introduced on 3.x is removed on 4.0. Please read [3.x](https://github.com/sonata-project/SonataMediaBundle/tree/3.x) upgrade guides for more information. See also the [diff code](https://github.com/sonata-project/SonataMediaBundle/compare/3.x...4.0.0). + +## Blocks + +The property `wrap` in `GalleryBlockService` was removed. You must create a custom block, if you still want to use ist. From 39bebdc8f21261d81f3fc84e37b0a38ede9fc49b Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Sun, 29 May 2016 10:07:27 +0200 Subject: [PATCH 04/77] DevKit updates (#1020) --- .travis.yml | 3 +++ .travis/after_success_test.sh | 4 ++++ .travis/install_test.sh | 4 ++++ Makefile | 2 +- README.md | 17 ++++++++++++++--- 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100755 .travis/after_success_test.sh diff --git a/.travis.yml b/.travis.yml index 05cce1fcd0..2ebc46f66d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -75,3 +75,6 @@ before_script: - if [ -x .travis/before_script_${TARGET}.sh ]; then .travis/before_script_${TARGET}.sh; fi; script: make $TARGET + +after_success: + - if [ -x .travis/after_success_${TARGET}.sh ]; then .travis/after_success_${TARGET}.sh; fi; diff --git a/.travis/after_success_test.sh b/.travis/after_success_test.sh new file mode 100755 index 0000000000..87158518b2 --- /dev/null +++ b/.travis/after_success_test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +set -ev + +coveralls -v diff --git a/.travis/install_test.sh b/.travis/install_test.sh index f496ff4193..b692108bbb 100755 --- a/.travis/install_test.sh +++ b/.travis/install_test.sh @@ -12,6 +12,10 @@ fi wget "https://phar.phpunit.de/${PHPUNIT_PHAR}" --output-document="${HOME}/bin/phpunit" chmod u+x "${HOME}/bin/phpunit" +# Coveralls client install +wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar --output-document="${HOME}/bin/coveralls" +chmod u+x "${HOME}/bin/coveralls" + # To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355 if [ "${COMPOSER_FLAGS}" = '--prefer-lowest' ]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet diff --git a/Makefile b/Makefile index 0394dd0070..c0e18e4f0f 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ all: @echo "Please choose a task." test: - phpunit -c phpunit.xml.dist + phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml docs: cd Resources/doc && sphinx-build -W -b html -d _build/doctrees . _build/html diff --git a/README.md b/README.md index de8146916a..feac35e1a0 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,10 @@ Symfony SonataMediaBundle [![Monthly Downloads](https://poser.pugx.org/sonata-project/media-bundle/d/monthly)](https://packagist.org/packages/sonata-project/media-bundle) [![Daily Downloads](https://poser.pugx.org/sonata-project/media-bundle/d/daily)](https://packagist.org/packages/sonata-project/media-bundle) -3.x status: [![Build Status](https://travis-ci.org/sonata-project/SonataMediaBundle.svg?branch=3.x)](https://travis-ci.org/sonata-project/SonataMediaBundle) - -master status: [![Build Status](https://travis-ci.org/sonata-project/SonataMediaBundle.svg?branch=master)](https://travis-ci.org/sonata-project/SonataMediaBundle) +Branch | Travis | Coveralls | +------ | ------ | --------- | +3.x | [![Build Status][travis_stable_badge]][travis_stable_link] | [![Coverage Status][coveralls_stable_badge]][coveralls_stable_link] | +master | [![Build Status][travis_unstable_badge]][travis_unstable_link] | [![Coverage Status][coveralls_unstable_badge]][coveralls_unstable_link] | ## Documentation @@ -28,3 +29,13 @@ If you think you find a bug or you have a feature idea to propose, feel free to ## License This package is available under the [MIT license](LICENSE). + +[travis_stable_badge]: https://travis-ci.org/sonata-project/SonataMediaBundle.svg?branch=3.x +[travis_stable_link]: https://travis-ci.org/sonata-project/SonataMediaBundle +[travis_unstable_badge]: https://travis-ci.org/sonata-project/SonataMediaBundle.svg?branch=master +[travis_unstable_link]: https://travis-ci.org/sonata-project/SonataMediaBundle + +[coveralls_stable_badge]: https://coveralls.io/repos/github/sonata-project/SonataMediaBundle/badge.svg?branch=3.x +[coveralls_stable_link]: https://coveralls.io/github/sonata-project/SonataMediaBundle?branch=3.x +[coveralls_unstable_badge]: https://coveralls.io/repos/github/sonata-project/SonataMediaBundle/badge.svg?branch=master +[coveralls_unstable_link]: https://coveralls.io/github/sonata-project/SonataMediaBundle?branch=master From 25f95237a7de5497d33d13c8ee415793bd795778 Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Sun, 29 May 2016 10:08:03 +0200 Subject: [PATCH 05/77] Applied fixes from StyleCI (#1023) --- Tests/Entity/GalleryManagerTest.php | 3 ++- Tests/Entity/MediaManagerTest.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/Entity/GalleryManagerTest.php b/Tests/Entity/GalleryManagerTest.php index 8c889f0727..1dbe4b0049 100644 --- a/Tests/Entity/GalleryManagerTest.php +++ b/Tests/Entity/GalleryManagerTest.php @@ -45,7 +45,8 @@ public function testGetPagerWithInvalidSort() { $self = $this; $this - ->getGalleryManager(function ($qb) use ($self) {}) + ->getGalleryManager(function ($qb) use ($self) { + }) ->getPager(array(), 1, 10, array('invalid' => 'ASC')); } diff --git a/Tests/Entity/MediaManagerTest.php b/Tests/Entity/MediaManagerTest.php index fc87fd567c..d4977fe206 100644 --- a/Tests/Entity/MediaManagerTest.php +++ b/Tests/Entity/MediaManagerTest.php @@ -41,7 +41,8 @@ public function testGetPagerWithInvalidSort() { $self = $this; $this - ->getMediaManager(function ($qb) use ($self) {}) + ->getMediaManager(function ($qb) use ($self) { + }) ->getPager(array(), 1, 10, array('invalid' => 'ASC')); } From 866072af66d9d17be07096f03364fdbc3a6add6e Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Mon, 30 May 2016 10:15:09 +0200 Subject: [PATCH 06/77] DevKit updates --- CONTRIBUTING.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 38c993e9dc..b8706b52d7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -84,14 +84,17 @@ on your PR explaining why you feel it is the case. #### The Change log -On each PR, the `CHANGELOG.md` file **has to be updated**. +For each PR, a change log must be provided. -There are few cases where the `CHANGELOG.md` file should not be touched: +There are few cases where no change log is necessary: * When you fix a bug on an unreleased feature. * When your PR concerns only the documentation (fix or improvement). -The change log note has to be put below the `## [Unreleased]` section. +**Do not** edit the `CHANGELOG.md` directly though, because having every +contributor write PR with changes in the same file, at roughly the same line is +a recipe for conflicts. Instead, fill in the dedicated section that should +appear in a textaread when submitting your PR. Your note can be put on one of these sections: From 5a3013c5f1545e17d2149a460e4f72361e5407a8 Mon Sep 17 00:00:00 2001 From: Christian Gripp Date: Fri, 3 Jun 2016 19:10:47 +0200 Subject: [PATCH 07/77] Removed deprecation on CloudFrontClient::setClient method (#885) --- CDN/CloudFront.php | 6 +----- Tests/CDN/CloudFrontTest.php | 12 ++---------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/CDN/CloudFront.php b/CDN/CloudFront.php index b3ba85c832..de7b04321c 100644 --- a/CDN/CloudFront.php +++ b/CDN/CloudFront.php @@ -151,12 +151,8 @@ public function flushPaths(array $paths) * * @param CloudFrontClient $client */ - public function setClient($client) + public function setClient(CloudFrontClient $client) { - if (!$client instanceof CloudFrontClient) { - @trigger_error('The '.__METHOD__.' expects a CloudFrontClient as parameter.', E_USER_DEPRECATED); - } - $this->client = $client; } diff --git a/Tests/CDN/CloudFrontTest.php b/Tests/CDN/CloudFrontTest.php index 79854ade94..8ec01fdf8f 100644 --- a/Tests/CDN/CloudFrontTest.php +++ b/Tests/CDN/CloudFrontTest.php @@ -21,7 +21,7 @@ class CloudFrontTest extends \PHPUnit_Framework_TestCase */ public function testLegacyCloudFront() { - $client = $this->getMock('CloudFrontClientSpy', array('createInvalidation'), array(), '', false); + $client = $this->getMock('\Aws\CloudFront\CloudFrontClient', array('createInvalidation'), array(), '', false); $client->expects($this->exactly(3))->method('createInvalidation')->will($this->returnValue(new CloudFrontResultSpy())); $cloudFront = $this->getMockBuilder('Sonata\MediaBundle\CDN\CloudFront') @@ -45,7 +45,7 @@ public function testLegacyCloudFront() public function testLegacyException() { $this->setExpectedException('\RuntimeException', 'Unable to flush : '); - $client = $this->getMock('CloudFrontClientSpy', array('createInvalidation'), array(), '', false); + $client = $this->getMock('\Aws\CloudFront\CloudFrontClient', array('createInvalidation'), array(), '', false); $client->expects($this->exactly(1))->method('createInvalidation')->will($this->returnValue(new CloudFrontResultSpy(true))); $cloudFront = $this->getMockBuilder('Sonata\MediaBundle\CDN\CloudFront') ->setConstructorArgs(array('/foo', 'secret', 'key', 'xxxxxxxxxxxxxx')) @@ -56,14 +56,6 @@ public function testLegacyException() } } -class CloudFrontClientSpy -{ - public function createInvalidation() - { - return new CloudFrontResultSpy(); - } -} - class CloudFrontResultSpy { protected $fail = false; From b6904a38e9c4e10849d713055690de4420f32202 Mon Sep 17 00:00:00 2001 From: Ahmet Akbana Date: Sat, 11 Jun 2016 16:19:59 +0200 Subject: [PATCH 08/77] Changed injection of container in SessionDownloadStrategy and added test (#1033) * changed the injection of container to session * updated test for SessionDownloadStrategy --- Security/SessionDownloadStrategy.php | 38 +++--------------- .../Security/SessionDownloadStrategyTest.php | 40 +------------------ 2 files changed, 6 insertions(+), 72 deletions(-) diff --git a/Security/SessionDownloadStrategy.php b/Security/SessionDownloadStrategy.php index 3441dd4034..cc15552629 100644 --- a/Security/SessionDownloadStrategy.php +++ b/Security/SessionDownloadStrategy.php @@ -12,26 +12,15 @@ namespace Sonata\MediaBundle\Security; use Sonata\MediaBundle\Model\MediaInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Translation\TranslatorInterface; /** - * Class SessionDownloadStrategy. - * * @author Ahmet Akbana */ class SessionDownloadStrategy implements DownloadStrategyInterface { - /** - * @var ContainerInterface - * - * @deprecated Since version 3.x, will be removed in 4.0. - * NEXT_MAJOR : remove this property - */ - protected $container; - /** * @var TranslatorInterface */ @@ -53,31 +42,14 @@ class SessionDownloadStrategy implements DownloadStrategyInterface private $session; /** - * @param TranslatorInterface $translator - * @param ContainerInterface|SessionInterface $session - * @param int $times + * @param TranslatorInterface $translator + * @param SessionInterface $session + * @param int $times */ - public function __construct(TranslatorInterface $translator, $session, $times) + public function __construct(TranslatorInterface $translator, SessionInterface $session, $times) { - // NEXT_MAJOR : remove this block and set session from parameter. - if ($session instanceof ContainerInterface) { - @trigger_error( - 'Using an instance of Symfony\Component\DependencyInjection\ContainerInterface is deprecated since - version 3.x and will be removed in 4.0. - Use Symfony\Component\HttpFoundation\Session\SessionInterface instead.', - E_USER_DEPRECATED - ); - - $this->session = $session->get('session'); - } elseif ($session instanceof SessionInterface) { - $this->session = $session; - } else { - throw new \InvalidArgumentException( - '$session should be an instance of Symfony\Component\HttpFoundation\Session\SessionInterface' - ); - } - $this->times = $times; + $this->session = $session; $this->translator = $translator; } diff --git a/Tests/Security/SessionDownloadStrategyTest.php b/Tests/Security/SessionDownloadStrategyTest.php index 0bcc6f1b56..10008bbc84 100644 --- a/Tests/Security/SessionDownloadStrategyTest.php +++ b/Tests/Security/SessionDownloadStrategyTest.php @@ -14,13 +14,11 @@ use Sonata\MediaBundle\Security\SessionDownloadStrategy; /** - * Class SessionDownloadStrategyTest. - * * @author Ahmet Akbana */ final class SessionDownloadStrategyTest extends \PHPUnit_Framework_TestCase { - public function testIsGrantedFalseWithGreaterSessionTime() + public function testIsGrantedFalse() { $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); $media = $this->getMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -49,40 +47,4 @@ public function testIsGrantedTrue() $strategy = new SessionDownloadStrategy($translator, $session, 1); $this->assertTrue($strategy->isGranted($media, $request)); } - - /** - * @group legacy - * NEXT_MAJOR: remove this method - */ - public function testIsGrantedTrueWithContainer() - { - $container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - - $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - $media = $this->getMock('Sonata\MediaBundle\Model\MediaInterface'); - $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); - $session = $this->getMock('Symfony\Component\HttpFoundation\Session\Session'); - - $session->expects($this->any()) - ->method('get') - ->willReturn(0); - - $container->expects($this->once()) - ->method('get') - ->willReturn($session); - - $strategy = new SessionDownloadStrategy($translator, $container, 1); - - $this->assertTrue($strategy->isGranted($media, $request)); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidArgumentException() - { - $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - - new SessionDownloadStrategy($translator, 'foo', 1); - } } From bbca025129e09fe593314b58c16069416d91e977 Mon Sep 17 00:00:00 2001 From: Christian Gripp Date: Sun, 12 Jun 2016 12:43:43 +0200 Subject: [PATCH 09/77] Support dev version of classification-bundle (#1059) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index a6efa1e150..e532e87730 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,7 @@ "sonata-project/notification-bundle": "^3.0", "sonata-project/easy-extends-bundle": "^2.1", "sonata-project/doctrine-extensions": "^1.0", - "sonata-project/classification-bundle": "^3.0", + "sonata-project/classification-bundle": "^3.0 || ^4.0@dev", "knplabs/gaufrette": "^0.1.6", "imagine/imagine": "^0.6", "kriswallsmith/buzz": "^0.15", From 86bee80f7740074eb35157f8b7f7104d3cef852c Mon Sep 17 00:00:00 2001 From: Christian Gripp Date: Sun, 12 Jun 2016 14:34:58 +0200 Subject: [PATCH 10/77] Added missing id getters (#867) --- Model/GalleryHasMediaInterface.php | 5 +++++ Model/GalleryInterface.php | 5 +++++ Tests/Controller/Api/GalleryControllerTest.php | 12 ++++++++++++ UPGRADE-4.0.md | 6 ++++++ 4 files changed, 28 insertions(+) diff --git a/Model/GalleryHasMediaInterface.php b/Model/GalleryHasMediaInterface.php index 0c7f269002..791e82d007 100644 --- a/Model/GalleryHasMediaInterface.php +++ b/Model/GalleryHasMediaInterface.php @@ -18,6 +18,11 @@ interface GalleryHasMediaInterface */ public function __toString(); + /** + * @return int + */ + public function getId(); + /** * @param bool $enabled */ diff --git a/Model/GalleryInterface.php b/Model/GalleryInterface.php index f473af2d10..1bb0c25dc4 100644 --- a/Model/GalleryInterface.php +++ b/Model/GalleryInterface.php @@ -18,6 +18,11 @@ interface GalleryInterface */ public function __toString(); + /** + * @return int + */ + public function getId(); + /** * Set name. * diff --git a/Tests/Controller/Api/GalleryControllerTest.php b/Tests/Controller/Api/GalleryControllerTest.php index 94cf76323e..bbb6fe639d 100644 --- a/Tests/Controller/Api/GalleryControllerTest.php +++ b/Tests/Controller/Api/GalleryControllerTest.php @@ -18,6 +18,18 @@ class GalleryTest extends GalleryHasMedia { + private $id; + + public function __construct() + { + parent::__construct(); + $this->id = rand(); + } + + public function getId() + { + return $this->id; + } } /** diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index c70c480ee8..00478b7226 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -12,3 +12,9 @@ See also the [diff code](https://github.com/sonata-project/SonataMediaBundle/com ## Blocks The property `wrap` in `GalleryBlockService` was removed. You must create a custom block, if you still want to use ist. + +## Models +If you have implemented a custom model, you must adapt the signature of the following new methods: + * `GalleryHasMediaInterface::getId` + * `GalleryInterface::getId` + From f7a629604a7ae7a36678c487c9381b14709118d3 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 13 Jun 2016 10:58:41 +0200 Subject: [PATCH 11/77] renamed GalleryHasMedia to GalleryItem (#948) --- Admin/GalleryAdmin.php | 8 +- ...HasMediaAdmin.php => GalleryItemAdmin.php} | 2 +- Block/GalleryBlockService.php | 12 +- Controller/Api/GalleryController.php | 107 ++++++----- DependencyInjection/Configuration.php | 2 +- DependencyInjection/SonataMediaExtension.php | 22 +-- Document/BaseGallery.php | 2 +- ...alleryHasMedia.php => BaseGalleryItem.php} | 4 +- Entity/BaseGallery.php | 2 +- ...alleryHasMedia.php => BaseGalleryItem.php} | 4 +- ...asMediaType.php => ApiGalleryItemType.php} | 2 +- Model/Gallery.php | 22 +-- Model/GalleryInterface.php | 12 +- .../{GalleryHasMedia.php => GalleryItem.php} | 2 +- ...Interface.php => GalleryItemInterface.php} | 2 +- Model/Media.php | 12 +- Model/MediaInterface.php | 8 +- PHPCR/BaseGallery.php | 32 ++-- ...alleryHasMedia.php => BaseGalleryItem.php} | 4 +- ...tory.php => BaseGalleryItemRepository.php} | 2 +- Resources/config/api_controllers.xml | 2 +- .../config/api_form_doctrine_mongodb.xml | 8 +- Resources/config/api_form_doctrine_orm.xml | 8 +- Resources/config/api_form_doctrine_phpcr.xml | 8 +- .../config/doctrine/BaseGallery.phpcr.xml | 2 +- ...ongodb.xml => BaseGalleryItem.mongodb.xml} | 2 +- ...sMedia.orm.xml => BaseGalleryItem.orm.xml} | 2 +- ...ia.phpcr.xml => BaseGalleryItem.phpcr.xml} | 2 +- ....skeleton => GalleryItem.orm.xml.skeleton} | 2 +- ...keleton => GalleryItem.phpcr.xml.skeleton} | 4 +- Resources/config/doctrine_mongodb_admin.xml | 16 +- Resources/config/doctrine_orm_admin.xml | 16 +- Resources/config/doctrine_phpcr_admin.xml | 16 +- .../config/serializer/Model.GalleryItem.xml | 11 ++ Resources/config/validation.xml | 2 +- .../doc/reference/advanced_configuration.rst | 2 +- Resources/doc/reference/installation.rst | 6 +- Resources/doc/reference/troubleshooting.rst | 6 +- .../translations/SonataMediaBundle.bg.xliff | 4 +- .../translations/SonataMediaBundle.de.xliff | 4 +- .../translations/SonataMediaBundle.en.xliff | 4 +- .../translations/SonataMediaBundle.es.xliff | 4 +- .../translations/SonataMediaBundle.fa.xliff | 4 +- .../translations/SonataMediaBundle.fi.xliff | 4 +- .../translations/SonataMediaBundle.fr.xliff | 4 +- .../translations/SonataMediaBundle.hu.xliff | 4 +- .../translations/SonataMediaBundle.it.xliff | 4 +- .../translations/SonataMediaBundle.ja.xliff | 4 +- .../translations/SonataMediaBundle.lt.xliff | 4 +- .../translations/SonataMediaBundle.nl.xliff | 4 +- .../translations/SonataMediaBundle.pl.xliff | 4 +- .../SonataMediaBundle.pt_BR.xliff | 4 +- .../translations/SonataMediaBundle.ro.xliff | 4 +- .../translations/SonataMediaBundle.ru.xliff | 4 +- .../translations/SonataMediaBundle.sl.xliff | 4 +- .../translations/SonataMediaBundle.uk.xliff | 4 +- Resources/views/Gallery/view.html.twig | 10 +- SonataMediaBundle.php | 2 +- .../Controller/Api/GalleryControllerTest.php | 169 +++++++++++------- UPGRADE-3.0.md | 6 + UPGRADE-4.0.md | 3 + 61 files changed, 363 insertions(+), 277 deletions(-) rename Admin/{GalleryHasMediaAdmin.php => GalleryItemAdmin.php} (96%) rename Document/{BaseGalleryHasMedia.php => BaseGalleryItem.php} (83%) rename Entity/{BaseGalleryHasMedia.php => BaseGalleryItem.php} (83%) rename Form/Type/{ApiGalleryHasMediaType.php => ApiGalleryItemType.php} (84%) rename Model/{GalleryHasMedia.php => GalleryItem.php} (97%) rename Model/{GalleryHasMediaInterface.php => GalleryItemInterface.php} (97%) rename PHPCR/{BaseGalleryHasMedia.php => BaseGalleryItem.php} (89%) rename PHPCR/{BaseGalleryHasMediaRepository.php => BaseGalleryItemRepository.php} (86%) rename Resources/config/doctrine/{BaseGalleryHasMedia.mongodb.xml => BaseGalleryItem.mongodb.xml} (98%) rename Resources/config/doctrine/{BaseGalleryHasMedia.orm.xml => BaseGalleryItem.orm.xml} (98%) rename Resources/config/doctrine/{BaseGalleryHasMedia.phpcr.xml => BaseGalleryItem.phpcr.xml} (96%) rename Resources/config/doctrine/{GalleryHasMedia.orm.xml.skeleton => GalleryItem.orm.xml.skeleton} (93%) rename Resources/config/doctrine/{GalleryHasMedia.phpcr.xml.skeleton => GalleryItem.phpcr.xml.skeleton} (96%) create mode 100644 Resources/config/serializer/Model.GalleryItem.xml create mode 100644 UPGRADE-3.0.md diff --git a/Admin/GalleryAdmin.php b/Admin/GalleryAdmin.php index c826b83ef9..c91fc7b5e4 100644 --- a/Admin/GalleryAdmin.php +++ b/Admin/GalleryAdmin.php @@ -47,7 +47,7 @@ public function prePersist($gallery) $gallery->setContext($parameters['context']); // fix weird bug with setter object not being call - $gallery->setGalleryHasMedias($gallery->getGalleryHasMedias()); + $gallery->setGalleryItems($gallery->getGalleryItems()); } /** @@ -56,7 +56,7 @@ public function prePersist($gallery) public function preUpdate($gallery) { // fix weird bug with setter object not being call - $gallery->setGalleryHasMedias($gallery->getGalleryHasMedias()); + $gallery->setGalleryItems($gallery->getGalleryItems()); } /** @@ -127,14 +127,14 @@ protected function configureFormFields(FormMapper $formMapper) ->add('defaultFormat', 'choice', array('choices' => $formats)) ->end() ->with('Gallery') - ->add('galleryHasMedias', 'sonata_type_collection', array( + ->add('galleryItems', 'sonata_type_collection', array( 'cascade_validation' => true, ), array( 'edit' => 'inline', 'inline' => 'table', 'sortable' => 'position', 'link_parameters' => array('context' => $context), - 'admin_code' => 'sonata.media.admin.gallery_has_media', + 'admin_code' => 'sonata.media.admin.gallery_item', ) ) ->end() diff --git a/Admin/GalleryHasMediaAdmin.php b/Admin/GalleryItemAdmin.php similarity index 96% rename from Admin/GalleryHasMediaAdmin.php rename to Admin/GalleryItemAdmin.php index a61b0ec894..7c234c67fb 100644 --- a/Admin/GalleryHasMediaAdmin.php +++ b/Admin/GalleryItemAdmin.php @@ -15,7 +15,7 @@ use Sonata\AdminBundle\Datagrid\ListMapper; use Sonata\AdminBundle\Form\FormMapper; -class GalleryHasMediaAdmin extends AbstractAdmin +class GalleryItemAdmin extends AbstractAdmin { /** * {@inheritdoc} diff --git a/Block/GalleryBlockService.php b/Block/GalleryBlockService.php index dd741cac47..fe4963c793 100644 --- a/Block/GalleryBlockService.php +++ b/Block/GalleryBlockService.php @@ -226,22 +226,22 @@ public function getBlockMetadata($code = null) private function buildElements(GalleryInterface $gallery) { $elements = array(); - foreach ($gallery->getGalleryHasMedias() as $galleryHasMedia) { - if (!$galleryHasMedia->getEnabled()) { + foreach ($gallery->getGalleryItems() as $galleryItem) { + if (!$galleryItem->getEnabled()) { continue; } - $type = $this->getMediaType($galleryHasMedia->getMedia()); + $type = $this->getMediaType($galleryItem->getMedia()); if (!$type) { continue; } $elements[] = array( - 'title' => $galleryHasMedia->getMedia()->getName(), - 'caption' => $galleryHasMedia->getMedia()->getDescription(), + 'title' => $galleryItem->getMedia()->getName(), + 'caption' => $galleryItem->getMedia()->getDescription(), 'type' => $type, - 'media' => $galleryHasMedia->getMedia(), + 'media' => $galleryItem->getMedia(), ); } diff --git a/Controller/Api/GalleryController.php b/Controller/Api/GalleryController.php index 864c1403c9..01e8cb3de3 100644 --- a/Controller/Api/GalleryController.php +++ b/Controller/Api/GalleryController.php @@ -18,8 +18,8 @@ use JMS\Serializer\SerializationContext; use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Sonata\DatagridBundle\Pager\PagerInterface; -use Sonata\MediaBundle\Model\GalleryHasMediaInterface; use Sonata\MediaBundle\Model\GalleryInterface; +use Sonata\MediaBundle\Model\GalleryItemInterface; use Sonata\MediaBundle\Model\GalleryManagerInterface; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Model\MediaManagerInterface; @@ -53,7 +53,7 @@ class GalleryController /** * @var string */ - protected $galleryHasMediaClass; + protected $galleryItemClass; /** * Constructor. @@ -61,14 +61,14 @@ class GalleryController * @param GalleryManagerInterface $galleryManager * @param MediaManagerInterface $mediaManager * @param FormFactoryInterface $formFactory - * @param string $galleryHasMediaClass + * @param string $galleryItemClass */ - public function __construct(GalleryManagerInterface $galleryManager, MediaManagerInterface $mediaManager, FormFactoryInterface $formFactory, $galleryHasMediaClass) + public function __construct(GalleryManagerInterface $galleryManager, MediaManagerInterface $mediaManager, FormFactoryInterface $formFactory, $galleryItemClass) { $this->galleryManager = $galleryManager; $this->mediaManager = $mediaManager; $this->formFactory = $formFactory; - $this->galleryHasMediaClass = $galleryHasMediaClass; + $this->galleryItemClass = $galleryItemClass; } /** @@ -79,10 +79,33 @@ public function __construct(GalleryManagerInterface $galleryManager, MediaManage * output={"class"="Sonata\DatagridBundle\Pager\PagerInterface", "groups"="sonata_api_read"} * ) * - * @QueryParam(name="page", requirements="\d+", default="1", description="Page for gallery list pagination") - * @QueryParam(name="count", requirements="\d+", default="10", description="Number of galleries by page") - * @QueryParam(name="enabled", requirements="0|1", nullable=true, strict=true, description="Enabled/Disabled galleries filter") - * @QueryParam(name="orderBy", array=true, requirements="ASC|DESC", nullable=true, strict=true, description="Order by array (key is field, value is direction)") + * @QueryParam( + * name="page", + * requirements="\d+", + * default="1", + * description="Page for gallery list pagination" + * ) + * @QueryParam( + * name="count", + * requirements="\d+", + * default="10", + * description="Number of galleries by page" + * ) + * @QueryParam( + * name="enabled", + * requirements="0|1", + * nullable=true, + * strict=true, + * description="Enabled/Disabled galleries filter" + * ) + * @QueryParam( + * name="orderBy", + * array=true, + * requirements="ASC|DESC", + * nullable=true, + * strict=true, + * description="Order by array (key is field, value is direction)" + * ) * * @View(serializerGroups="sonata_api_read", serializerEnableMaxDepthChecks=true) * @@ -163,24 +186,24 @@ public function getGalleryAction($id) */ public function getGalleryMediasAction($id) { - $ghms = $this->getGallery($id)->getGalleryHasMedias(); + $galleryItems = $this->getGallery($id)->getGalleryItems(); $media = array(); - foreach ($ghms as $ghm) { - $media[] = $ghm->getMedia(); + foreach ($galleryItems as $galleryItem) { + $media[] = $galleryItem->getMedia(); } return $media; } /** - * Retrieves the galleryhasmedias of specified gallery. + * Retrieves the gallery items of specified gallery. * * @ApiDoc( * requirements={ * {"name"="id", "dataType"="integer", "requirement"="\d+", "description"="gallery id"} * }, - * output={"class"="Sonata\MediaBundle\Model\GalleryHasMedia", "groups"="sonata_api_read"}, + * output={"class"="Sonata\MediaBundle\Model\GalleryItem", "groups"="sonata_api_read"}, * statusCodes={ * 200="Returned when successful", * 404="Returned when gallery is not found" @@ -191,11 +214,11 @@ public function getGalleryMediasAction($id) * * @param $id * - * @return GalleryHasMediaInterface[] + * @return GalleryItemInterface[] */ - public function getGalleryGalleryhasmediasAction($id) + public function getGalleryGalleryItemAction($id) { - return $this->getGallery($id)->getGalleryHasMedias(); + return $this->getGallery($id)->getGalleryItems(); } /** @@ -257,7 +280,7 @@ public function putGalleryAction($id, Request $request) * {"name"="galleryId", "dataType"="integer", "requirement"="\d+", "description"="gallery identifier"}, * {"name"="mediaId", "dataType"="integer", "requirement"="\d+", "description"="media identifier"} * }, - * input={"class"="sonata_media_api_form_gallery_has_media", "name"="", "groups"={"sonata_api_write"}}, + * input={"class"="sonata_media_api_form_gallery_item", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="sonata_media_api_form_gallery", "groups"={"sonata_api_read"}}, * statusCodes={ * 200="Returned when successful", @@ -273,20 +296,20 @@ public function putGalleryAction($id, Request $request) * * @throws NotFoundHttpException */ - public function postGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Request $request) + public function postGalleryMediaGalleryItemAction($galleryId, $mediaId, Request $request) { $gallery = $this->getGallery($galleryId); $media = $this->getMedia($mediaId); - foreach ($gallery->getGalleryHasMedias() as $galleryHasMedia) { - if ($galleryHasMedia->getMedia()->getId() == $media->getId()) { + foreach ($gallery->getGalleryItems() as $galleryItem) { + if ($galleryItem->getMedia()->getId() == $media->getId()) { return FOSRestView::create(array( 'error' => sprintf('Gallery "%s" already has media "%s"', $galleryId, $mediaId), ), 400); } } - return $this->handleWriteGalleryhasmedia($gallery, $media, null, $request); + return $this->handleWriteGalleryItem($gallery, $media, null, $request); } /** @@ -297,7 +320,7 @@ public function postGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Requ * {"name"="galleryId", "dataType"="integer", "requirement"="\d+", "description"="gallery identifier"}, * {"name"="mediaId", "dataType"="integer", "requirement"="\d+", "description"="media identifier"} * }, - * input={"class"="sonata_media_api_form_gallery_has_media", "name"="", "groups"={"sonata_api_write"}}, + * input={"class"="sonata_media_api_form_gallery_item", "name"="", "groups"={"sonata_api_write"}}, * output={"class"="sonata_media_api_form_gallery", "groups"={"sonata_api_read"}}, * statusCodes={ * 200="Returned when successful", @@ -313,14 +336,14 @@ public function postGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Requ * * @throws NotFoundHttpException */ - public function putGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Request $request) + public function putGalleryMediaGalleryItemAction($galleryId, $mediaId, Request $request) { $gallery = $this->getGallery($galleryId); $media = $this->getMedia($mediaId); - foreach ($gallery->getGalleryHasMedias() as $galleryHasMedia) { - if ($galleryHasMedia->getMedia()->getId() == $media->getId()) { - return $this->handleWriteGalleryhasmedia($gallery, $media, $galleryHasMedia, $request); + foreach ($gallery->getGalleryItems() as $galleryItem) { + if ($galleryItem->getMedia()->getId() == $media->getId()) { + return $this->handleWriteGalleryItem($gallery, $media, $galleryItem, $request); } } @@ -349,14 +372,14 @@ public function putGalleryMediaGalleryhasmediaAction($galleryId, $mediaId, Reque * * @throws NotFoundHttpException */ - public function deleteGalleryMediaGalleryhasmediaAction($galleryId, $mediaId) + public function deleteGalleryMediaGalleryItemAction($galleryId, $mediaId) { $gallery = $this->getGallery($galleryId); $media = $this->getMedia($mediaId); - foreach ($gallery->getGalleryHasMedias() as $key => $galleryHasMedia) { - if ($galleryHasMedia->getMedia()->getId() == $media->getId()) { - $gallery->getGalleryHasMedias()->remove($key); + foreach ($gallery->getGalleryItems() as $key => $galleryItem) { + if ($galleryItem->getMedia()->getId() == $media->getId()) { + $gallery->getGalleryItems()->remove($key); $this->getGalleryManager()->save($gallery); return array('deleted' => true); @@ -398,31 +421,31 @@ public function deleteGalleryAction($id) } /** - * Write a GalleryHasMedia, this method is used by both POST and PUT action methods. + * Write a GalleryItem, this method is used by both POST and PUT action methods. * - * @param GalleryInterface $gallery - * @param MediaInterface $media - * @param GalleryHasMediaInterface $galleryHasMedia - * @param Request $request + * @param GalleryInterface $gallery + * @param MediaInterface $media + * @param GalleryItemInterface $galleryItem + * @param Request $request * * @return FormInterface */ - protected function handleWriteGalleryhasmedia(GalleryInterface $gallery, MediaInterface $media, GalleryHasMediaInterface $galleryHasMedia = null, Request $request) + protected function handleWriteGalleryItem(GalleryInterface $gallery, MediaInterface $media, GalleryItemInterface $galleryItem = null, Request $request) { - $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery_has_media', $galleryHasMedia, array( + $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery_item', $galleryItem, array( 'csrf_protection' => false, )); $form->handleRequest($request); if ($form->isValid()) { - $galleryHasMedia = $form->getData(); - $galleryHasMedia->setMedia($media); + $galleryItem = $form->getData(); + $galleryItem->setMedia($media); - $gallery->addGalleryHasMedias($galleryHasMedia); + $gallery->addGalleryItem($galleryItem); $this->galleryManager->save($gallery); - $view = FOSRestView::create($galleryHasMedia); + $view = FOSRestView::create($galleryItem); $serializationContext = SerializationContext::create(); $serializationContext->setGroups(array('sonata_api_read')); $serializationContext->enableMaxDepthChecks(); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index eab8f9ef5f..b3358eef21 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -417,7 +417,7 @@ private function addModelSection(ArrayNodeDefinition $node) ->children() ->scalarNode('media')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Media')->end() ->scalarNode('gallery')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\Gallery')->end() - ->scalarNode('gallery_has_media')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\GalleryHasMedia')->end() + ->scalarNode('gallery_item')->defaultValue('Application\\Sonata\\MediaBundle\\Entity\\GalleryItem')->end() ->scalarNode('category')->defaultValue('Application\\Sonata\\ClassificationBundle\\Entity\\Category')->end() ->end() ->end() diff --git a/DependencyInjection/SonataMediaExtension.php b/DependencyInjection/SonataMediaExtension.php index 4518bd3964..e17d2e12b4 100644 --- a/DependencyInjection/SonataMediaExtension.php +++ b/DependencyInjection/SonataMediaExtension.php @@ -201,7 +201,7 @@ public function configureParameterClass(ContainerBuilder $container, array $conf { $container->setParameter('sonata.media.admin.media.entity', $config['class']['media']); $container->setParameter('sonata.media.admin.gallery.entity', $config['class']['gallery']); - $container->setParameter('sonata.media.admin.gallery_has_media.entity', $config['class']['gallery_has_media']); + $container->setParameter('sonata.media.admin.gallery_item.entity', $config['class']['gallery_item']); $container->setParameter('sonata.media.media.class', $config['class']['media']); $container->setParameter('sonata.media.gallery.class', $config['class']['gallery']); @@ -217,8 +217,8 @@ public function registerDoctrineMapping(array $config) $collector = DoctrineCollector::getInstance(); $collector->addAssociation($config['class']['media'], 'mapOneToMany', array( - 'fieldName' => 'galleryHasMedias', - 'targetEntity' => $config['class']['gallery_has_media'], + 'fieldName' => 'galleryItems', + 'targetEntity' => $config['class']['gallery_item'], 'cascade' => array( 'persist', ), @@ -226,14 +226,14 @@ public function registerDoctrineMapping(array $config) 'orphanRemoval' => false, )); - $collector->addAssociation($config['class']['gallery_has_media'], 'mapManyToOne', array( + $collector->addAssociation($config['class']['gallery_item'], 'mapManyToOne', array( 'fieldName' => 'gallery', 'targetEntity' => $config['class']['gallery'], 'cascade' => array( 'persist', ), 'mappedBy' => null, - 'inversedBy' => 'galleryHasMedias', + 'inversedBy' => 'galleryItems', 'joinColumns' => array( array( 'name' => 'gallery_id', @@ -243,14 +243,14 @@ public function registerDoctrineMapping(array $config) 'orphanRemoval' => false, )); - $collector->addAssociation($config['class']['gallery_has_media'], 'mapManyToOne', array( + $collector->addAssociation($config['class']['gallery_item'], 'mapManyToOne', array( 'fieldName' => 'media', 'targetEntity' => $config['class']['media'], 'cascade' => array( 'persist', ), 'mappedBy' => null, - 'inversedBy' => 'galleryHasMedias', + 'inversedBy' => 'galleryItems', 'joinColumns' => array( array( 'name' => 'media_id', @@ -261,8 +261,8 @@ public function registerDoctrineMapping(array $config) )); $collector->addAssociation($config['class']['gallery'], 'mapOneToMany', array( - 'fieldName' => 'galleryHasMedias', - 'targetEntity' => $config['class']['gallery_has_media'], + 'fieldName' => 'galleryItems', + 'targetEntity' => $config['class']['gallery_item'], 'cascade' => array( 'persist', ), @@ -495,8 +495,8 @@ public function configureClassesToCompile() 'Sonata\\MediaBundle\\Metadata\\NoopMetadataBuilder', 'Sonata\\MediaBundle\\Metadata\\ProxyMetadataBuilder', 'Sonata\\MediaBundle\\Model\\Gallery', - 'Sonata\\MediaBundle\\Model\\GalleryHasMedia', - 'Sonata\\MediaBundle\\Model\\GalleryHasMediaInterface', + 'Sonata\\MediaBundle\\Model\\GalleryItem', + 'Sonata\\MediaBundle\\Model\\GalleryItemInterface', 'Sonata\\MediaBundle\\Model\\GalleryInterface', 'Sonata\\MediaBundle\\Model\\GalleryManager', 'Sonata\\MediaBundle\\Model\\GalleryManagerInterface', diff --git a/Document/BaseGallery.php b/Document/BaseGallery.php index e4100ead4a..8644f46a0b 100644 --- a/Document/BaseGallery.php +++ b/Document/BaseGallery.php @@ -24,7 +24,7 @@ abstract class BaseGallery extends Gallery */ public function __construct() { - $this->galleryHasMedias = new ArrayCollection(); + $this->galleryItems = new ArrayCollection(); } /** diff --git a/Document/BaseGalleryHasMedia.php b/Document/BaseGalleryItem.php similarity index 83% rename from Document/BaseGalleryHasMedia.php rename to Document/BaseGalleryItem.php index bb763eb174..d527045b9e 100644 --- a/Document/BaseGalleryHasMedia.php +++ b/Document/BaseGalleryItem.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Document; -use Sonata\MediaBundle\Model\GalleryHasMedia; +use Sonata\MediaBundle\Model\GalleryItem; -abstract class BaseGalleryHasMedia extends GalleryHasMedia +abstract class BaseGalleryItem extends GalleryItem { public function prePersist() { diff --git a/Entity/BaseGallery.php b/Entity/BaseGallery.php index 2f199d195a..54b0f18668 100644 --- a/Entity/BaseGallery.php +++ b/Entity/BaseGallery.php @@ -24,7 +24,7 @@ abstract class BaseGallery extends Gallery */ public function __construct() { - $this->galleryHasMedias = new ArrayCollection(); + $this->galleryItems = new ArrayCollection(); } /** diff --git a/Entity/BaseGalleryHasMedia.php b/Entity/BaseGalleryItem.php similarity index 83% rename from Entity/BaseGalleryHasMedia.php rename to Entity/BaseGalleryItem.php index 4f5f6398fd..6fae702618 100644 --- a/Entity/BaseGalleryHasMedia.php +++ b/Entity/BaseGalleryItem.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Entity; -use Sonata\MediaBundle\Model\GalleryHasMedia; +use Sonata\MediaBundle\Model\GalleryItem; -abstract class BaseGalleryHasMedia extends GalleryHasMedia +abstract class BaseGalleryItem extends GalleryItem { public function prePersist() { diff --git a/Form/Type/ApiGalleryHasMediaType.php b/Form/Type/ApiGalleryItemType.php similarity index 84% rename from Form/Type/ApiGalleryHasMediaType.php rename to Form/Type/ApiGalleryItemType.php index b49aff6b4e..9821dbb529 100644 --- a/Form/Type/ApiGalleryHasMediaType.php +++ b/Form/Type/ApiGalleryItemType.php @@ -13,6 +13,6 @@ use Sonata\CoreBundle\Form\Type\BaseDoctrineORMSerializationType; -class ApiGalleryHasMediaType extends BaseDoctrineORMSerializationType +class ApiGalleryItemType extends BaseDoctrineORMSerializationType { } diff --git a/Model/Gallery.php b/Model/Gallery.php index 51fd375f6a..af92dd93b0 100644 --- a/Model/Gallery.php +++ b/Model/Gallery.php @@ -46,9 +46,9 @@ abstract class Gallery implements GalleryInterface protected $defaultFormat; /** - * @var GalleryHasMediaInterface[] + * @var GalleryItemInterface[] */ - protected $galleryHasMedias; + protected $galleryItems; /** * {@inheritdoc} @@ -141,31 +141,31 @@ public function getDefaultFormat() /** * {@inheritdoc} */ - public function setGalleryHasMedias($galleryHasMedias) + public function setGalleryItems($galleryItems) { - $this->galleryHasMedias = new ArrayCollection(); + $this->galleryItems = new ArrayCollection(); - foreach ($galleryHasMedias as $galleryHasMedia) { - $this->addGalleryHasMedias($galleryHasMedia); + foreach ($galleryItems as $galleryItem) { + $this->addGalleryItem($galleryItem); } } /** * {@inheritdoc} */ - public function getGalleryHasMedias() + public function getGalleryItems() { - return $this->galleryHasMedias; + return $this->galleryItems; } /** * {@inheritdoc} */ - public function addGalleryHasMedias(GalleryHasMediaInterface $galleryHasMedia) + public function addGalleryItem(GalleryItemInterface $galleryItem) { - $galleryHasMedia->setGallery($this); + $galleryItem->setGallery($this); - $this->galleryHasMedias[] = $galleryHasMedia; + $this->galleryItems[] = $galleryItem; } /** diff --git a/Model/GalleryInterface.php b/Model/GalleryInterface.php index 1bb0c25dc4..40f21cae66 100644 --- a/Model/GalleryInterface.php +++ b/Model/GalleryInterface.php @@ -102,17 +102,17 @@ public function setDefaultFormat($defaultFormat); public function getDefaultFormat(); /** - * @param array $galleryHasMedias + * @param array $galleryItems */ - public function setGalleryHasMedias($galleryHasMedias); + public function setGalleryItems($galleryItems); /** - * @return GalleryHasMediaInterface[] + * @return GalleryItemInterface[] */ - public function getGalleryHasMedias(); + public function getGalleryItems(); /** - * @param GalleryHasMediaInterface $galleryHasMedia + * @param GalleryItemInterface $galleryItem */ - public function addGalleryHasMedias(GalleryHasMediaInterface $galleryHasMedia); + public function addGalleryItem(GalleryItemInterface $galleryItem); } diff --git a/Model/GalleryHasMedia.php b/Model/GalleryItem.php similarity index 97% rename from Model/GalleryHasMedia.php rename to Model/GalleryItem.php index 7bf2fdfb3c..a4605f8c15 100644 --- a/Model/GalleryHasMedia.php +++ b/Model/GalleryItem.php @@ -11,7 +11,7 @@ namespace Sonata\MediaBundle\Model; -abstract class GalleryHasMedia implements GalleryHasMediaInterface +abstract class GalleryItem implements GalleryItemInterface { /** * @var MediaInterface diff --git a/Model/GalleryHasMediaInterface.php b/Model/GalleryItemInterface.php similarity index 97% rename from Model/GalleryHasMediaInterface.php rename to Model/GalleryItemInterface.php index 791e82d007..75c4aae3ef 100644 --- a/Model/GalleryHasMediaInterface.php +++ b/Model/GalleryItemInterface.php @@ -11,7 +11,7 @@ namespace Sonata\MediaBundle\Model; -interface GalleryHasMediaInterface +interface GalleryItemInterface { /** * @return string diff --git a/Model/Media.php b/Model/Media.php index 2afbd2def0..e772ef3d70 100644 --- a/Model/Media.php +++ b/Model/Media.php @@ -134,9 +134,9 @@ abstract class Media implements MediaInterface protected $size; /** - * @var GalleryHasMediaInterface[] + * @var GalleryItemInterface[] */ - protected $galleryHasMedias; + protected $galleryItems; /** * @var CategoryInterface @@ -590,17 +590,17 @@ public function getBox() /** * {@inheritdoc} */ - public function setGalleryHasMedias($galleryHasMedias) + public function setGalleryItems($galleryItems) { - $this->galleryHasMedias = $galleryHasMedias; + $this->galleryItems = $galleryItems; } /** * {@inheritdoc} */ - public function getGalleryHasMedias() + public function getGalleryItems() { - return $this->galleryHasMedias; + return $this->galleryItems; } /** diff --git a/Model/MediaInterface.php b/Model/MediaInterface.php index 6e7e5a953d..5045044468 100644 --- a/Model/MediaInterface.php +++ b/Model/MediaInterface.php @@ -367,14 +367,14 @@ public function getCdnStatus(); public function getBox(); /** - * @param GalleryHasMediaInterface[] $galleryHasMedias + * @param GalleryItemInterface[] $galleryItems */ - public function setGalleryHasMedias($galleryHasMedias); + public function setGalleryItems($galleryItems); /** - * @return GalleryHasMediaInterface[] + * @return GalleryItemInterface[] */ - public function getGalleryHasMedias(); + public function getGalleryItems(); /** * @return string diff --git a/PHPCR/BaseGallery.php b/PHPCR/BaseGallery.php index c89a730978..7b708f957e 100644 --- a/PHPCR/BaseGallery.php +++ b/PHPCR/BaseGallery.php @@ -12,7 +12,7 @@ namespace Sonata\MediaBundle\PHPCR; use Sonata\MediaBundle\Model\Gallery; -use Sonata\MediaBundle\Model\GalleryHasMediaInterface; +use Sonata\MediaBundle\Model\GalleryItemInterface; /** * Bundle\MediaBundle\Document\BaseGallery. @@ -29,7 +29,7 @@ abstract class BaseGallery extends Gallery */ public function __construct() { - $this->galleryHasMedias = new \Doctrine\Common\Collections\ArrayCollection(); + $this->galleryItems = new \Doctrine\Common\Collections\ArrayCollection(); } /** @@ -45,18 +45,18 @@ public function getUuid() /** * {@inheritdoc} */ - public function addGalleryHasMedias(GalleryHasMediaInterface $galleryHasMedia) + public function addGalleryItem(GalleryItemInterface $galleryItem) { - $galleryHasMedia->setGallery($this); + $galleryItem->setGallery($this); - // set nodename of GalleryHasMedia - if (!$galleryHasMedia->getNodename()) { - $galleryHasMedia->setNodename( - 'media'.($this->galleryHasMedias->count() + 1) + // set nodename of GalleryItem + if (!$galleryItem->getNodename()) { + $galleryItem->setNodename( + 'media'.($this->galleryItems->count() + 1) ); } - $this->galleryHasMedias->set($galleryHasMedia->getNodename(), $galleryHasMedia); + $this->galleryItems->set($galleryItem->getNodename(), $galleryItem); } /** @@ -67,7 +67,7 @@ public function prePersist() $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); - $this->reorderGalleryHasMedia(); + $this->reorderGalleryItems(); } /** @@ -77,18 +77,18 @@ public function preUpdate() { $this->updatedAt = new \DateTime(); - $this->reorderGalleryHasMedia(); + $this->reorderGalleryItems(); } /** - * Reorders $galleryHasMedia items based on their position. + * Reorders gallery items based on their position. */ - public function reorderGalleryHasMedia() + public function reorderGalleryItems() { - if ($this->getGalleryHasMedias() && $this->getGalleryHasMedias() instanceof \IteratorAggregate) { + if ($this->getGalleryItems() && $this->getGalleryItems() instanceof \IteratorAggregate) { // reorder - $iterator = $this->getGalleryHasMedias()->getIterator(); + $iterator = $this->getGalleryItems()->getIterator(); $iterator->uasort(function ($a, $b) { if ($a->getPosition() === $b->getPosition()) { @@ -98,7 +98,7 @@ public function reorderGalleryHasMedia() return $a->getPosition() > $b->getPosition() ? 1 : -1; }); - $this->setGalleryHasMedias($iterator); + $this->setGalleryItems($iterator); } } } diff --git a/PHPCR/BaseGalleryHasMedia.php b/PHPCR/BaseGalleryItem.php similarity index 89% rename from PHPCR/BaseGalleryHasMedia.php rename to PHPCR/BaseGalleryItem.php index 2e41f21acf..a5d72f1d8c 100644 --- a/PHPCR/BaseGalleryHasMedia.php +++ b/PHPCR/BaseGalleryItem.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\PHPCR; -use Sonata\MediaBundle\Model\GalleryHasMedia; +use Sonata\MediaBundle\Model\GalleryItem; -abstract class BaseGalleryHasMedia extends GalleryHasMedia +abstract class BaseGalleryItem extends GalleryItem { /** * @var string diff --git a/PHPCR/BaseGalleryHasMediaRepository.php b/PHPCR/BaseGalleryItemRepository.php similarity index 86% rename from PHPCR/BaseGalleryHasMediaRepository.php rename to PHPCR/BaseGalleryItemRepository.php index ff73f53a63..dd321fd846 100644 --- a/PHPCR/BaseGalleryHasMediaRepository.php +++ b/PHPCR/BaseGalleryItemRepository.php @@ -14,7 +14,7 @@ use Doctrine\ODM\PHPCR\DocumentRepository; use Doctrine\ODM\PHPCR\Id\RepositoryIdInterface; -class BaseGalleryHasMediaRepository extends DocumentRepository implements RepositoryIdInterface +class BaseGalleryItemRepository extends DocumentRepository implements RepositoryIdInterface { /** * @param mixed $document diff --git a/Resources/config/api_controllers.xml b/Resources/config/api_controllers.xml index 381653973d..1db206879e 100644 --- a/Resources/config/api_controllers.xml +++ b/Resources/config/api_controllers.xml @@ -5,7 +5,7 @@ - %sonata.media.admin.gallery_has_media.entity% + %sonata.media.admin.gallery_item.entity% diff --git a/Resources/config/api_form_doctrine_mongodb.xml b/Resources/config/api_form_doctrine_mongodb.xml index 36d0261fc7..c807fa4cb0 100644 --- a/Resources/config/api_form_doctrine_mongodb.xml +++ b/Resources/config/api_form_doctrine_mongodb.xml @@ -22,12 +22,12 @@ %sonata.media.admin.gallery.entity% sonata_api_write - - + + - sonata_media_api_form_gallery_has_media - %sonata.media.admin.gallery_has_media.entity% + sonata_media_api_form_gallery_item + %sonata.media.admin.gallery_item.entity% sonata_api_write diff --git a/Resources/config/api_form_doctrine_orm.xml b/Resources/config/api_form_doctrine_orm.xml index 42abf5d8d3..7919ace1f5 100644 --- a/Resources/config/api_form_doctrine_orm.xml +++ b/Resources/config/api_form_doctrine_orm.xml @@ -22,12 +22,12 @@ %sonata.media.admin.gallery.entity% sonata_api_write - - + + - sonata_media_api_form_gallery_has_media - %sonata.media.admin.gallery_has_media.entity% + sonata_media_api_form_gallery_item + %sonata.media.admin.gallery_item.entity% sonata_api_write diff --git a/Resources/config/api_form_doctrine_phpcr.xml b/Resources/config/api_form_doctrine_phpcr.xml index dd3a3fb336..cf0ce63f5e 100644 --- a/Resources/config/api_form_doctrine_phpcr.xml +++ b/Resources/config/api_form_doctrine_phpcr.xml @@ -22,12 +22,12 @@ %sonata.media.admin.gallery.entity% sonata_api_write - - + + - sonata_media_api_form_gallery_has_media - %sonata.media.admin.gallery_has_media.entity% + sonata_media_api_form_gallery_item + %sonata.media.admin.gallery_item.entity% sonata_api_write diff --git a/Resources/config/doctrine/BaseGallery.phpcr.xml b/Resources/config/doctrine/BaseGallery.phpcr.xml index db3d9f902f..843d429d8e 100644 --- a/Resources/config/doctrine/BaseGallery.phpcr.xml +++ b/Resources/config/doctrine/BaseGallery.phpcr.xml @@ -2,7 +2,7 @@ - + diff --git a/Resources/config/doctrine/BaseGalleryHasMedia.mongodb.xml b/Resources/config/doctrine/BaseGalleryItem.mongodb.xml similarity index 98% rename from Resources/config/doctrine/BaseGalleryHasMedia.mongodb.xml rename to Resources/config/doctrine/BaseGalleryItem.mongodb.xml index e91bc72237..8cd5227d04 100644 --- a/Resources/config/doctrine/BaseGalleryHasMedia.mongodb.xml +++ b/Resources/config/doctrine/BaseGalleryItem.mongodb.xml @@ -1,6 +1,6 @@ - + diff --git a/Resources/config/doctrine/BaseGalleryHasMedia.orm.xml b/Resources/config/doctrine/BaseGalleryItem.orm.xml similarity index 98% rename from Resources/config/doctrine/BaseGalleryHasMedia.orm.xml rename to Resources/config/doctrine/BaseGalleryItem.orm.xml index fe650c7e5b..1b10c1cace 100644 --- a/Resources/config/doctrine/BaseGalleryHasMedia.orm.xml +++ b/Resources/config/doctrine/BaseGalleryItem.orm.xml @@ -1,6 +1,6 @@ - + diff --git a/Resources/config/doctrine/BaseGalleryHasMedia.phpcr.xml b/Resources/config/doctrine/BaseGalleryItem.phpcr.xml similarity index 96% rename from Resources/config/doctrine/BaseGalleryHasMedia.phpcr.xml rename to Resources/config/doctrine/BaseGalleryItem.phpcr.xml index 74f36b27a1..ab4fadfa72 100644 --- a/Resources/config/doctrine/BaseGalleryHasMedia.phpcr.xml +++ b/Resources/config/doctrine/BaseGalleryItem.phpcr.xml @@ -1,6 +1,6 @@ - + diff --git a/Resources/config/doctrine/GalleryHasMedia.orm.xml.skeleton b/Resources/config/doctrine/GalleryItem.orm.xml.skeleton similarity index 93% rename from Resources/config/doctrine/GalleryHasMedia.orm.xml.skeleton rename to Resources/config/doctrine/GalleryItem.orm.xml.skeleton index 2c55ea9d72..91bcc7b5dd 100644 --- a/Resources/config/doctrine/GalleryHasMedia.orm.xml.skeleton +++ b/Resources/config/doctrine/GalleryItem.orm.xml.skeleton @@ -9,7 +9,7 @@ association mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/association-mapping/en --> diff --git a/Resources/config/doctrine/GalleryHasMedia.phpcr.xml.skeleton b/Resources/config/doctrine/GalleryItem.phpcr.xml.skeleton similarity index 96% rename from Resources/config/doctrine/GalleryHasMedia.phpcr.xml.skeleton rename to Resources/config/doctrine/GalleryItem.phpcr.xml.skeleton index 618ef07aec..bdb0236392 100644 --- a/Resources/config/doctrine/GalleryHasMedia.phpcr.xml.skeleton +++ b/Resources/config/doctrine/GalleryItem.phpcr.xml.skeleton @@ -14,8 +14,8 @@ association mapping : http://www.doctrine-project.org/projects/orm/2.0/docs/reference/association-mapping/en --> - + diff --git a/Resources/config/doctrine_mongodb_admin.xml b/Resources/config/doctrine_mongodb_admin.xml index 65f3c064c2..62fe3a1b4c 100644 --- a/Resources/config/doctrine_mongodb_admin.xml +++ b/Resources/config/doctrine_mongodb_admin.xml @@ -10,9 +10,9 @@ SonataMediaBundle:GalleryAdmin %sonata.media.admin.media.translation_domain% - Sonata\MediaBundle\Admin\GalleryHasMediaAdmin - SonataAdminBundle:CRUD - %sonata.media.admin.media.translation_domain% + Sonata\MediaBundle\Admin\GalleryItemAdmin + SonataAdminBundle:CRUD + %sonata.media.admin.media.translation_domain% @@ -54,13 +54,13 @@ - - + + - %sonata.media.admin.gallery_has_media.entity% - %sonata.media.admin.gallery_has_media.controller% + %sonata.media.admin.gallery_item.entity% + %sonata.media.admin.gallery_item.controller% - %sonata.media.admin.gallery_has_media.translation_domain% + %sonata.media.admin.gallery_item.translation_domain% diff --git a/Resources/config/doctrine_orm_admin.xml b/Resources/config/doctrine_orm_admin.xml index e5ce2fa4a8..dd09e01588 100644 --- a/Resources/config/doctrine_orm_admin.xml +++ b/Resources/config/doctrine_orm_admin.xml @@ -10,9 +10,9 @@ SonataMediaBundle:GalleryAdmin %sonata.media.admin.media.translation_domain% - Sonata\MediaBundle\Admin\GalleryHasMediaAdmin - SonataAdminBundle:CRUD - %sonata.media.admin.media.translation_domain% + Sonata\MediaBundle\Admin\GalleryItemAdmin + SonataAdminBundle:CRUD + %sonata.media.admin.media.translation_domain% @@ -56,13 +56,13 @@ - - + + - %sonata.media.admin.gallery_has_media.entity% - %sonata.media.admin.gallery_has_media.controller% + %sonata.media.admin.gallery_item.entity% + %sonata.media.admin.gallery_item.controller% - %sonata.media.admin.gallery_has_media.translation_domain% + %sonata.media.admin.gallery_item.translation_domain% diff --git a/Resources/config/doctrine_phpcr_admin.xml b/Resources/config/doctrine_phpcr_admin.xml index 5052cb27cf..48306a7e73 100644 --- a/Resources/config/doctrine_phpcr_admin.xml +++ b/Resources/config/doctrine_phpcr_admin.xml @@ -10,9 +10,9 @@ SonataMediaBundle:GalleryAdmin %sonata.media.admin.media.translation_domain% - Sonata\MediaBundle\Admin\GalleryHasMediaAdmin - SonataAdminBundle:CRUD - %sonata.media.admin.media.translation_domain% + Sonata\MediaBundle\Admin\GalleryItemAdmin + SonataAdminBundle:CRUD + %sonata.media.admin.media.translation_domain% @@ -55,13 +55,13 @@ - - + + - %sonata.media.admin.gallery_has_media.entity% - %sonata.media.admin.gallery_has_media.controller% + %sonata.media.admin.gallery_item.entity% + %sonata.media.admin.gallery_item.controller% - %sonata.media.admin.gallery_has_media.translation_domain% + %sonata.media.admin.gallery_item.translation_domain% diff --git a/Resources/config/serializer/Model.GalleryItem.xml b/Resources/config/serializer/Model.GalleryItem.xml new file mode 100644 index 0000000000..fbbbe654f6 --- /dev/null +++ b/Resources/config/serializer/Model.GalleryItem.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/Resources/config/validation.xml b/Resources/config/validation.xml index 20170956ec..88b51bb5af 100644 --- a/Resources/config/validation.xml +++ b/Resources/config/validation.xml @@ -25,7 +25,7 @@ - + diff --git a/Resources/doc/reference/advanced_configuration.rst b/Resources/doc/reference/advanced_configuration.rst index a909a56884..c59b133c66 100644 --- a/Resources/doc/reference/advanced_configuration.rst +++ b/Resources/doc/reference/advanced_configuration.rst @@ -10,7 +10,7 @@ Full configuration options: class: media: Application\Sonata\MediaBundle\Entity\Media gallery: Application\Sonata\MediaBundle\Entity\Gallery - gallery_has_media: Application\Sonata\MediaBundle\Entity\GalleryHasMedia + gallery_item: Application\Sonata\MediaBundle\Entity\GalleryItem category: Application\Sonata\ClassificationBundle\Entity\Category default_context: default diff --git a/Resources/doc/reference/installation.rst b/Resources/doc/reference/installation.rst index e5369b5899..1571600b41 100644 --- a/Resources/doc/reference/installation.rst +++ b/Resources/doc/reference/installation.rst @@ -108,9 +108,9 @@ Doctrine PHPCR: sonata_media: # if you don't use default namespace configuration #class: - # media: MyVendor\MediaBundle\Entity\Media - # gallery: MyVendor\MediaBundle\Entity\Gallery - # gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia + # media: MyVendor\MediaBundle\Entity\Media + # gallery: MyVendor\MediaBundle\Entity\Gallery + # gallery_item: MyVendor\MediaBundle\Entity\GalleryItem db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr it is mandatory to choose one here default_context: default # you need to set a context contexts: diff --git a/Resources/doc/reference/troubleshooting.rst b/Resources/doc/reference/troubleshooting.rst index a3bc123cc3..981207a4d4 100644 --- a/Resources/doc/reference/troubleshooting.rst +++ b/Resources/doc/reference/troubleshooting.rst @@ -80,9 +80,9 @@ Finally your settings in your ``sonata_media`` parameters will look like this: sonata_media: # if you don't use default namespace configuration #class: - # media: MyVendor\MediaBundle\Entity\Media - # gallery: MyVendor\MediaBundle\Entity\Gallery - # gallery_has_media: MyVendor\MediaBundle\Entity\GalleryHasMedia + # media: MyVendor\MediaBundle\Entity\Media + # gallery: MyVendor\MediaBundle\Entity\Gallery + # gallery_item: MyVendor\MediaBundle\Entity\GalleryItem default_context: default db_driver: doctrine_orm # or doctrine_mongodb, doctrine_phpcr contexts: diff --git a/Resources/translations/SonataMediaBundle.bg.xliff b/Resources/translations/SonataMediaBundle.bg.xliff index 46b31c22e1..f111026b48 100644 --- a/Resources/translations/SonataMediaBundle.bg.xliff +++ b/Resources/translations/SonataMediaBundle.bg.xliff @@ -150,8 +150,8 @@ form.label_default_format Формат - - form.label_gallery_has_medias + + form.label_gallery_items Медиа diff --git a/Resources/translations/SonataMediaBundle.de.xliff b/Resources/translations/SonataMediaBundle.de.xliff index c918234535..06f32b7d1d 100644 --- a/Resources/translations/SonataMediaBundle.de.xliff +++ b/Resources/translations/SonataMediaBundle.de.xliff @@ -146,8 +146,8 @@ form.label_default_format Format - - form.label_gallery_has_medias + + form.label_gallery_items Medium diff --git a/Resources/translations/SonataMediaBundle.en.xliff b/Resources/translations/SonataMediaBundle.en.xliff index da410daaea..05966d4a62 100644 --- a/Resources/translations/SonataMediaBundle.en.xliff +++ b/Resources/translations/SonataMediaBundle.en.xliff @@ -146,8 +146,8 @@ form.label_default_format Format - - form.label_gallery_has_medias + + form.label_gallery_items Media diff --git a/Resources/translations/SonataMediaBundle.es.xliff b/Resources/translations/SonataMediaBundle.es.xliff index b2699964e7..e2aa2773db 100644 --- a/Resources/translations/SonataMediaBundle.es.xliff +++ b/Resources/translations/SonataMediaBundle.es.xliff @@ -150,8 +150,8 @@ form.label_default_format Formato - - form.label_gallery_has_medias + + form.label_gallery_items Multimedias diff --git a/Resources/translations/SonataMediaBundle.fa.xliff b/Resources/translations/SonataMediaBundle.fa.xliff index 4e4746061e..a68c9b6b88 100644 --- a/Resources/translations/SonataMediaBundle.fa.xliff +++ b/Resources/translations/SonataMediaBundle.fa.xliff @@ -146,8 +146,8 @@ form.label_default_format فورمت - - form.label_gallery_has_medias + + form.label_gallery_items رسانه diff --git a/Resources/translations/SonataMediaBundle.fi.xliff b/Resources/translations/SonataMediaBundle.fi.xliff index 9c206f58a6..3adae77ad8 100644 --- a/Resources/translations/SonataMediaBundle.fi.xliff +++ b/Resources/translations/SonataMediaBundle.fi.xliff @@ -146,8 +146,8 @@ form.label_default_format Muoto - - form.label_gallery_has_medias + + form.label_gallery_items Media diff --git a/Resources/translations/SonataMediaBundle.fr.xliff b/Resources/translations/SonataMediaBundle.fr.xliff index ddc59aba75..441dc04185 100644 --- a/Resources/translations/SonataMediaBundle.fr.xliff +++ b/Resources/translations/SonataMediaBundle.fr.xliff @@ -146,8 +146,8 @@ form.label_default_format Format - - form.label_gallery_has_medias + + form.label_gallery_items Médias diff --git a/Resources/translations/SonataMediaBundle.hu.xliff b/Resources/translations/SonataMediaBundle.hu.xliff index f8ce830f67..fd782936f1 100644 --- a/Resources/translations/SonataMediaBundle.hu.xliff +++ b/Resources/translations/SonataMediaBundle.hu.xliff @@ -150,8 +150,8 @@ form.label_default_format Formátum - - form.label_gallery_has_medias + + form.label_gallery_items Média diff --git a/Resources/translations/SonataMediaBundle.it.xliff b/Resources/translations/SonataMediaBundle.it.xliff index d7bfadd9d9..4b11aa7913 100644 --- a/Resources/translations/SonataMediaBundle.it.xliff +++ b/Resources/translations/SonataMediaBundle.it.xliff @@ -146,8 +146,8 @@ form.label_default_format Formato - - form.label_gallery_has_medias + + form.label_gallery_items Media diff --git a/Resources/translations/SonataMediaBundle.ja.xliff b/Resources/translations/SonataMediaBundle.ja.xliff index bc44e012c5..f33baa06bd 100644 --- a/Resources/translations/SonataMediaBundle.ja.xliff +++ b/Resources/translations/SonataMediaBundle.ja.xliff @@ -126,8 +126,8 @@ form.label_default_format フォーマット - - form.label_gallery_has_medias + + form.label_gallery_items メディア diff --git a/Resources/translations/SonataMediaBundle.lt.xliff b/Resources/translations/SonataMediaBundle.lt.xliff index f320f9594a..7608344f42 100644 --- a/Resources/translations/SonataMediaBundle.lt.xliff +++ b/Resources/translations/SonataMediaBundle.lt.xliff @@ -150,8 +150,8 @@ form.label_default_format Formatas - - form.label_gallery_has_medias + + form.label_gallery_items Media diff --git a/Resources/translations/SonataMediaBundle.nl.xliff b/Resources/translations/SonataMediaBundle.nl.xliff index 29ec6bc5cd..9219d2115a 100644 --- a/Resources/translations/SonataMediaBundle.nl.xliff +++ b/Resources/translations/SonataMediaBundle.nl.xliff @@ -146,8 +146,8 @@ form.label_default_format Formaat - - form.label_gallery_has_medias + + form.label_gallery_items Media items diff --git a/Resources/translations/SonataMediaBundle.pl.xliff b/Resources/translations/SonataMediaBundle.pl.xliff index 9fb403db13..670e770c32 100644 --- a/Resources/translations/SonataMediaBundle.pl.xliff +++ b/Resources/translations/SonataMediaBundle.pl.xliff @@ -150,8 +150,8 @@ form.label_default_format Format - - form.label_gallery_has_medias + + form.label_gallery_items Media diff --git a/Resources/translations/SonataMediaBundle.pt_BR.xliff b/Resources/translations/SonataMediaBundle.pt_BR.xliff index a5a91e8aa3..4e55eaf5d2 100644 --- a/Resources/translations/SonataMediaBundle.pt_BR.xliff +++ b/Resources/translations/SonataMediaBundle.pt_BR.xliff @@ -130,8 +130,8 @@ form.label_default_format Formato - - form.label_gallery_has_medias + + form.label_gallery_items Mídias diff --git a/Resources/translations/SonataMediaBundle.ro.xliff b/Resources/translations/SonataMediaBundle.ro.xliff index a6ab3b0996..7933f23f58 100644 --- a/Resources/translations/SonataMediaBundle.ro.xliff +++ b/Resources/translations/SonataMediaBundle.ro.xliff @@ -146,8 +146,8 @@ form.label_default_format Format - - form.label_gallery_has_medias + + form.label_gallery_items Media diff --git a/Resources/translations/SonataMediaBundle.ru.xliff b/Resources/translations/SonataMediaBundle.ru.xliff index e19330b632..ee8dd8ea02 100644 --- a/Resources/translations/SonataMediaBundle.ru.xliff +++ b/Resources/translations/SonataMediaBundle.ru.xliff @@ -150,8 +150,8 @@ form.label_default_format Формат - - form.label_gallery_has_medias + + form.label_gallery_items Список медиа diff --git a/Resources/translations/SonataMediaBundle.sl.xliff b/Resources/translations/SonataMediaBundle.sl.xliff index cdbbf2b999..3af83d2058 100644 --- a/Resources/translations/SonataMediaBundle.sl.xliff +++ b/Resources/translations/SonataMediaBundle.sl.xliff @@ -150,8 +150,8 @@ form.label_default_format Oblika - - form.label_gallery_has_medias + + form.label_gallery_items Mediji diff --git a/Resources/translations/SonataMediaBundle.uk.xliff b/Resources/translations/SonataMediaBundle.uk.xliff index 092c162d3f..7a2f39de2b 100644 --- a/Resources/translations/SonataMediaBundle.uk.xliff +++ b/Resources/translations/SonataMediaBundle.uk.xliff @@ -126,8 +126,8 @@ form.label_default_format Формат - - form.label_gallery_has_medias + + form.label_gallery_items Список медіа diff --git a/Resources/views/Gallery/view.html.twig b/Resources/views/Gallery/view.html.twig index ed6b5ba43c..5ff7b41fee 100644 --- a/Resources/views/Gallery/view.html.twig +++ b/Resources/views/Gallery/view.html.twig @@ -20,14 +20,14 @@ file that was distributed with this source code.

{{ gallery.name }}

{% endif %} - {% for element in collection %} + {% for element in collection if element is not null %}
  • {% if element.parent or root %}{% endif %} @@ -35,10 +35,12 @@ file that was distributed with this source code. {% endmacro %} {% block list_table %} + {% if datagrid.values['category']['value'] is defined %}
    {{ tree.navigate_child([root_category], admin, true, datagrid.values['category']['value'], 1) }}
    + {% endif %}
    {{ parent() }}
    -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/Tests/Command/FixMediaContextCommandTest.php b/Tests/Command/FixMediaContextCommandTest.php index 7d290735c6..c021152efd 100755 --- a/Tests/Command/FixMediaContextCommandTest.php +++ b/Tests/Command/FixMediaContextCommandTest.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Tests\Command; -use Sonata\ClassificationBundle\Model\CategoryManagerInterface; use Sonata\ClassificationBundle\Model\ContextManagerInterface; use Sonata\MediaBundle\Command\FixMediaContextCommand; +use Sonata\MediaBundle\Model\CategoryManagerInterface; use Sonata\MediaBundle\Provider\Pool; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; @@ -75,7 +75,7 @@ protected function setUp() $this->contextManger = $contextManger = $this->getMock('Sonata\ClassificationBundle\Model\ContextManagerInterface'); - $this->categoryManger = $categoryManger = $this->getMockBuilder('Sonata\ClassificationBundle\Entity\CategoryManager')->disableOriginalConstructor()->getMock(); + $this->categoryManger = $categoryManger = $this->getMock('Sonata\MediaBundle\Model\CategoryManagerInterface'); $this->container->expects($this->any()) ->method('get') @@ -85,7 +85,7 @@ protected function setUp() return $pool; case 'sonata.classification.manager.context': return $contextManger; - case 'sonata.classification.manager.category': + case 'sonata.media.manager.category': return $categoryManger; } @@ -93,6 +93,16 @@ protected function setUp() })); } + public function testExecuteWithDisabledClassfication() + { + $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) + ->will($this->returnValue(false)); + + $this->setExpectedException('\LogicException'); + + $this->tester->execute(array('command' => $this->command->getName())); + } + public function testExecuteWithExisting() { $context = array( @@ -101,6 +111,9 @@ public function testExecuteWithExisting() 'download' => array(), ); + $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) + ->will($this->returnValue(true)); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); $contextModel = $this->getMock('Sonata\ClassificationBundle\Model\ContextInterface'); @@ -126,6 +139,9 @@ public function testExecuteWithEmptyRoot() 'download' => array(), ); + $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) + ->will($this->returnValue(true)); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); $contextModel = $this->getMock('Sonata\ClassificationBundle\Model\ContextInterface'); @@ -153,6 +169,9 @@ public function testExecuteWithNew() 'download' => array(), ); + $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) + ->will($this->returnValue(true)); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); $contextModel = $this->getMock('Sonata\ClassificationBundle\Model\ContextInterface'); diff --git a/Tests/DependencyInjection/SonataMediaExtensionTest.php b/Tests/DependencyInjection/SonataMediaExtensionTest.php new file mode 100644 index 0000000000..8e0fa67569 --- /dev/null +++ b/Tests/DependencyInjection/SonataMediaExtensionTest.php @@ -0,0 +1,98 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sonata\MediaBundle\Tests\DependencyInjection; + +use Sonata\MediaBundle\DependencyInjection\SonataMediaExtension; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Definition; + +class SonataMediaExtensionTest extends \PHPUnit_Framework_TestCase +{ + public function testLoadWithDefaultAndCustomCategoryManager() + { + $container = $this->getContainer( + array(array( + 'class' => array('category' => '\stdClass'), + 'category_manager' => 'dummy.service.name', + ))); + + $this->assertTrue($container->hasAlias('sonata.media.manager.category')); + $this->assertSame($container->getAlias('sonata.media.manager.category')->__toString(), 'dummy.service.name'); + } + + public function testLoadWithForceDisableTrueAndWithCategoryManager() + { + $container = $this->getContainer( + array(array( + 'class' => array('category' => '\stdClass'), + 'category_manager' => 'dummy.service.name', + 'force_disable_category' => true, + ))); + + $this->assertFalse($container->hasDefinition('sonata.media.manager.category')); + } + + public function testLoadWithDefaultAndClassificationBundleEnable() + { + $container = $this->getContainer(); + $this->assertTrue($container->hasAlias('sonata.media.manager.category')); + $this->assertSame($container->getDefinition('sonata.media.manager.category.default')->getClass(), 'Sonata\MediaBundle\Model\CategoryManager'); + } + + public function testLoadWithDefaultAndClassificationBundleEnableAndForceDisableCategory() + { + $container = $this->getContainer(array(array('force_disable_category' => true))); + + $this->assertFalse($container->hasDefinition('sonata.media.manager.category')); + } + + public function testLoadWithDefaultAndClassificationBundleEnableAndCustomCategoryManager() + { + $container = $this->getContainer( + array(array( + 'class' => array('category' => '\stdClass'), + 'category_manager' => 'dummy.service.name', + ))); + + $this->assertTrue($container->hasAlias('sonata.media.manager.category')); + $this->assertSame($container->getAlias('sonata.media.manager.category')->__toString(), 'dummy.service.name'); + } + + private function getContainer(array $config = array()) + { + $defaults = array(array( + 'default_context' => 'default', + 'db_driver' => 'doctrine_orm', + 'contexts' => array('default' => array('formats' => array('small' => array('width' => 100, 'quality' => 50)))), + 'filesystem' => array('local' => array('directory' => '/tmp/')), + )); + + $container = new ContainerBuilder(); + $container->setParameter('kernel.bundles', array('SonataAdminBundle' => true)); + $container->setDefinition('translator', new Definition('\stdClass')); + $container->setDefinition('security.context', new Definition('\stdClass')); + $container->setDefinition('doctrine', new Definition('\stdClass')); + $container->setDefinition('session', new Definition('\stdClass')); + + if (isset($config[0]['category_manager'])) { + $container->setDefinition($config[0]['category_manager'], new Definition('\stdClass')); + } + + $container->setDefinition('sonata.classification.manager.category', new Definition('Sonata\ClassificationBundle\Model\CategoryManager')); + + $loader = new SonataMediaExtension(); + $loader->load(array_merge($defaults, $config), $container); + $container->compile(); + + return $container; + } +} diff --git a/Tests/Listener/ORM/MediaEventSubscriberTest.php b/Tests/Listener/ORM/MediaEventSubscriberTest.php index 505308f4e2..780e883980 100644 --- a/Tests/Listener/ORM/MediaEventSubscriberTest.php +++ b/Tests/Listener/ORM/MediaEventSubscriberTest.php @@ -36,17 +36,19 @@ public function testRefetchCategoriesAfterClear() $category = $this->getMock('Sonata\\ClassificationBundle\\Model\\CategoryInterface'); - $catManager = $this->getMockBuilder('Sonata\\ClassificationBundle\\Entity\\CategoryManager', array('getRootCategories')) - ->disableOriginalConstructor() - ->getMock(); + $catManager = $this->getMock('Sonata\\MediaBundle\\Model\\CategoryManagerInterface'); $container = $this->getMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); $container->method('get')->will($this->returnValueMap(array( array('sonata.media.pool', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $pool), - array('sonata.classification.manager.category', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $catManager), + array('sonata.media.manager.category', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $catManager), ))); + $container->method('has') + ->with($this->equalTo('sonata.media.manager.category')) + ->will($this->returnValue(true)); + $catManager->expects($this->exactly(2)) ->method('getRootCategories') ->willReturn(array('context' => $category)) diff --git a/Tests/Provider/AbstractProviderTest.php b/Tests/Provider/AbstractProviderTest.php index 65200153c9..5e174799dc 100644 --- a/Tests/Provider/AbstractProviderTest.php +++ b/Tests/Provider/AbstractProviderTest.php @@ -98,7 +98,6 @@ public function setUp() } })); - $this->formBuilder->expects($this->any())->method('getOption')->willReturn('api'); $this->provider = $this->getProvider(); diff --git a/Tests/fixtures/SonataClassificationBundle/Model/CategoryInterface.php b/Tests/fixtures/SonataClassificationBundle/Model/CategoryInterface.php new file mode 100644 index 0000000000..77ba3e2cec --- /dev/null +++ b/Tests/fixtures/SonataClassificationBundle/Model/CategoryInterface.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sonata\ClassificationBundle\Model; + +interface CategoryInterface +{ + public function setContext($context); + + public function setName($name); + + public function setEnabled($enabled); + + public function setPosition($position); +} diff --git a/Tests/fixtures/SonataClassificationBundle/Model/ContextInterface.php b/Tests/fixtures/SonataClassificationBundle/Model/ContextInterface.php new file mode 100644 index 0000000000..845baa1b96 --- /dev/null +++ b/Tests/fixtures/SonataClassificationBundle/Model/ContextInterface.php @@ -0,0 +1,21 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sonata\ClassificationBundle\Model; + +interface ContextInterface +{ + public function setId($id); + + public function setName($name); + + public function setEnabled($enabled); +} diff --git a/Tests/fixtures/SonataClassificationBundle/Model/ContextManagerInterface.php b/Tests/fixtures/SonataClassificationBundle/Model/ContextManagerInterface.php new file mode 100644 index 0000000000..ec3e33f8d6 --- /dev/null +++ b/Tests/fixtures/SonataClassificationBundle/Model/ContextManagerInterface.php @@ -0,0 +1,18 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Sonata\ClassificationBundle\Model; + +use Sonata\CoreBundle\Model\ManagerInterface; + +interface ContextManagerInterface extends ManagerInterface +{ +} diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 0f6e1a990b..c96a651907 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -21,3 +21,8 @@ If you have implemented a custom model, you must adapt the signature of the foll ## Renamed GalleryHasMedia to GalleryItem All Actions, Controllers, Interfaces and anything related to this is renamed accordingly. + +## Removed classification dependency + +The category feature is now optional and can be disabled in the configuration. +If you need this feature you have to require `sonata-project/classifcation-bundle` via composer. diff --git a/composer.json b/composer.json index 9edac3bce4..626437ac2c 100644 --- a/composer.json +++ b/composer.json @@ -37,7 +37,6 @@ "sonata-project/notification-bundle": "^3.0", "sonata-project/easy-extends-bundle": "^2.1", "sonata-project/doctrine-extensions": "^1.0", - "sonata-project/classification-bundle": "^3.0 || ^4.0@dev", "knplabs/gaufrette": "^0.1.6", "imagine/imagine": "^0.6", "kriswallsmith/buzz": "^0.15", @@ -59,6 +58,7 @@ "sllh/php-cs-fixer-styleci-bridge": "^2.0" }, "suggest": { + "sonata-project/classification-bundle": "If you want to categorize your media items.", "sonata-project/doctrine-orm-admin-bundle": "^3.0", "liip/imagine-bundle": "^0.9", "rackspace/php-opencloud": "^1.6", @@ -69,6 +69,7 @@ "friendsofsymfony/rest-bundle": "<1.7.4 || >=3.0", "jms/serializer": "<0.13", "sonata-project/seo-bundle": "<2.0 || >=3.0", + "sonata-project/classification-bundle": "<3.0 || >=5.0", "sonata-project/block-bundle": "<3.1.1 || >=4.0" }, "autoload": { @@ -78,7 +79,10 @@ ] }, "autoload-dev": { - "psr-4": { "Sonata\\MediaBundle\\Tests\\": "Tests/" } + "psr-4": { + "Sonata\\MediaBundle\\Tests\\": "Tests/", + "Sonata\\ClassificationBundle\\": "Tests/fixtures/SonataClassificationBundle" + } }, "extra": { "branch-alias": { From 945d70b4763ed57aa1f1054f8c51a61e635ccbea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 21 Sep 2016 12:32:38 +0200 Subject: [PATCH 16/77] Applied fixes from StyleCI (#1118) --- Filesystem/Replicate.php | 2 +- Thumbnail/ConsumerThumbnail.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Filesystem/Replicate.php b/Filesystem/Replicate.php index d18da51264..56147d828c 100644 --- a/Filesystem/Replicate.php +++ b/Filesystem/Replicate.php @@ -174,7 +174,7 @@ public function rename($key, $new) */ public function supportsMetadata() { - return $this->master instanceof MetadataSupporter || $this->slave instanceof MetadataSupporter; + return $this->master instanceof MetadataSupporter || $this->slave instanceof MetadataSupporter; } /** diff --git a/Thumbnail/ConsumerThumbnail.php b/Thumbnail/ConsumerThumbnail.php index 32bf82e824..a9612909e8 100644 --- a/Thumbnail/ConsumerThumbnail.php +++ b/Thumbnail/ConsumerThumbnail.php @@ -89,7 +89,7 @@ public function generate(MediaProviderInterface $provider, MediaInterface $media // BC compatibility for missing EventDispatcher if (null === $this->dispatcher) { - trigger_error('Since version 2.3.3, passing an empty parameter in argument 4 for __construct() in '.__CLASS__.' is deprecated and the workaround for it will be removed in 3.0.', E_USER_DEPRECATED); + @trigger_error('Since version 2.3.3, passing an empty parameter in argument 4 for __construct() in '.__CLASS__.' is deprecated and the workaround for it will be removed in 3.0.', E_USER_DEPRECATED); $publish(); } else { $this->dispatcher->addListener('kernel.finish_request', $publish); From 62360e8b23cb093b3f8d95c2401b306fb5f7a479 Mon Sep 17 00:00:00 2001 From: Christian Gripp Date: Mon, 26 Sep 2016 08:22:41 +0200 Subject: [PATCH 17/77] Fixed wrong phpdoc of #1086 (#1120) --- Model/CategoryManagerInterface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Model/CategoryManagerInterface.php b/Model/CategoryManagerInterface.php index 5b6b8f65bb..400c5d0ae5 100644 --- a/Model/CategoryManagerInterface.php +++ b/Model/CategoryManagerInterface.php @@ -27,11 +27,11 @@ interface CategoryManagerInterface public function getRootCategory($context); /** - * @param bool|true $loadChildren + * @param bool $loadChildren * * @return CategoryInterface[] */ - public function getRootCategories($loadChildren); + public function getRootCategories($loadChildren = true); /** * @param int $categoryId From b49f4357302926f7b4561fbf6ea7e6577e7f624a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Jan 2017 15:24:04 +0100 Subject: [PATCH 18/77] cs --- Provider/YouTubeProvider.php | 5 -- .../SonataMediaExtensionTest.php | 59 +++++++++---------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/Provider/YouTubeProvider.php b/Provider/YouTubeProvider.php index a513cd6e2c..4105984326 100644 --- a/Provider/YouTubeProvider.php +++ b/Provider/YouTubeProvider.php @@ -57,7 +57,6 @@ public function getProviderMetadata() */ public function getHelperProperties(MediaInterface $media, $format, $options = array()) { - // Override html5 value if $options['html5'] is a boolean if (!isset($options['html5'])) { $options['html5'] = $this->html5; @@ -66,7 +65,6 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // documentation : http://code.google.com/apis/youtube/player_parameters.html $default_player_url_parameters = array( - //Values: 0 or 1. Default is 1. Sets whether the player should load related // videos once playback of the initial video starts. Related videos are // displayed in the "genie menu" when the menu button is pressed. The player @@ -157,11 +155,9 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // When wmode=opaque, the Flash movie is rendered as part of the page. // When wmode=transparent, the Flash movie is rendered as part of the page. 'wmode' => 'window', - ); $default_player_parameters = array( - // Values: 0 or 1. Default is 0. Setting to 1 enables a border around the entire video // player. The border's primary color can be set via the color1 parameter, and a // secondary color can be set by the color2 parameter. @@ -181,7 +177,6 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // When wmode=opaque, the Flash movie is rendered as part of the page. // When wmode=transparent, the Flash movie is rendered as part of the page. 'wmode' => $default_player_url_parameters['wmode'], - ); $player_url_parameters = array_merge($default_player_url_parameters, isset($options['player_url_parameters']) ? $options['player_url_parameters'] : array()); diff --git a/Tests/DependencyInjection/SonataMediaExtensionTest.php b/Tests/DependencyInjection/SonataMediaExtensionTest.php index f5093813ce..31b732fcad 100644 --- a/Tests/DependencyInjection/SonataMediaExtensionTest.php +++ b/Tests/DependencyInjection/SonataMediaExtensionTest.php @@ -93,36 +93,6 @@ public function testLoadWithDefaultAndClassificationBundleEnableAndCustomCategor $this->assertSame($container->getAlias('sonata.media.manager.category')->__toString(), 'dummy.service.name'); } - private function getContainer(array $config = array()) - { - $defaults = array(array( - 'default_context' => 'default', - 'db_driver' => 'doctrine_orm', - 'contexts' => array('default' => array('formats' => array('small' => array('width' => 100, 'quality' => 50)))), - 'filesystem' => array('local' => array('directory' => '/tmp/')), - )); - - $container = new ContainerBuilder(); - $container->setParameter('kernel.bundles', array('SonataAdminBundle' => true)); - $container->setDefinition('translator', new Definition('\stdClass')); - $container->setDefinition('security.context', new Definition('\stdClass')); - $container->setDefinition('doctrine', new Definition('\stdClass')); - $container->setDefinition('session', new Definition('\stdClass')); - - if (isset($config[0]['category_manager'])) { - $container->setDefinition($config[0]['category_manager'], new Definition('\stdClass')); - } - - $container->setDefinition('sonata.classification.manager.category', new Definition('Sonata\ClassificationBundle\Model\CategoryManager')); - - $loader = new SonataMediaExtension(); - $loader->load(array_merge($defaults, $config), $container); - $container->compile(); - - return $container; - } - - public function testDefaultAdapter() { $this->assertTrue($this->container->hasAlias('sonata.media.adapter.image.default')); @@ -230,4 +200,33 @@ protected function getConfigs() return $configs; } + + private function getContainer(array $config = array()) + { + $defaults = array(array( + 'default_context' => 'default', + 'db_driver' => 'doctrine_orm', + 'contexts' => array('default' => array('formats' => array('small' => array('width' => 100, 'quality' => 50)))), + 'filesystem' => array('local' => array('directory' => '/tmp/')), + )); + + $container = new ContainerBuilder(); + $container->setParameter('kernel.bundles', array('SonataAdminBundle' => true)); + $container->setDefinition('translator', new Definition('\stdClass')); + $container->setDefinition('security.context', new Definition('\stdClass')); + $container->setDefinition('doctrine', new Definition('\stdClass')); + $container->setDefinition('session', new Definition('\stdClass')); + + if (isset($config[0]['category_manager'])) { + $container->setDefinition($config[0]['category_manager'], new Definition('\stdClass')); + } + + $container->setDefinition('sonata.classification.manager.category', new Definition('Sonata\ClassificationBundle\Model\CategoryManager')); + + $loader = new SonataMediaExtension(); + $loader->load(array_merge($defaults, $config), $container); + $container->compile(); + + return $container; + } } From 639ef8bf4d566352dff02ccf96eb41c49f81d3fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Jan 2017 15:34:58 +0100 Subject: [PATCH 19/77] Remove useless user argument pip already knows who we are. Plus this is not interpreted as a user, but as a package. --- .travis/install_docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/install_docs.sh b/.travis/install_docs.sh index e638352b65..362f6449ff 100755 --- a/.travis/install_docs.sh +++ b/.travis/install_docs.sh @@ -1,4 +1,4 @@ #!/usr/bin/env sh set -ev -pip install -r Resources/doc/requirements.txt --user $(whoami) +pip install -r Resources/doc/requirements.txt --user From a7d1fd1c2d158a5d96782cb13c2496e420ce40ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 7 Jan 2017 17:25:56 +0100 Subject: [PATCH 20/77] Apply fixes from StyleCI (#1164) --- CDN/CloudFront.php | 6 +++--- PHPCR/BaseGallery.php | 1 - Tests/Controller/Api/MediaControllerTest.php | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/CDN/CloudFront.php b/CDN/CloudFront.php index de7b04321c..e498f2d703 100644 --- a/CDN/CloudFront.php +++ b/CDN/CloudFront.php @@ -39,9 +39,9 @@ * to the new distribution. For more information about the charges for * invalidation, see Paying for Object Invalidation. * - * @uses CloudFrontClient for stablish connection with CloudFront service + * @uses \CloudFrontClient for stablish connection with CloudFront service * - * @link http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.htmlInvalidating Objects (Web Distributions Only) + * @see http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.htmlInvalidating Objects (Web Distributions Only) * * @author Javier Spagnoletti */ @@ -113,7 +113,7 @@ public function flush($string) /** * {@inheritdoc} * - * @link http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.CloudFront.CloudFrontClient.html#_createInvalidation + * @see http://docs.aws.amazon.com/aws-sdk-php/latest/class-Aws.CloudFront.CloudFrontClient.html#_createInvalidation */ public function flushPaths(array $paths) { diff --git a/PHPCR/BaseGallery.php b/PHPCR/BaseGallery.php index 7b708f957e..3e64419528 100644 --- a/PHPCR/BaseGallery.php +++ b/PHPCR/BaseGallery.php @@ -86,7 +86,6 @@ public function preUpdate() public function reorderGalleryItems() { if ($this->getGalleryItems() && $this->getGalleryItems() instanceof \IteratorAggregate) { - // reorder $iterator = $this->getGalleryItems()->getIterator(); diff --git a/Tests/Controller/Api/MediaControllerTest.php b/Tests/Controller/Api/MediaControllerTest.php index 76d4f51818..8bbb74d9ef 100644 --- a/Tests/Controller/Api/MediaControllerTest.php +++ b/Tests/Controller/Api/MediaControllerTest.php @@ -204,7 +204,7 @@ public function testPostProviderMediumAction() } /** - * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException + * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ public function testPostProviderActionNotFound() { From 9c50b3d6ed55a90976bfb2684da17b65a35a9c51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 10 Jan 2017 08:27:57 +0100 Subject: [PATCH 21/77] Drop support for old versions of Symfony (#1165) --- .../Compiler/SecurityContextCompilerPass.php | 44 ------------- Form/Type/ApiMediaType.php | 19 +----- Form/Type/MediaType.php | 49 ++------------ Model/Media.php | 20 ++---- Provider/BaseVideoProvider.php | 21 ++---- Provider/FileProvider.php | 18 +----- SonataMediaBundle.php | 2 - Tests/Form/Type/AbstractTypeTest.php | 64 +++++++++---------- Tests/Form/Type/MediaTypeTest.php | 32 +++------- Tests/Provider/AbstractProviderTest.php | 62 ++++++++---------- composer.json | 30 ++++----- 11 files changed, 101 insertions(+), 260 deletions(-) delete mode 100644 DependencyInjection/Compiler/SecurityContextCompilerPass.php diff --git a/DependencyInjection/Compiler/SecurityContextCompilerPass.php b/DependencyInjection/Compiler/SecurityContextCompilerPass.php deleted file mode 100644 index 6c96ed19d0..0000000000 --- a/DependencyInjection/Compiler/SecurityContextCompilerPass.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\MediaBundle\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\ContainerBuilder; - -/** - * SecurityContextCompilerPass. - * - * This compiler pass provides compatibility with Symfony < 2.6 security.context service - * and 2.6+ security.authorization_checker service. This pass may be removed when support - * for Symfony < 2.6 is dropped. - */ -class SecurityContextCompilerPass implements CompilerPassInterface -{ - /** - * {@inheritdoc} - */ - public function process(ContainerBuilder $container) - { - // Prefer the security.authorization_checker service - if ($container->hasDefinition('security.authorization_checker')) { - $security = $container->getDefinition('security.authorization_checker'); - } else { - $security = $container->getDefinition('security.context'); - } - - $container->getDefinition('sonata.media.security.superadmin_strategy') - ->replaceArgument(1, $security); - - $container->getDefinition('sonata.media.security.connected_strategy') - ->replaceArgument(1, $security); - } -} diff --git a/Form/Type/ApiMediaType.php b/Form/Type/ApiMediaType.php index 46d15cc724..65b58ab81d 100644 --- a/Form/Type/ApiMediaType.php +++ b/Form/Type/ApiMediaType.php @@ -16,7 +16,6 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * Class ApiMediaType. @@ -59,18 +58,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) $provider->buildMediaType($builder); } - /** - * {@inheritdoc} - * - * NEXT_MAJOR: remove this method. - * - * @deprecated Remove it when bumping requirements to Symfony >=2.7 - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $this->configureOptions($resolver); - } - /** * {@inheritdoc} */ @@ -87,11 +74,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - // NEXT_MAJOR: Return 'Sonata\MediaBundle\Form\Type\ApiDoctrineMediaType' - // (when requirement of Symfony is >= 2.8) - return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Sonata\MediaBundle\Form\Type\ApiDoctrineMediaType' - : 'sonata_media_api_form_doctrine_media'; + return 'Sonata\MediaBundle\Form\Type\ApiDoctrineMediaType'; } /** diff --git a/Form/Type/MediaType.php b/Form/Type/MediaType.php index b28e6f941f..bae4ce40d6 100644 --- a/Form/Type/MediaType.php +++ b/Form/Type/MediaType.php @@ -20,7 +20,6 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; class MediaType extends AbstractType { @@ -64,13 +63,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) $this->pool->getProvider($options['provider'])->buildMediaType($builder); - // NEXT_MAJOR: Remove ternary and keep 'Symfony\Component\Form\Extension\Core\Type\CheckboxType' value. - // (when requirement of Symfony is >= 2.8) $builder->add( 'unlink', - method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\CheckboxType' - : 'checkbox', + 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', array( 'label' => 'widget_label_unlink', 'mapped' => false, @@ -89,18 +84,6 @@ public function buildView(FormView $view, FormInterface $form, array $options) $view->vars['context'] = $options['context']; } - /** - * {@inheritdoc} - * - * NEXT_MAJOR: remove this method. - * - * @deprecated Remove it when bumping requirements to Symfony >=2.7 - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $this->configureOptions($resolver); - } - /** * {@inheritdoc} */ @@ -118,25 +101,11 @@ public function configureOptions(OptionsResolver $resolver) 'context', )); - // NEXT_MAJOR: Remove this hack when dropping support for symfony 2.3 - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - $resolver - ->setAllowedTypes('provider', 'string') - ->setAllowedTypes('context', 'string') - ->setAllowedValues('provider', $this->pool->getProviderList()) - ->setAllowedValues('context', array_keys($this->pool->getContexts())) - ; - } else { - $resolver - ->setAllowedTypes(array( - 'provider' => 'string', - 'context' => 'string', - )) - ->setAllowedValues(array( - 'provider' => $this->pool->getProviderList(), - 'context' => array_keys($this->pool->getContexts()), - )); - } + $resolver + ->setAllowedTypes('provider', 'string') + ->setAllowedTypes('context', 'string') + ->setAllowedValues('provider', $this->pool->getProviderList()) + ->setAllowedValues('context', array_keys($this->pool->getContexts())); } /** @@ -144,11 +113,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - // NEXT_MAJOR: Return 'Symfony\Component\Form\Extension\Core\Type\FormType' - // (when requirement of Symfony is >= 2.8) - return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\FormType' - : 'form'; + return 'Symfony\Component\Form\Extension\Core\Type\FormType'; } /** diff --git a/Model/Media.php b/Model/Media.php index 5c29039733..78c2912b22 100644 --- a/Model/Media.php +++ b/Model/Media.php @@ -14,7 +14,6 @@ use Imagine\Image\Box; use Sonata\ClassificationBundle\Model\CategoryInterface; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\ExecutionContextInterface as LegacyExecutionContextInterface; abstract class Media implements MediaInterface { @@ -612,23 +611,14 @@ public function getPreviousProviderReference() } /** - * @param ExecutionContextInterface|LegacyExecutionContextInterface $context + * @param ExecutionContextInterface $context */ - public function isStatusErroneous($context) + public function isStatusErroneous(ExecutionContextInterface $context) { if ($this->getBinaryContent() && $this->getProviderStatus() == self::STATUS_ERROR) { - // Interface compatibility, the new ExecutionContextInterface should be typehinted when support for Symfony <2.5 is dropped - if (!$context instanceof ExecutionContextInterface && !$context instanceof LegacyExecutionContextInterface) { - throw new \InvalidArgumentException('Argument 1 should be an instance of Symfony\Component\Validator\ExecutionContextInterface or Symfony\Component\Validator\Context\ExecutionContextInterface'); - } - - if ($context instanceof LegacyExecutionContextInterface) { - $context->addViolationAt('binaryContent', 'invalid', array(), null); - } else { - $context->buildViolation('invalid') - ->atPath('binaryContent') - ->addViolation(); - } + $context->buildViolation('invalid') + ->atPath('binaryContent') + ->addViolation(); } } diff --git a/Provider/BaseVideoProvider.php b/Provider/BaseVideoProvider.php index 4b3ec169fa..8ba854ccd6 100644 --- a/Provider/BaseVideoProvider.php +++ b/Provider/BaseVideoProvider.php @@ -131,12 +131,9 @@ public function buildEditForm(FormMapper $formMapper) $formMapper->add('copyright'); $formMapper->add( 'binaryContent', - // NEXT_MAJOR: Remove ternary and keep 'Symfony\Component\Form\Extension\Core\Type\TextType' value - // (when requirement of Symfony is >= 2.8) - method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\TextType' - : 'text', - array('required' => false)); + 'Symfony\Component\Form\Extension\Core\Type\TextType', + array('required' => false) + ); } /** @@ -146,11 +143,7 @@ public function buildCreateForm(FormMapper $formMapper) { $formMapper->add( 'binaryContent', - // NEXT_MAJOR: Remove ternary and keep 'Symfony\Component\Form\Extension\Core\Type\TextType' value - // (when requirement of Symfony is >= 2.8) - method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\TextType' - : 'text', + 'Symfony\Component\Form\Extension\Core\Type\TextType', array( 'constraints' => array( new NotBlank(), @@ -165,13 +158,9 @@ public function buildCreateForm(FormMapper $formMapper) */ public function buildMediaType(FormBuilder $formBuilder) { - // NEXT_MAJOR: Remove ternary and keep 'Symfony\Component\Form\Extension\Core\Type\TextType' - // (when requirement of Symfony is >= 2.8) $formBuilder->add( 'binaryContent', - method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\TextType' - : 'text', + 'Symfony\Component\Form\Extension\Core\Type\TextType', array( 'label' => 'widget_label_binary_content', ) diff --git a/Provider/FileProvider.php b/Provider/FileProvider.php index b668650da9..7eef8de1b3 100644 --- a/Provider/FileProvider.php +++ b/Provider/FileProvider.php @@ -98,11 +98,7 @@ public function buildEditForm(FormMapper $formMapper) $formMapper->add('copyright'); $formMapper->add( 'binaryContent', - // NEXT_MAJOR: Remove ternary and keep 'Symfony\Component\Form\Extension\Core\Type\FileType' value - // (when requirement of Symfony is >= 2.8) - method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\FileType' - : 'file', + 'Symfony\Component\Form\Extension\Core\Type\FileType', array('required' => false) ); } @@ -114,11 +110,7 @@ public function buildCreateForm(FormMapper $formMapper) { $formMapper->add( 'binaryContent', - // NEXT_MAJOR: Remove ternary and keep 'Symfony\Component\Form\Extension\Core\Type\FileType' value - // (when requirement of Symfony is >= 2.8) - method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\FileType' - : 'file', + 'Symfony\Component\Form\Extension\Core\Type\FileType', array( 'constraints' => array( new NotBlank(), @@ -133,11 +125,7 @@ public function buildCreateForm(FormMapper $formMapper) */ public function buildMediaType(FormBuilder $formBuilder) { - // NEXT_MAJOR: Remove $fileType variable and inline 'Symfony\Component\Form\Extension\Core\Type\FileType' - // (when requirement of Symfony is >= 2.8) - $fileType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\FileType' - : 'file'; + $fileType = 'Symfony\Component\Form\Extension\Core\Type\FileType'; if ($formBuilder->getOption('context') == 'api') { $formBuilder->add('binaryContent', $fileType); diff --git a/SonataMediaBundle.php b/SonataMediaBundle.php index ad9c6a12eb..09295f49aa 100644 --- a/SonataMediaBundle.php +++ b/SonataMediaBundle.php @@ -14,7 +14,6 @@ use Sonata\CoreBundle\Form\FormHelper; use Sonata\MediaBundle\DependencyInjection\Compiler\AddProviderCompilerPass; use Sonata\MediaBundle\DependencyInjection\Compiler\GlobalVariablesCompilerPass; -use Sonata\MediaBundle\DependencyInjection\Compiler\SecurityContextCompilerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -27,7 +26,6 @@ public function build(ContainerBuilder $container) { $container->addCompilerPass(new AddProviderCompilerPass()); $container->addCompilerPass(new GlobalVariablesCompilerPass()); - $container->addCompilerPass(new SecurityContextCompilerPass()); $this->registerFormMapping(); } diff --git a/Tests/Form/Type/AbstractTypeTest.php b/Tests/Form/Type/AbstractTypeTest.php index 53553d49ac..d8946f9f50 100644 --- a/Tests/Form/Type/AbstractTypeTest.php +++ b/Tests/Form/Type/AbstractTypeTest.php @@ -51,24 +51,21 @@ protected function setUp() ->expects($this->any()) ->method('add') ->will($this->returnCallback(function ($name, $type = null) use ($that) { - // NEXT_MAJOR: Remove this "if" (when requirement of Symfony is >= 2.8) - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - if (null !== $type) { - $isFQCN = class_exists($type); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $type - ), - E_USER_DEPRECATED) - ; - } - - $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); + if (null !== $type) { + $isFQCN = class_exists($type); + if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { + // 2.8 + @trigger_error( + sprintf( + 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' + .' Use the fully-qualified type class name instead.', + $type + ), + E_USER_DEPRECATED) + ; } + + $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); } })); @@ -88,25 +85,22 @@ public function testBuildForm() public function testGetParent() { - // NEXT_MAJOR: Remove this "if" (when requirement of Symfony is >= 2.8) - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - $parentRef = $this->formType->getParent(); - - $isFQCN = class_exists($parentRef); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $parentRef - ), - E_USER_DEPRECATED) - ; - } - - $this->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $parentRef)); + $parentRef = $this->formType->getParent(); + + $isFQCN = class_exists($parentRef); + if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { + // 2.8 + @trigger_error( + sprintf( + 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' + .' Use the fully-qualified type class name instead.', + $parentRef + ), + E_USER_DEPRECATED) + ; } + + $this->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $parentRef)); } /** diff --git a/Tests/Form/Type/MediaTypeTest.php b/Tests/Form/Type/MediaTypeTest.php index 3642f58c30..fb0bff68dd 100644 --- a/Tests/Form/Type/MediaTypeTest.php +++ b/Tests/Form/Type/MediaTypeTest.php @@ -106,18 +106,10 @@ public function testInvalidFormProviderOption() 'pic' => array(), ))); - // NEXT_MAJOR: Remove this hack when dropping support for symfony 2.3 - if (class_exists('Symfony\Component\Validator\Validator\RecursiveValidator')) { - $this->setExpectedException( - 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', - 'The option "provider" with value "provider_c" is invalid. Accepted values are: "provider_a", "provider_b".' - ); - } else { - $this->setExpectedException( - 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', - 'The option "provider" has the value "provider_c", but is expected to be one of "provider_a", "provider_b"' - ); - } + $this->setExpectedException( + 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', + 'The option "provider" with value "provider_c" is invalid. Accepted values are: "provider_a", "provider_b".' + ); $this->factory->create($this->getFormType(), null, array( 'provider' => 'provider_c', @@ -136,18 +128,10 @@ public function testInvalidFormContextOption() 'pic' => array(), ))); - // NEXT_MAJOR: Remove this hack when dropping support for symfony 2.3 - if (class_exists('Symfony\Component\Validator\Validator\RecursiveValidator')) { - $this->setExpectedException( - 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', - 'The option "context" with value "photo" is invalid. Accepted values are: "video", "pic".' - ); - } else { - $this->setExpectedException( - 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', - 'The option "context" has the value "photo", but is expected to be one of "video", "pic"' - ); - } + $this->setExpectedException( + 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', + 'The option "context" with value "photo" is invalid. Accepted values are: "video", "pic".' + ); $this->factory->create($this->getFormType(), null, array( 'provider' => 'provider_b', diff --git a/Tests/Provider/AbstractProviderTest.php b/Tests/Provider/AbstractProviderTest.php index 5e174799dc..6ff4c90576 100644 --- a/Tests/Provider/AbstractProviderTest.php +++ b/Tests/Provider/AbstractProviderTest.php @@ -51,24 +51,21 @@ public function setUp() ->expects($this->any()) ->method('add') ->will($this->returnCallback(function ($name, $type = null) use ($that) { - // NEXT_MAJOR: Remove this "if" (when requirement of Symfony is >= 2.8) - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - if (null !== $type) { - $isFQCN = class_exists($type); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $type - ), - E_USER_DEPRECATED) - ; - } - - $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); + if (null !== $type) { + $isFQCN = class_exists($type); + if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { + // 2.8 + @trigger_error( + sprintf( + 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' + .' Use the fully-qualified type class name instead.', + $type + ), + E_USER_DEPRECATED) + ; } + + $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); } })); @@ -77,24 +74,21 @@ public function setUp() ->expects($this->any()) ->method('add') ->will($this->returnCallback(function ($name, $type = null) use ($that) { - // NEXT_MAJOR: Remove this "if" (when requirement of Symfony is >= 2.8) - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - if (null !== $type) { - $isFQCN = class_exists($type); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $type - ), - E_USER_DEPRECATED) - ; - } - - $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); + if (null !== $type) { + $isFQCN = class_exists($type); + if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { + // 2.8 + @trigger_error( + sprintf( + 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' + .' Use the fully-qualified type class name instead.', + $type + ), + E_USER_DEPRECATED) + ; } + + $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); } })); diff --git a/composer.json b/composer.json index 43878129b3..dacca2c22b 100644 --- a/composer.json +++ b/composer.json @@ -18,21 +18,21 @@ ], "require": { "php": "^5.3 || ^7.0", - "symfony/config": "^2.3.9 || ^3.0", - "symfony/console": "^2.3 || ^3.0", - "symfony/dependency-injection": "^2.3.3 || ^3.0", - "symfony/event-dispatcher": "^2.3 || ^3.0", - "symfony/filesystem": "^2.3 || ^3.0", - "symfony/finder": "^2.3 || ^3.0", - "symfony/form": "^2.3.5 || ^3.0", - "symfony/http-foundation": "^2.3 || ^3.0", - "symfony/http-kernel": "^2.3 || ^3.0", - "symfony/options-resolver": "^2.3 || ^3.0", - "symfony/routing": "^2.3 || ^3.0", - "symfony/security":"^2.3 || ^3.0", - "symfony/templating":"^2.3 || ^3.0", - "symfony/translation": "^2.3 || ^3.0", - "symfony/validator": "^2.3 || ^3.0", + "symfony/config": "^2.8 || ^3.0", + "symfony/console": "^2.8 || ^3.0", + "symfony/dependency-injection": "^2.8 || ^3.0", + "symfony/event-dispatcher": "^2.8 || ^3.0", + "symfony/filesystem": "^2.8 || ^3.0", + "symfony/finder": "^2.8 || ^3.0", + "symfony/form": "^2.8 || ^3.0", + "symfony/http-foundation": "^2.8 || ^3.0", + "symfony/http-kernel": "^2.8 || ^3.0", + "symfony/options-resolver": "^2.8 || ^3.0", + "symfony/routing": "^2.8 || ^3.0", + "symfony/security":"^2.8 || ^3.0", + "symfony/templating":"^2.8 || ^3.0", + "symfony/translation": "^2.8 || ^3.0", + "symfony/validator": "^2.8 || ^3.0", "sonata-project/core-bundle": "^3.0", "sonata-project/notification-bundle": "^3.0", "sonata-project/easy-extends-bundle": "^2.1", From 098e4e01d06fea43757be309552f094345919ec5 Mon Sep 17 00:00:00 2001 From: jenyak Date: Wed, 11 Jan 2017 13:32:07 +0200 Subject: [PATCH 22/77] Use AuthorizationChecker for strategies (#1166) --- Resources/config/security.xml | 6 ++---- Security/RolesDownloadStrategy.php | 15 +++++---------- .../SonataMediaExtensionTest.php | 2 +- Tests/Security/RolesDownloadStrategyTest.php | 16 ++-------------- 4 files changed, 10 insertions(+), 29 deletions(-) diff --git a/Resources/config/security.xml b/Resources/config/security.xml index 3a32ac0c10..982e1ab398 100644 --- a/Resources/config/security.xml +++ b/Resources/config/security.xml @@ -9,8 +9,7 @@ - - + ROLE_SUPER_ADMIN ROLE_ADMIN @@ -23,8 +22,7 @@ - - + IS_AUTHENTICATED_FULLY IS_AUTHENTICATED_REMEMBERED diff --git a/Security/RolesDownloadStrategy.php b/Security/RolesDownloadStrategy.php index a30760e59f..d5c64fd658 100644 --- a/Security/RolesDownloadStrategy.php +++ b/Security/RolesDownloadStrategy.php @@ -15,7 +15,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException; -use Symfony\Component\Security\Core\SecurityContextInterface; use Symfony\Component\Translation\TranslatorInterface; class RolesDownloadStrategy implements DownloadStrategyInterface @@ -26,7 +25,7 @@ class RolesDownloadStrategy implements DownloadStrategyInterface protected $roles; /** - * @var AuthorizationCheckerInterface|SecurityContextInterface + * @var AuthorizationCheckerInterface */ protected $security; @@ -36,16 +35,12 @@ class RolesDownloadStrategy implements DownloadStrategyInterface protected $translator; /** - * @param TranslatorInterface $translator - * @param AuthorizationCheckerInterface|SecurityContextInterface $security - * @param string[] $roles + * @param TranslatorInterface $translator + * @param AuthorizationCheckerInterface $security + * @param string[] $roles */ - public function __construct(TranslatorInterface $translator, $security, array $roles = array()) + public function __construct(TranslatorInterface $translator, AuthorizationCheckerInterface $security, array $roles = array()) { - if (!$security instanceof AuthorizationCheckerInterface && !$security instanceof SecurityContextInterface) { - throw new \InvalidArgumentException('Argument 2 should be an instance of Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface or Symfony\Component\Security\Core\SecurityContextInterface'); - } - $this->roles = $roles; $this->security = $security; $this->translator = $translator; diff --git a/Tests/DependencyInjection/SonataMediaExtensionTest.php b/Tests/DependencyInjection/SonataMediaExtensionTest.php index 31b732fcad..ea23ea0678 100644 --- a/Tests/DependencyInjection/SonataMediaExtensionTest.php +++ b/Tests/DependencyInjection/SonataMediaExtensionTest.php @@ -213,7 +213,7 @@ private function getContainer(array $config = array()) $container = new ContainerBuilder(); $container->setParameter('kernel.bundles', array('SonataAdminBundle' => true)); $container->setDefinition('translator', new Definition('\stdClass')); - $container->setDefinition('security.context', new Definition('\stdClass')); + $container->setDefinition('security.authorization_checker', new Definition('\stdClass')); $container->setDefinition('doctrine', new Definition('\stdClass')); $container->setDefinition('session', new Definition('\stdClass')); diff --git a/Tests/Security/RolesDownloadStrategyTest.php b/Tests/Security/RolesDownloadStrategyTest.php index d364a80133..129d3a23d1 100644 --- a/Tests/Security/RolesDownloadStrategyTest.php +++ b/Tests/Security/RolesDownloadStrategyTest.php @@ -20,13 +20,7 @@ public function testIsGrantedTrue() $media = $this->getMock('Sonata\MediaBundle\Model\MediaInterface'); $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - - // Prefer the Symfony 2.6+ API if available - if (interface_exists('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')) { - $security = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); - } else { - $security = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); - } + $security = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); $security->expects($this->any()) ->method('isGranted') @@ -43,13 +37,7 @@ public function testIsGrantedFalse() $media = $this->getMock('Sonata\MediaBundle\Model\MediaInterface'); $request = $this->getMock('Symfony\Component\HttpFoundation\Request'); $translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - - // Prefer the Symfony 2.6+ API if available - if (interface_exists('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface')) { - $security = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); - } else { - $security = $this->getMock('Symfony\Component\Security\Core\SecurityContextInterface'); - } + $security = $this->getMock('Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface'); $security->expects($this->any()) ->method('isGranted') From dded20116affa6f4e63ad34104da50b7ab3dfb3d Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Fri, 3 Mar 2017 07:50:36 +0100 Subject: [PATCH 23/77] Remove old Symfony 2.3 code (#1212) --- Admin/BaseMediaAdmin.php | 26 ++-------- Admin/GalleryAdmin.php | 20 +++----- Admin/GalleryItemAdmin.php | 14 +----- Admin/ORM/MediaAdmin.php | 16 ++----- Block/FeatureMediaBlockService.php | 23 ++------- Block/GalleryBlockService.php | 31 +++--------- Block/GalleryListBlockService.php | 27 +++-------- Block/MediaBlockService.php | 24 ++-------- Controller/MediaController.php | 47 +++++++------------ DependencyInjection/SonataMediaExtension.php | 19 -------- Model/Media.php | 17 ------- Resources/config/gaufrette.xml | 4 -- Resources/config/validation.xml | 2 - Tests/Admin/BaseMediaAdminTest.php | 7 +-- .../Controller/GalleryAdminControllerTest.php | 36 ++++---------- Tests/Controller/MediaAdminControllerTest.php | 36 ++++---------- Tests/Controller/MediaControllerTest.php | 35 ++++---------- Tests/Form/Type/AbstractTypeTest.php | 30 +----------- Tests/Provider/AbstractProviderTest.php | 30 +----------- UPGRADE-4.0.md | 13 +++-- 20 files changed, 102 insertions(+), 355 deletions(-) diff --git a/Admin/BaseMediaAdmin.php b/Admin/BaseMediaAdmin.php index eeb608e849..c161306424 100644 --- a/Admin/BaseMediaAdmin.php +++ b/Admin/BaseMediaAdmin.php @@ -107,16 +107,8 @@ public function getNewInstance() if ($this->hasRequest()) { if ($this->getRequest()->isMethod('POST')) { $uniqid = $this->getUniqid(); - - if (method_exists('Symfony\Component\HttpFoundation\JsonResponse', 'transformJsonError')) { - // NEXT_MAJOR remove this block when dropping sf < 2.8 compatibility - $media->setProviderName( - $this->getRequest()->get(sprintf('%s[providerName]', $uniqid), null, true) - ); - } else { - $providerParams = $this->getRequest()->get($uniqid); - $media->setProviderName($providerParams['providerName']); - } + $providerParams = $this->getRequest()->get($uniqid); + $media->setProviderName($providerParams['providerName']); } else { $media->setProviderName($this->getRequest()->get('provider')); } @@ -183,12 +175,7 @@ protected function configureFormFields(FormMapper $formMapper) return; } - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $hiddenType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\HiddenType' - : 'hidden'; - - $formMapper->add('providerName', $hiddenType); + $formMapper->add('providerName', 'Symfony\Component\Form\Extension\Core\Type\HiddenType'); $formMapper->getFormBuilder()->addModelTransformer(new ProviderDataTransformer($this->pool, $this->getClass()), true); @@ -201,12 +188,7 @@ protected function configureFormFields(FormMapper $formMapper) } if (null !== $this->categoryManager) { - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $modelListType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Sonata\AdminBundle\Form\Type\ModelListType' - : 'sonata_type_model_list'; - - $formMapper->add('category', $modelListType, array(), array( + $formMapper->add('category', 'Sonata\AdminBundle\Form\Type\ModelListType', array(), array( 'link_parameters' => array( 'context' => $media->getContext(), 'hide_context' => true, diff --git a/Admin/GalleryAdmin.php b/Admin/GalleryAdmin.php index d37bd2a762..c054709565 100644 --- a/Admin/GalleryAdmin.php +++ b/Admin/GalleryAdmin.php @@ -116,27 +116,21 @@ protected function configureFormFields(FormMapper $formMapper) $contexts[$contextItem] = $contextItem; } - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $choiceType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType' - : 'choice'; - - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $collectionType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Sonata\CoreBundle\Form\Type\CollectionType' - : 'sonata_type_collection'; - $formMapper ->with('Options') - ->add('context', $choiceType, array('choices' => $contexts)) + ->add('context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + 'choices' => $contexts, + )) ->add('enabled', null, array('required' => false)) ->add('name') ->ifTrue($formats) - ->add('defaultFormat', $choiceType, array('choices' => $formats)) + ->add('defaultFormat', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + 'choices' => $formats, + )) ->ifEnd() ->end() ->with('Gallery') - ->add('galleryItems', $collectionType, array(), array( + ->add('galleryItems', 'Sonata\CoreBundle\Form\Type\CollectionType', array(), array( 'edit' => 'inline', 'inline' => 'table', 'sortable' => 'position', diff --git a/Admin/GalleryItemAdmin.php b/Admin/GalleryItemAdmin.php index 864e1d0e81..a72543079f 100644 --- a/Admin/GalleryItemAdmin.php +++ b/Admin/GalleryItemAdmin.php @@ -36,22 +36,12 @@ protected function configureFormFields(FormMapper $formMapper) } } - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $modelListType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Sonata\AdminBundle\Form\Type\ModelListType' - : 'sonata_type_model_list'; - - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $hiddenType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\HiddenType' - : 'hidden'; - $formMapper - ->add('media', $modelListType, array('required' => false), array( + ->add('media', 'Sonata\AdminBundle\Form\Type\ModelListType', array('required' => false), array( 'link_parameters' => $link_parameters, )) ->add('enabled', null, array('required' => false)) - ->add('position', $hiddenType) + ->add('position', 'Symfony\Component\Form\Extension\Core\Type\HiddenType') ; } diff --git a/Admin/ORM/MediaAdmin.php b/Admin/ORM/MediaAdmin.php index 8dd6cc9e69..8ec9b24bd0 100644 --- a/Admin/ORM/MediaAdmin.php +++ b/Admin/ORM/MediaAdmin.php @@ -29,18 +29,13 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) $options['choices'][$name] = $name; } - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $choiceType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType' - : 'choice'; - $datagridMapper ->add('name') ->add('providerReference') ->add('enabled') ->add('context', null, array( 'show_filter' => $this->getPersistentParameter('hide_context') !== true, - ), $choiceType, $options); + ), 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', $options); if (null !== $this->categoryManager) { $datagridMapper->add('category', null, array('show_filter' => false)); @@ -59,19 +54,14 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) $providers[$name] = $name; } - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $ormChoiceType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter' - : 'doctrine_orm_choice'; - - $datagridMapper->add('providerName', $ormChoiceType, array( + $datagridMapper->add('providerName', 'Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter', array( 'field_options' => array( 'choices' => $providers, 'required' => false, 'multiple' => false, 'expanded' => false, ), - 'field_type' => $choiceType, + 'field_type' => 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', )); } } diff --git a/Block/FeatureMediaBlockService.php b/Block/FeatureMediaBlockService.php index a31d4a59e0..bb334bb160 100644 --- a/Block/FeatureMediaBlockService.php +++ b/Block/FeatureMediaBlockService.php @@ -45,30 +45,17 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) { $formatChoices = $this->getFormatChoices($block->getSetting('mediaId')); - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - $immutableArrayType = 'Sonata\CoreBundle\Form\Type\ImmutableArrayType'; - $textType = 'Symfony\Component\Form\Extension\Core\Type\TextType'; - $textareaType = 'Symfony\Component\Form\Extension\Core\Type\TextareaType'; - $choiceType = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; - } else { - $immutableArrayType = 'sonata_type_immutable_array'; - $textType = 'text'; - $textareaType = 'textarea'; - $choiceType = 'choice'; - } - - $formMapper->add('settings', $immutableArrayType, array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( 'keys' => array( - array('title', $textType, array( + array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( 'required' => false, 'label' => 'form.label_title', )), - array('content', $textareaType, array( + array('content', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', array( 'required' => false, 'label' => 'form.label_content', )), - array('orientation', $choiceType, array( + array('orientation', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'required' => false, 'choices' => array( 'left' => 'form.label_orientation_left', @@ -77,7 +64,7 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) 'label' => 'form.label_orientation', )), array($this->getMediaBuilder($formMapper), null, array()), - array('format', $choiceType, array( + array('format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'required' => count($formatChoices) > 0, 'choices' => $formatChoices, 'label' => 'form.label_format', diff --git a/Block/GalleryBlockService.php b/Block/GalleryBlockService.php index 8df117c558..50ea8c3ceb 100644 --- a/Block/GalleryBlockService.php +++ b/Block/GalleryBlockService.php @@ -125,51 +125,34 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) $fieldDescription->setOption('edit', 'list'); $fieldDescription->setAssociationMapping(array('fieldName' => 'gallery', 'type' => ClassMetadataInfo::MANY_TO_ONE)); - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - $modelListType = 'Sonata\AdminBundle\Form\Type\ModelListType'; - $immutableArrayType = 'Sonata\CoreBundle\Form\Type\ImmutableArrayType'; - $textType = 'Symfony\Component\Form\Extension\Core\Type\TextType'; - $choiceType = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; - $numberType = 'Symfony\Component\Form\Extension\Core\Type\NumberType'; - $checkboxType = 'Symfony\Component\Form\Extension\Core\Type\CheckboxType'; - } else { - $modelListType = 'sonata_type_model_list'; - $immutableArrayType = 'sonata_type_immutable_array'; - $textType = 'text'; - $choiceType = 'choice'; - $numberType = 'number'; - $checkboxType = 'checkbox'; - } - - $builder = $formMapper->create('galleryId', $modelListType, array( + $builder = $formMapper->create('galleryId', 'Sonata\AdminBundle\Form\Type\ModelListType', array( 'sonata_field_description' => $fieldDescription, 'class' => $this->getGalleryAdmin()->getClass(), 'model_manager' => $this->getGalleryAdmin()->getModelManager(), 'label' => 'form.label_gallery', )); - $formMapper->add('settings', $immutableArrayType, array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( 'keys' => array( - array('title', $textType, array( + array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( 'required' => false, 'label' => 'form.label_title', )), - array('context', $choiceType, array( + array('context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'required' => true, 'choices' => $contextChoices, 'label' => 'form.label_context', )), - array('format', $choiceType, array( + array('format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'required' => count($formatChoices) > 0, 'choices' => $formatChoices, 'label' => 'form.label_format', )), array($builder, null, array()), - array('pauseTime', $numberType, array( + array('pauseTime', 'Symfony\Component\Form\Extension\Core\Type\NumberType', array( 'label' => 'form.label_pause_time', )), - array('startPaused', $checkboxType, array( + array('startPaused', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', array( 'required' => false, 'label' => 'form.label_start_paused', )), diff --git a/Block/GalleryListBlockService.php b/Block/GalleryListBlockService.php index 81aea1b3f6..4581175b97 100755 --- a/Block/GalleryListBlockService.php +++ b/Block/GalleryListBlockService.php @@ -59,42 +59,29 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) $contextChoices[$name] = $name; } - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - $immutableArrayType = 'Sonata\CoreBundle\Form\Type\ImmutableArrayType'; - $textType = 'Symfony\Component\Form\Extension\Core\Type\TextType'; - $integerType = 'Symfony\Component\Form\Extension\Core\Type\IntegerType'; - $choiceType = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; - } else { - $immutableArrayType = 'sonata_type_immutable_array'; - $textType = 'text'; - $integerType = 'integer'; - $choiceType = 'choice'; - } - - $formMapper->add('settings', $immutableArrayType, array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( 'keys' => array( - array('title', $textType, array( + array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( 'label' => 'form.label_title', 'required' => false, )), - array('number', $integerType, array( + array('number', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', array( 'label' => 'form.label_number', 'required' => true, )), - array('context', $choiceType, array( + array('context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'required' => true, 'label' => 'form.label_context', 'choices' => $contextChoices, )), - array('mode', $choiceType, array( + array('mode', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'label' => 'form.label_mode', 'choices' => array( 'public' => 'form.label_mode_public', 'admin' => 'form.label_mode_admin', ), )), - array('order', $choiceType, array( + array('order', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'label' => 'form.label_order', 'choices' => array( 'name' => 'form.label_order_name', @@ -102,7 +89,7 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) 'updatedAt' => 'form.label_order_updated_at', ), )), - array('sort', $choiceType, array( + array('sort', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'label' => 'form.label_sort', 'choices' => array( 'desc' => 'form.label_sort_desc', diff --git a/Block/MediaBlockService.php b/Block/MediaBlockService.php index 998f80a4f3..8928b4ed34 100644 --- a/Block/MediaBlockService.php +++ b/Block/MediaBlockService.php @@ -102,25 +102,14 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) $formatChoices = $this->getFormatChoices($block->getSetting('mediaId')); - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { - $immutableArrayType = 'Sonata\CoreBundle\Form\Type\ImmutableArrayType'; - $textType = 'Symfony\Component\Form\Extension\Core\Type\TextType'; - $choiceType = 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; - } else { - $immutableArrayType = 'sonata_type_immutable_array'; - $textType = 'text'; - $choiceType = 'choice'; - } - - $formMapper->add('settings', $immutableArrayType, array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( 'keys' => array( - array('title', $textType, array( + array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( 'required' => false, 'label' => 'form.label_title', )), array($this->getMediaBuilder($formMapper), null, array()), - array('format', $choiceType, array( + array('format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( 'required' => count($formatChoices) > 0, 'choices' => $formatChoices, 'label' => 'form.label_format', @@ -233,12 +222,7 @@ protected function getMediaBuilder(FormMapper $formMapper) 'type' => ClassMetadataInfo::MANY_TO_ONE, )); - // NEXT_MAJOR: Keep FQCN when bumping Symfony requirement to 2.8+. - $modelListType = method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') - ? 'Sonata\AdminBundle\Form\Type\ModelListType' - : 'sonata_type_model_list'; - - return $formMapper->create('mediaId', $modelListType, array( + return $formMapper->create('mediaId', 'Sonata\AdminBundle\Form\Type\ModelListType', array( 'sonata_field_description' => $fieldDescription, 'class' => $this->getMediaAdmin()->getClass(), 'model_manager' => $this->getMediaAdmin()->getModelManager(), diff --git a/Controller/MediaController.php b/Controller/MediaController.php index 5c813d71b4..23f616f492 100644 --- a/Controller/MediaController.php +++ b/Controller/MediaController.php @@ -15,6 +15,7 @@ use Sonata\MediaBundle\Provider\MediaProviderInterface; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\Security\Core\Exception\AccessDeniedException; @@ -44,12 +45,13 @@ public function getMedia($id) /** * @throws NotFoundHttpException * - * @param string $id - * @param string $format + * @param Request $request + * @param string $id + * @param string $format * * @return Response */ - public function downloadAction($id, $format = 'reference') + public function downloadAction(Request $request, $id, $format = 'reference') { $media = $this->getMedia($id); @@ -57,14 +59,14 @@ public function downloadAction($id, $format = 'reference') throw new NotFoundHttpException(sprintf('unable to find the media with the id : %s', $id)); } - if (!$this->get('sonata.media.pool')->getDownloadSecurity($media)->isGranted($media, $this->getCurrentRequest())) { + if (!$this->get('sonata.media.pool')->getDownloadSecurity($media)->isGranted($media, $request)) { throw new AccessDeniedException(); } $response = $this->getProvider($media)->getDownloadResponse($media, $format, $this->get('sonata.media.pool')->getDownloadMode($media)); if ($response instanceof BinaryFileResponse) { - $response->prepare($this->getCurrentRequest()); + $response->prepare($request); } return $response; @@ -73,12 +75,13 @@ public function downloadAction($id, $format = 'reference') /** * @throws NotFoundHttpException * - * @param string $id - * @param string $format + * @param Request $request + * @param string $id + * @param string $format * * @return Response */ - public function viewAction($id, $format = 'reference') + public function viewAction(Request $request, $id, $format = 'reference') { $media = $this->getMedia($id); @@ -86,7 +89,7 @@ public function viewAction($id, $format = 'reference') throw new NotFoundHttpException(sprintf('unable to find the media with the id : %s', $id)); } - if (!$this->get('sonata.media.pool')->getDownloadSecurity($media)->isGranted($media, $this->getCurrentRequest())) { + if (!$this->get('sonata.media.pool')->getDownloadSecurity($media)->isGranted($media, $request)) { throw new AccessDeniedException(); } @@ -102,18 +105,19 @@ public function viewAction($id, $format = 'reference') * optionally saves the image and * outputs it to the browser at the same time. * - * @param string $path - * @param string $filter + * @param Request $request + * @param string $path + * @param string $filter * * @return Response */ - public function liipImagineFilterAction($path, $filter) + public function liipImagineFilterAction(Request $request, $path, $filter) { if (!preg_match('@([^/]*)/(.*)/([0-9]*)_([a-z_A-Z]*).jpg@', $path, $matches)) { throw new NotFoundHttpException(); } - $targetPath = $this->get('liip_imagine.cache.manager')->resolve($this->getCurrentRequest(), $path, $filter); + $targetPath = $this->get('liip_imagine.cache.manager')->resolve($request, $path, $filter); if ($targetPath instanceof Response) { return $targetPath; @@ -134,7 +138,7 @@ public function liipImagineFilterAction($path, $filter) $image = $this->get('liip_imagine')->open($tmpFile); - $response = $this->get('liip_imagine.filter.manager')->get($this->getCurrentRequest(), $filter, $image, $path); + $response = $this->get('liip_imagine.filter.manager')->get($request, $filter, $image, $path); if ($targetPath) { $response = $this->get('liip_imagine.cache.manager')->store($response, $targetPath, $filter); @@ -142,19 +146,4 @@ public function liipImagineFilterAction($path, $filter) return $response; } - - /** - * NEXT_MAJOR: Remove this method when bumping Symfony requirement to 2.8+. - * Inject the Symfony\Component\HttpFoundation\Request into the actions instead. - * - * @return Request - */ - private function getCurrentRequest() - { - if ($this->has('request_stack')) { - return $this->get('request_stack')->getCurrentRequest(); - } - - return $this->get('request'); - } } diff --git a/DependencyInjection/SonataMediaExtension.php b/DependencyInjection/SonataMediaExtension.php index 566933aba7..406e357604 100644 --- a/DependencyInjection/SonataMediaExtension.php +++ b/DependencyInjection/SonataMediaExtension.php @@ -42,25 +42,6 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('extra.xml'); $loader->load('form.xml'); $loader->load('gaufrette.xml'); - - // NEXT_MAJOR: Remove Following lines - $amazonS3Definition = $container->getDefinition('sonata.media.adapter.service.s3'); - if (method_exists($amazonS3Definition, 'setFactory')) { - $amazonS3Definition->setFactory(array('Aws\S3\S3Client', 'factory')); - } else { - $amazonS3Definition->setFactoryClass('Aws\S3\S3Client'); - $amazonS3Definition->setFactoryMethod('factory'); - } - - // NEXT_MAJOR: Remove Following lines - $openCloudDefinition = $container->getDefinition('sonata.media.adapter.filesystem.opencloud.objectstore'); - if (method_exists($openCloudDefinition, 'setFactory')) { - $openCloudDefinition->setFactory(array(new Reference('sonata.media.adapter.filesystem.opencloud.connection'), 'ObjectStore')); - } else { - $openCloudDefinition->setFactoryService('sonata.media.adapter.filesystem.opencloud.connection'); - $openCloudDefinition->setFactoryMethod('ObjectStore'); - } - $loader->load('validators.xml'); $loader->load('serializer.xml'); diff --git a/Model/Media.php b/Model/Media.php index 56c44182a1..7faa075408 100644 --- a/Model/Media.php +++ b/Model/Media.php @@ -12,9 +12,7 @@ namespace Sonata\MediaBundle\Model; use Imagine\Image\Box; -use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\Mapping\ClassMetadata; abstract class Media implements MediaInterface { @@ -611,21 +609,6 @@ public function getPreviousProviderReference() return $this->previousProviderReference; } - /** - * NEXT_MAJOR: Remove this method when bumping Symfony requirement to 2.8+. - * - * @param ClassMetadata $metadata - */ - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - if (class_exists('Symfony\Component\Validator\Constraints\Expression')) { - $method = 'isStatusErroneous'; - } else { - $method = array('methods' => array('isStatusErroneous')); - } - $metadata->addConstraint(new Assert\Callback($method)); - } - /** * @param ExecutionContextInterface $context */ diff --git a/Resources/config/gaufrette.xml b/Resources/config/gaufrette.xml index 3dd39e3f6d..9cb820144f 100644 --- a/Resources/config/gaufrette.xml +++ b/Resources/config/gaufrette.xml @@ -10,9 +10,7 @@ - @@ -39,9 +37,7 @@ - diff --git a/Resources/config/validation.xml b/Resources/config/validation.xml index 52e2ad431d..df75033ae4 100644 --- a/Resources/config/validation.xml +++ b/Resources/config/validation.xml @@ -1,9 +1,7 @@ - diff --git a/Tests/Admin/BaseMediaAdminTest.php b/Tests/Admin/BaseMediaAdminTest.php index 188319e0aa..36fce28c4e 100644 --- a/Tests/Admin/BaseMediaAdminTest.php +++ b/Tests/Admin/BaseMediaAdminTest.php @@ -97,12 +97,7 @@ private function configureGetPersistentParameters() private function configureGetProviderName($media) { - // NEXT_MAJOR remove this block when dropping sf < 2.8 compatibility - if (method_exists('Symfony\Component\HttpFoundation\JsonResponse', 'transformJsonError')) { - $this->request->get('uniqid[providerName]', null, true)->willReturn('providerName'); - } else { - $this->request->get('uniqid')->willReturn(array('providerName' => 'providerName')); - } + $this->request->get('uniqid')->willReturn(array('providerName' => 'providerName')); $media->setProviderName('providerName')->shouldBeCalled(); } } diff --git a/Tests/Controller/GalleryAdminControllerTest.php b/Tests/Controller/GalleryAdminControllerTest.php index 03041d4117..8645aafb07 100644 --- a/Tests/Controller/GalleryAdminControllerTest.php +++ b/Tests/Controller/GalleryAdminControllerTest.php @@ -83,38 +83,22 @@ private function configureCRUDController() private function configureGetCurrentRequest($request) { - // NEXT_MAJOR: Remove this trick when bumping Symfony requirement to 2.8+. - if (class_exists('Symfony\Component\HttpFoundation\RequestStack')) { - $requestStack = $this->prophesize('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack = $this->prophesize('Symfony\Component\HttpFoundation\RequestStack'); - $this->container->has('request_stack')->willReturn(true); - $this->container->get('request_stack')->willReturn($requestStack->reveal()); - $requestStack->getCurrentRequest()->willReturn($request); - } else { - $this->container->has('request_stack')->willReturn(false); - $this->container->get('request')->willReturn($request); - } + $this->container->has('request_stack')->willReturn(true); + $this->container->get('request_stack')->willReturn($requestStack->reveal()); + $requestStack->getCurrentRequest()->willReturn($request); } private function configureSetCsrfToken($intention) { - // NEXT_MAJOR: Remove this trick when bumping Symfony requirement to 2.8+. - if (interface_exists('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')) { - $tokenManager = $this->prophesize('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); - $token = $this->prophesize('Symfony\Component\Security\Csrf\CsrfToken'); - - $tokenManager->getToken($intention)->willReturn($token->reveal()); - $token->getValue()->willReturn('token'); - $this->container->has('security.csrf.token_manager')->willReturn(true); - $this->container->get('security.csrf.token_manager')->willReturn($tokenManager->reveal()); - } else { - $csrfProvider = $this->prophesize('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'); + $tokenManager = $this->prophesize('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); + $token = $this->prophesize('Symfony\Component\Security\Csrf\CsrfToken'); - $csrfProvider->generateCsrfToken($intention)->shouldBeCalled('token'); - $this->container->has('security.csrf.token_manager')->willReturn(false); - $this->container->has('form.csrf_provider')->willReturn(true); - $this->container->get('form.csrf_provider')->willReturn($csrfProvider->reveal()); - } + $tokenManager->getToken($intention)->willReturn($token->reveal()); + $token->getValue()->willReturn('token'); + $this->container->has('security.csrf.token_manager')->willReturn(true); + $this->container->get('security.csrf.token_manager')->willReturn($tokenManager->reveal()); } private function configureSetFormTheme($formView, $formTheme) diff --git a/Tests/Controller/MediaAdminControllerTest.php b/Tests/Controller/MediaAdminControllerTest.php index 5b82ba2b5a..9ce0834480 100644 --- a/Tests/Controller/MediaAdminControllerTest.php +++ b/Tests/Controller/MediaAdminControllerTest.php @@ -158,17 +158,11 @@ private function configureCreateAction($class) private function configureGetCurrentRequest($request) { - // NEXT_MAJOR: Remove this trick when bumping Symfony requirement to 2.8+. - if (class_exists('Symfony\Component\HttpFoundation\RequestStack')) { - $requestStack = $this->prophesize('Symfony\Component\HttpFoundation\RequestStack'); + $requestStack = $this->prophesize('Symfony\Component\HttpFoundation\RequestStack'); - $this->container->has('request_stack')->willReturn(true); - $this->container->get('request_stack')->willReturn($requestStack->reveal()); - $requestStack->getCurrentRequest()->willReturn($request); - } else { - $this->container->has('request_stack')->willReturn(false); - $this->container->get('request')->willReturn($request); - } + $this->container->has('request_stack')->willReturn(true); + $this->container->get('request_stack')->willReturn($requestStack->reveal()); + $requestStack->getCurrentRequest()->willReturn($request); } private function configureSetFormTheme($formView, $formTheme) @@ -194,23 +188,13 @@ private function configureSetFormTheme($formView, $formTheme) private function configureSetCsrfToken($intention) { - // NEXT_MAJOR: Remove this trick when bumping Symfony requirement to 2.8+. - if (interface_exists('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')) { - $tokenManager = $this->prophesize('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); - $token = $this->prophesize('Symfony\Component\Security\Csrf\CsrfToken'); - - $tokenManager->getToken($intention)->willReturn($token->reveal()); - $token->getValue()->willReturn('token'); - $this->container->has('security.csrf.token_manager')->willReturn(true); - $this->container->get('security.csrf.token_manager')->willReturn($tokenManager->reveal()); - } else { - $csrfProvider = $this->prophesize('Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface'); + $tokenManager = $this->prophesize('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); + $token = $this->prophesize('Symfony\Component\Security\Csrf\CsrfToken'); - $csrfProvider->generateCsrfToken($intention)->shouldBeCalled('token'); - $this->container->has('security.csrf.token_manager')->willReturn(false); - $this->container->has('form.csrf_provider')->willReturn(true); - $this->container->get('form.csrf_provider')->willReturn($csrfProvider->reveal()); - } + $tokenManager->getToken($intention)->willReturn($token->reveal()); + $token->getValue()->willReturn('token'); + $this->container->has('security.csrf.token_manager')->willReturn(true); + $this->container->get('security.csrf.token_manager')->willReturn($tokenManager->reveal()); } private function configureRender($template, $data, $rendered) diff --git a/Tests/Controller/MediaControllerTest.php b/Tests/Controller/MediaControllerTest.php index a26272258d..91f7cf1628 100644 --- a/Tests/Controller/MediaControllerTest.php +++ b/Tests/Controller/MediaControllerTest.php @@ -31,9 +31,11 @@ public function testDownloadActionWithNotFoundMedia() { $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); + $request = $this->prophesize('Symfony\Component\HttpFoundation\Request'); + $this->configureGetMedia(1, null); - $this->controller->downloadAction(1); + $this->controller->downloadAction($request->reveal(), 1); } public function testDownloadActionAccessDenied() @@ -44,12 +46,11 @@ public function testDownloadActionAccessDenied() $media = $this->prophesize('Sonata\MediaBundle\Model\Media'); $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); - $this->configureGetCurrentRequest($request->reveal()); $this->configureGetMedia(1, $media->reveal()); $this->configureDownloadSecurity($pool, $media->reveal(), $request->reveal(), false); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); - $this->controller->downloadAction(1); + $this->controller->downloadAction($request->reveal(), 1); } public function testDownloadActionBinaryFile() @@ -63,13 +64,12 @@ public function testDownloadActionBinaryFile() $this->configureGetMedia(1, $media->reveal()); $this->configureDownloadSecurity($pool, $media->reveal(), $request->reveal(), true); $this->configureGetProvider($pool, $media, $provider->reveal()); - $this->configureGetCurrentRequest($request->reveal()); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); $pool->getDownloadMode($media->reveal())->willReturn('mode'); $provider->getDownloadResponse($media->reveal(), 'format', 'mode')->willReturn($response->reveal()); $response->prepare($request->reveal())->shouldBeCalled(); - $result = $this->controller->downloadAction(1, 'format'); + $result = $this->controller->downloadAction($request->reveal(), 1, 'format'); $this->assertSame($response->reveal(), $result); } @@ -78,9 +78,11 @@ public function testViewActionWithNotFoundMedia() { $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); + $request = $this->prophesize('Symfony\Component\HttpFoundation\Request'); + $this->configureGetMedia(1, null); - $this->controller->viewAction(1); + $this->controller->viewAction($request->reveal(), 1); } public function testViewActionAccessDenied() @@ -92,11 +94,10 @@ public function testViewActionAccessDenied() $request = $this->prophesize('Symfony\Component\HttpFoundation\Request'); $this->configureGetMedia(1, $media->reveal()); - $this->configureGetCurrentRequest($request->reveal()); $this->configureDownloadSecurity($pool, $media->reveal(), $request->reveal(), false); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); - $this->controller->viewAction(1); + $this->controller->viewAction($request->reveal(), 1); } public function testViewActionRendersView() @@ -106,7 +107,6 @@ public function testViewActionRendersView() $request = $this->prophesize('Symfony\Component\HttpFoundation\Request'); $this->configureGetMedia(1, $media->reveal()); - $this->configureGetCurrentRequest($request->reveal()); $this->configureDownloadSecurity($pool, $media->reveal(), $request->reveal(), true); $this->configureRender('SonataMediaBundle:Media:view.html.twig', array( 'media' => $media->reveal(), @@ -117,7 +117,7 @@ public function testViewActionRendersView() $media->getContext()->willReturn('context'); $pool->getFormatNamesByContext('context')->willReturn(array('format')); - $response = $this->controller->viewAction(1, 'format'); + $response = $this->controller->viewAction($request->reveal(), 1, 'format'); $this->assertSame('renderResponse', $response); } @@ -144,21 +144,6 @@ private function configureGetProvider($pool, $media, $provider) $media->getProviderName()->willReturn('provider'); } - private function configureGetCurrentRequest($request) - { - // NEXT_MAJOR: Remove this trick when bumping Symfony requirement to 2.8+. - if (class_exists('Symfony\Component\HttpFoundation\RequestStack')) { - $requestStack = $this->prophesize('Symfony\Component\HttpFoundation\RequestStack'); - - $this->container->has('request_stack')->willReturn(true); - $this->container->get('request_stack')->willReturn($requestStack->reveal()); - $requestStack->getCurrentRequest()->willReturn($request); - } else { - $this->container->has('request_stack')->willReturn(false); - $this->container->get('request')->willReturn($request); - } - } - private function configureRender($template, $data, $rendered) { $templating = $this->prophesize('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); diff --git a/Tests/Form/Type/AbstractTypeTest.php b/Tests/Form/Type/AbstractTypeTest.php index d623100a0d..26085ad01f 100644 --- a/Tests/Form/Type/AbstractTypeTest.php +++ b/Tests/Form/Type/AbstractTypeTest.php @@ -54,20 +54,7 @@ protected function setUp() ->method('add') ->will($this->returnCallback(function ($name, $type = null) use ($that) { if (null !== $type) { - $isFQCN = class_exists($type); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $type - ), - E_USER_DEPRECATED) - ; - } - - $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); + $that->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } })); @@ -89,20 +76,7 @@ public function testGetParent() { $parentRef = $this->formType->getParent(); - $isFQCN = class_exists($parentRef); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $parentRef - ), - E_USER_DEPRECATED) - ; - } - - $this->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $parentRef)); + $this->assertTrue(class_exists($parentRef), sprintf('Unable to ensure %s is a FQCN', $parentRef)); } /** diff --git a/Tests/Provider/AbstractProviderTest.php b/Tests/Provider/AbstractProviderTest.php index 748be43d79..a65f35540b 100644 --- a/Tests/Provider/AbstractProviderTest.php +++ b/Tests/Provider/AbstractProviderTest.php @@ -53,20 +53,7 @@ protected function setUp() ->method('add') ->will($this->returnCallback(function ($name, $type = null) use ($that) { if (null !== $type) { - $isFQCN = class_exists($type); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $type - ), - E_USER_DEPRECATED) - ; - } - - $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); + $that->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } })); @@ -76,20 +63,7 @@ protected function setUp() ->method('add') ->will($this->returnCallback(function ($name, $type = null) use ($that) { if (null !== $type) { - $isFQCN = class_exists($type); - if (!$isFQCN && method_exists('Symfony\Component\Form\AbstractType', 'getName')) { - // 2.8 - @trigger_error( - sprintf( - 'Accessing type "%s" by its string name is deprecated since version 2.8 and will be removed in 3.0.' - .' Use the fully-qualified type class name instead.', - $type - ), - E_USER_DEPRECATED) - ; - } - - $that->assertTrue($isFQCN, sprintf('Unable to ensure %s is a FQCN', $type)); + $that->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } })); diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index c96a651907..5c2fb15d38 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -9,20 +9,27 @@ Please read [3.x](https://github.com/sonata-project/SonataMediaBundle/tree/3.x) See also the [diff code](https://github.com/sonata-project/SonataMediaBundle/compare/3.x...4.0.0). +## Controllers + +`MediaController` actions were changed to introduce `Request $request` as first parameter. +You must update those signatures if you want to still extend this class: +`downloadAction`, `listAction` and `liipImagineFilterAction` + ## Blocks -The property `wrap` in `GalleryBlockService` was removed. You must create a custom block, if you still want to use ist. +The property `wrap` in `GalleryBlockService` was removed. You must create a custom block, if you still want to use it. ## Models + If you have implemented a custom model, you must adapt the signature of the following new methods: * `GalleryHasMediaInterface::getId` * `GalleryInterface::getId` - + ## Renamed GalleryHasMedia to GalleryItem All Actions, Controllers, Interfaces and anything related to this is renamed accordingly. ## Removed classification dependency -The category feature is now optional and can be disabled in the configuration. +The category feature is now optional and can be disabled in the configuration. If you need this feature you have to require `sonata-project/classifcation-bundle` via composer. From 11f734ea7df550fe7380ca14410c68d4c60cb7f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Wed, 13 Sep 2017 11:53:46 +0200 Subject: [PATCH 24/77] Remove unwanted build jobs --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 860f2db7ba..808c20dd3e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,10 +46,6 @@ matrix: env: TARGET=lint - php: '5.3' env: COMPOSER_FLAGS="--prefer-lowest" - - php: '7.1' - env: SYMFONY=2.3.* - - php: '7.1' - env: SYMFONY=2.7.* - php: '7.1' env: SYMFONY=2.8.* - php: '7.1' From 504b5004ba42c224c4a829affb4481d617f8d49f Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Thu, 14 Sep 2017 06:59:30 +0200 Subject: [PATCH 25/77] DevKit updates (#1293) --- .travis.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 808c20dd3e..6dc53a9ffa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,11 +10,6 @@ branches: language: php php: - - '5.3' - - '5.4' - - '5.5' - - '5.6' - - '7.0' - '7.1' - nightly @@ -44,7 +39,7 @@ matrix: env: TARGET=docs - php: '7.1' env: TARGET=lint - - php: '5.3' + - php: '7.1' env: COMPOSER_FLAGS="--prefer-lowest" - php: '7.1' env: SYMFONY=2.8.* From d93bfe064fcac7922f0f8f9d4899db7c9fce435a Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Thu, 21 Sep 2017 06:15:09 +0200 Subject: [PATCH 26/77] DevKit updates (#1296) --- .travis/before_install_test.sh | 6 ------ .travis/before_script_test.sh | 7 ------- 2 files changed, 13 deletions(-) diff --git a/.travis/before_install_test.sh b/.travis/before_install_test.sh index bc4613c9b1..d6e9f88f34 100755 --- a/.travis/before_install_test.sh +++ b/.travis/before_install_test.sh @@ -6,12 +6,6 @@ if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ]; then TRAVIS_INI_FILE="$PHP_INI_DIR/travis.ini" echo "memory_limit=3072M" >> "$TRAVIS_INI_FILE" - if [ "$TRAVIS_PHP_VERSION" '<' '5.4' ]; then - XDEBUG_INI_FILE="$PHP_INI_DIR/xdebug.ini" - if [ -f "$XDEBUG_INI_FILE" ]; then - mv "$XDEBUG_INI_FILE" /tmp - fi - fi if [ "$TRAVIS_PHP_VERSION" '<' '7.0' ]; then echo "extension=mongo.so" >> "$TRAVIS_INI_FILE" diff --git a/.travis/before_script_test.sh b/.travis/before_script_test.sh index 936d4f590a..87b475092d 100644 --- a/.travis/before_script_test.sh +++ b/.travis/before_script_test.sh @@ -1,10 +1,3 @@ #!/usr/bin/env bash set -ev -if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ "$TRAVIS_PHP_VERSION" '<' '5.4' ]; then - PHP_INI_DIR="$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/" - XDEBUG_INI_FILE="/tmp/xdebug.ini" - if [ -f "$XDEBUG_INI_FILE" ]; then - mv "$XDEBUG_INI_FILE" "$PHP_INI_DIR" - fi -fi From 8cdfef23da41c7d8d2425c097f7c9d61a6027b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 14 Oct 2017 09:58:59 +0200 Subject: [PATCH 27/77] Use short array syntax --- Admin/BaseMediaAdmin.php | 12 +- Admin/GalleryAdmin.php | 38 ++--- Admin/GalleryItemAdmin.php | 10 +- Admin/ORM/MediaAdmin.php | 22 +-- Admin/PHPCR/GalleryAdmin.php | 8 +- Admin/PHPCR/MediaAdmin.php | 8 +- .../BaseGalleryBreadcrumbBlockService.php | 6 +- .../GalleryViewBreadcrumbBlockService.php | 12 +- .../MediaViewBreadcrumbBlockService.php | 12 +- Block/FeatureMediaBlockService.php | 42 +++--- Block/GalleryBlockService.php | 66 ++++----- Block/GalleryListBlockService.php | 66 ++++----- Block/MediaBlockService.php | 46 +++--- CDN/CloudFront.php | 26 ++-- CDN/PantherPortal.php | 4 +- Command/AddMassMediaCommand.php | 6 +- Command/AddMediaCommand.php | 6 +- Command/CleanMediaCommand.php | 10 +- Command/FixMediaContextCommand.php | 4 +- Command/MigrateToJsonTypeCommand.php | 2 +- Command/RefreshMetadataCommand.php | 8 +- Command/RemoveThumbsCommand.php | 14 +- Command/SyncThumbsCommand.php | 14 +- Command/UpdateCdnStatusCommand.php | 8 +- Consumer/CreateThumbnailConsumer.php | 4 +- Controller/Api/GalleryController.php | 42 +++--- Controller/Api/MediaController.php | 24 +-- Controller/GalleryAdminController.php | 6 +- Controller/GalleryController.php | 16 +- Controller/MediaAdminController.php | 14 +- Controller/MediaController.php | 4 +- .../Compiler/AddProviderCompilerPass.php | 8 +- .../Compiler/GlobalVariablesCompilerPass.php | 2 +- DependencyInjection/Configuration.php | 24 +-- DependencyInjection/SonataMediaExtension.php | 130 ++++++++--------- Document/GalleryManager.php | 2 +- Document/MediaManager.php | 2 +- Entity/GalleryManager.php | 6 +- Entity/MediaManager.php | 4 +- Extra/Pixlr.php | 22 +-- Filesystem/Replicate.php | 6 +- .../ProviderDataTransformer.php | 8 +- .../ServiceProviderDataTransformer.php | 2 +- Form/Type/ApiMediaType.php | 8 +- Form/Type/MediaType.php | 16 +- Listener/ODM/MediaEventSubscriber.php | 4 +- Listener/ORM/MediaEventSubscriber.php | 4 +- Listener/PHPCR/MediaEventSubscriber.php | 4 +- Metadata/AmazonMetadataBuilder.php | 8 +- Metadata/NoopMetadataBuilder.php | 2 +- Metadata/ProxyMetadataBuilder.php | 6 +- Model/Media.php | 8 +- Model/MediaInterface.php | 2 +- PHPCR/GalleryManager.php | 2 +- PHPCR/MediaManager.php | 2 +- Provider/BaseProvider.php | 8 +- Provider/BaseVideoProvider.php | 26 ++-- Provider/DailyMotionProvider.php | 14 +- Provider/FileProvider.php | 38 ++--- Provider/ImageProvider.php | 10 +- Provider/MediaProviderInterface.php | 4 +- Provider/Pool.php | 24 +-- Provider/VimeoProvider.php | 16 +- Provider/YouTubeProvider.php | 24 +-- Resizer/SimpleResizer.php | 6 +- Resizer/SquareResizer.php | 4 +- Security/ForbiddenDownloadStrategy.php | 2 +- Security/PublicDownloadStrategy.php | 2 +- Security/RolesDownloadStrategy.php | 4 +- Security/SessionDownloadStrategy.php | 2 +- SonataMediaBundle.php | 4 +- Templating/Helper/MediaHelper.php | 16 +- Tests/Admin/BaseMediaAdminTest.php | 6 +- Tests/Block/FeatureMediaBlockServiceTest.php | 8 +- Tests/Block/GalleryBlockServiceTest.php | 12 +- Tests/Block/GalleryListBlockServiceTest.php | 8 +- Tests/Block/MediaBlockServiceTest.php | 12 +- Tests/CDN/CloudFrontTest.php | 12 +- Tests/CDN/PantherPortalTest.php | 12 +- Tests/Command/CleanMediaCommandTest.php | 138 +++++++++--------- Tests/Command/FixMediaContextCommandTest.php | 50 +++---- .../Controller/Api/GalleryControllerTest.php | 32 ++-- Tests/Controller/Api/MediaControllerTest.php | 32 ++-- .../Controller/GalleryAdminControllerTest.php | 2 +- Tests/Controller/MediaAdminControllerTest.php | 10 +- Tests/Controller/MediaControllerTest.php | 8 +- .../DependencyInjection/ConfigurationTest.php | 8 +- .../SonataMediaExtensionTest.php | 96 ++++++------ Tests/Document/MediaManagerTest.php | 2 +- Tests/Entity/GalleryManagerTest.php | 32 ++-- Tests/Entity/MediaManagerTest.php | 32 ++-- Tests/Entity/MediaTest.php | 2 +- Tests/Filesystem/ReplicateTest.php | 4 +- .../ProviderDataTransformerTest.php | 24 +-- .../ServiceProviderDataTransformerTest.php | 2 +- Tests/Form/Type/AbstractTypeTest.php | 4 +- Tests/Form/Type/ApiMediaTypeTest.php | 2 +- Tests/Form/Type/MediaTypeTest.php | 76 +++++----- .../Listener/ORM/MediaEventSubscriberTest.php | 24 +-- Tests/Metadata/AmazonMetadataBuilderTest.php | 28 ++-- Tests/Metadata/NoopMetadataBuilderTest.php | 2 +- Tests/Metadata/ProxyMetadataBuilderTest.php | 54 +++---- Tests/Model/MediaTest.php | 4 +- Tests/PHPCR/MediaManagerTest.php | 2 +- Tests/Provider/BaseProviderTest.php | 16 +- Tests/Provider/DailyMotionProviderTest.php | 16 +- Tests/Provider/FakeHttpWrapper.php | 4 +- Tests/Provider/FileProviderTest.php | 38 ++--- Tests/Provider/ImageProviderTest.php | 26 ++-- Tests/Provider/PoolTest.php | 6 +- Tests/Provider/VimeoProviderTest.php | 24 +-- Tests/Provider/YouTubeProviderTest.php | 42 +++--- Tests/Resizer/SimpleResizerTest.php | 30 ++-- Tests/Resizer/SquareResizerTest.php | 14 +- Tests/Security/RolesDownloadStrategyTest.php | 4 +- Tests/Thumbnail/FormatThumbnailTest.php | 12 +- Tests/Twig/Extension/MediaExtensionTest.php | 14 +- Tests/Validator/FormatValidatorTest.php | 4 +- Tests/tests/bootstrap.php | 4 +- Thumbnail/ConsumerThumbnail.php | 4 +- Thumbnail/FormatThumbnail.php | 2 +- Thumbnail/LiipImagineThumbnail.php | 2 +- Twig/Extension/FormatterMediaExtension.php | 20 +-- Twig/Extension/MediaExtension.php | 28 ++-- Twig/Node/MediaNode.php | 2 +- Twig/Node/PathNode.php | 2 +- Twig/Node/ThumbnailNode.php | 2 +- Twig/TokenParser/MediaTokenParser.php | 2 +- Twig/TokenParser/ThumbnailTokenParser.php | 2 +- 129 files changed, 1053 insertions(+), 1053 deletions(-) diff --git a/Admin/BaseMediaAdmin.php b/Admin/BaseMediaAdmin.php index 1ffbc299f9..836dfd2e84 100644 --- a/Admin/BaseMediaAdmin.php +++ b/Admin/BaseMediaAdmin.php @@ -91,11 +91,11 @@ public function getPersistentParameters() $categoryId = $this->categoryManager->getRootCategory($context)->getId(); } - return array_merge($parameters, array( + return array_merge($parameters, [ 'context' => $context, 'category' => $categoryId, 'hide_context' => (bool) $this->getRequest()->get('hide_context'), - )); + ]); } /** @@ -192,13 +192,13 @@ protected function configureFormFields(FormMapper $formMapper) } if (null !== $this->categoryManager) { - $formMapper->add('category', 'Sonata\AdminBundle\Form\Type\ModelListType', array(), array( - 'link_parameters' => array( + $formMapper->add('category', 'Sonata\AdminBundle\Form\Type\ModelListType', [], [ + 'link_parameters' => [ 'context' => $media->getContext(), 'hide_context' => true, 'mode' => 'tree', - ), - )); + ], + ]); } } } diff --git a/Admin/GalleryAdmin.php b/Admin/GalleryAdmin.php index c054709565..8adb8c4cf6 100644 --- a/Admin/GalleryAdmin.php +++ b/Admin/GalleryAdmin.php @@ -70,9 +70,9 @@ public function getPersistentParameters() return $parameters; } - return array_merge($parameters, array( + return array_merge($parameters, [ 'context' => $this->getRequest()->get('context', $this->pool->getDefaultContext()), - )); + ]); } /** @@ -96,8 +96,8 @@ protected function configureFormFields(FormMapper $formMapper) { // define group zoning $formMapper - ->with('Gallery', array('class' => 'col-md-9'))->end() - ->with('Options', array('class' => 'col-md-3'))->end() + ->with('Gallery', ['class' => 'col-md-9'])->end() + ->with('Options', ['class' => 'col-md-3'])->end() ; $context = $this->getPersistentParameter('context'); @@ -106,37 +106,37 @@ protected function configureFormFields(FormMapper $formMapper) $context = $this->pool->getDefaultContext(); } - $formats = array(); + $formats = []; foreach ((array) $this->pool->getFormatNamesByContext($context) as $name => $options) { $formats[$name] = $name; } - $contexts = array(); + $contexts = []; foreach ((array) $this->pool->getContexts() as $contextItem => $format) { $contexts[$contextItem] = $contextItem; } $formMapper ->with('Options') - ->add('context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ->add('context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'choices' => $contexts, - )) - ->add('enabled', null, array('required' => false)) + ]) + ->add('enabled', null, ['required' => false]) ->add('name') ->ifTrue($formats) - ->add('defaultFormat', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ->add('defaultFormat', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'choices' => $formats, - )) + ]) ->ifEnd() ->end() ->with('Gallery') - ->add('galleryItems', 'Sonata\CoreBundle\Form\Type\CollectionType', array(), array( + ->add('galleryItems', 'Sonata\CoreBundle\Form\Type\CollectionType', [], [ 'edit' => 'inline', 'inline' => 'table', 'sortable' => 'position', - 'link_parameters' => array('context' => $context), + 'link_parameters' => ['context' => $context], 'admin_code' => 'sonata.media.admin.gallery_item', - )) + ]) ->end() ; } @@ -148,9 +148,9 @@ protected function configureListFields(ListMapper $listMapper) { $listMapper ->addIdentifier('name') - ->add('enabled', 'boolean', array('editable' => true)) - ->add('context', 'trans', array('catalogue' => 'SonataMediaBundle')) - ->add('defaultFormat', 'trans', array('catalogue' => 'SonataMediaBundle')) + ->add('enabled', 'boolean', ['editable' => true]) + ->add('context', 'trans', ['catalogue' => 'SonataMediaBundle']) + ->add('defaultFormat', 'trans', ['catalogue' => 'SonataMediaBundle']) ; } @@ -162,9 +162,9 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) $datagridMapper ->add('name') ->add('enabled') - ->add('context', null, array( + ->add('context', null, [ 'show_filter' => false, - )) + ]) ; } } diff --git a/Admin/GalleryItemAdmin.php b/Admin/GalleryItemAdmin.php index a72543079f..ed4fcdade2 100644 --- a/Admin/GalleryItemAdmin.php +++ b/Admin/GalleryItemAdmin.php @@ -22,10 +22,10 @@ class GalleryItemAdmin extends AbstractAdmin */ protected function configureFormFields(FormMapper $formMapper) { - $link_parameters = array(); + $link_parameters = []; if ($this->hasParentFieldDescription()) { - $link_parameters = $this->getParentFieldDescription()->getOption('link_parameters', array()); + $link_parameters = $this->getParentFieldDescription()->getOption('link_parameters', []); } if ($this->hasRequest()) { @@ -37,10 +37,10 @@ protected function configureFormFields(FormMapper $formMapper) } $formMapper - ->add('media', 'Sonata\AdminBundle\Form\Type\ModelListType', array('required' => false), array( + ->add('media', 'Sonata\AdminBundle\Form\Type\ModelListType', ['required' => false], [ 'link_parameters' => $link_parameters, - )) - ->add('enabled', null, array('required' => false)) + ]) + ->add('enabled', null, ['required' => false]) ->add('position', 'Symfony\Component\Form\Extension\Core\Type\HiddenType') ; } diff --git a/Admin/ORM/MediaAdmin.php b/Admin/ORM/MediaAdmin.php index 8ec9b24bd0..996ca55a18 100644 --- a/Admin/ORM/MediaAdmin.php +++ b/Admin/ORM/MediaAdmin.php @@ -21,9 +21,9 @@ class MediaAdmin extends Admin */ protected function configureDatagridFilters(DatagridMapper $datagridMapper) { - $options = array( - 'choices' => array(), - ); + $options = [ + 'choices' => [], + ]; foreach ($this->pool->getContexts() as $name => $context) { $options['choices'][$name] = $name; @@ -33,12 +33,12 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) ->add('name') ->add('providerReference') ->add('enabled') - ->add('context', null, array( + ->add('context', null, [ 'show_filter' => $this->getPersistentParameter('hide_context') !== true, - ), 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', $options); + ], 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', $options); if (null !== $this->categoryManager) { - $datagridMapper->add('category', null, array('show_filter' => false)); + $datagridMapper->add('category', null, ['show_filter' => false]); } $datagridMapper @@ -47,21 +47,21 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) ->add('contentType') ; - $providers = array(); + $providers = []; $providerNames = (array) $this->pool->getProviderNamesByContext($this->getPersistentParameter('context', $this->pool->getDefaultContext())); foreach ($providerNames as $name) { $providers[$name] = $name; } - $datagridMapper->add('providerName', 'Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter', array( - 'field_options' => array( + $datagridMapper->add('providerName', 'Sonata\DoctrineORMAdminBundle\Filter\ChoiceFilter', [ + 'field_options' => [ 'choices' => $providers, 'required' => false, 'multiple' => false, 'expanded' => false, - ), + ], 'field_type' => 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', - )); + ]); } } diff --git a/Admin/PHPCR/GalleryAdmin.php b/Admin/PHPCR/GalleryAdmin.php index ba084160f3..471888933b 100644 --- a/Admin/PHPCR/GalleryAdmin.php +++ b/Admin/PHPCR/GalleryAdmin.php @@ -72,11 +72,11 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) protected function configureRoutes(RouteCollection $collection) { // Allow path in id parameter - $collection->add('view', $this->getRouterIdParameter().'/view', array(), array('id' => '.+', '_method' => 'GET')); - $collection->add('show', $this->getRouterIdParameter().'/show', array( + $collection->add('view', $this->getRouterIdParameter().'/view', [], ['id' => '.+', '_method' => 'GET']); + $collection->add('show', $this->getRouterIdParameter().'/show', [ '_controller' => sprintf('%s:%s', $this->baseControllerName, 'view'), - ), - array('id' => '.+', '_method' => 'GET') + ], + ['id' => '.+', '_method' => 'GET'] ); } } diff --git a/Admin/PHPCR/MediaAdmin.php b/Admin/PHPCR/MediaAdmin.php index de563b918d..c25b223eb7 100644 --- a/Admin/PHPCR/MediaAdmin.php +++ b/Admin/PHPCR/MediaAdmin.php @@ -74,11 +74,11 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) protected function configureRoutes(RouteCollection $collection) { // Allow path in id parameter - $collection->add('view', $this->getRouterIdParameter().'/view', array(), array('id' => '.+', '_method' => 'GET')); - $collection->add('show', $this->getRouterIdParameter().'/show', array( + $collection->add('view', $this->getRouterIdParameter().'/view', [], ['id' => '.+', '_method' => 'GET']); + $collection->add('show', $this->getRouterIdParameter().'/show', [ '_controller' => sprintf('%s:%s', $this->baseControllerName, 'view'), - ), - array('id' => '.+', '_method' => 'GET') + ], + ['id' => '.+', '_method' => 'GET'] ); } } diff --git a/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php b/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php index 778f398e4c..31cf873961 100644 --- a/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php +++ b/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php @@ -28,10 +28,10 @@ protected function getRootMenu(BlockContextInterface $blockContext) { $menu = parent::getRootMenu($blockContext); - $menu->addChild('sonata_media_gallery_index', array( + $menu->addChild('sonata_media_gallery_index', [ 'route' => 'sonata_media_gallery_index', - 'extras' => array('translation_domain' => 'SonataMediaBundle'), - )); + 'extras' => ['translation_domain' => 'SonataMediaBundle'], + ]); return $menu; } diff --git a/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php b/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php index 77f58cd140..2e75281675 100644 --- a/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php +++ b/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php @@ -36,9 +36,9 @@ public function configureSettings(OptionsResolver $resolver) { parent::configureSettings($resolver); - $resolver->setDefaults(array( + $resolver->setDefaults([ 'gallery' => false, - )); + ]); } /** @@ -49,12 +49,12 @@ protected function getMenu(BlockContextInterface $blockContext) $menu = $this->getRootMenu($blockContext); if ($gallery = $blockContext->getBlock()->getSetting('gallery')) { - $menu->addChild($gallery->getName(), array( + $menu->addChild($gallery->getName(), [ 'route' => 'sonata_media_gallery_view', - 'routeParameters' => array( + 'routeParameters' => [ 'id' => $gallery->getId(), - ), - )); + ], + ]); } return $menu; diff --git a/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php b/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php index b165b8574e..16bb1f6983 100644 --- a/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php +++ b/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php @@ -36,9 +36,9 @@ public function configureSettings(OptionsResolver $resolver) { parent::configureSettings($resolver); - $resolver->setDefaults(array( + $resolver->setDefaults([ 'media' => false, - )); + ]); } /** @@ -49,12 +49,12 @@ protected function getMenu(BlockContextInterface $blockContext) $menu = $this->getRootMenu($blockContext); if ($media = $blockContext->getBlock()->getSetting('media')) { - $menu->addChild($media->getName(), array( + $menu->addChild($media->getName(), [ 'route' => 'sonata_media_view', - 'routeParameters' => array( + 'routeParameters' => [ 'id' => $media->getId(), - ), - )); + ], + ]); } return $menu; diff --git a/Block/FeatureMediaBlockService.php b/Block/FeatureMediaBlockService.php index bb334bb160..75370ca6ab 100644 --- a/Block/FeatureMediaBlockService.php +++ b/Block/FeatureMediaBlockService.php @@ -26,7 +26,7 @@ class FeatureMediaBlockService extends MediaBlockService */ public function configureSettings(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'media' => false, 'orientation' => 'left', 'title' => false, @@ -35,7 +35,7 @@ public function configureSettings(OptionsResolver $resolver) 'mediaId' => null, 'format' => false, 'template' => 'SonataMediaBundle:Block:block_feature_media.html.twig', - )); + ]); } /** @@ -45,33 +45,33 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) { $formatChoices = $this->getFormatChoices($block->getSetting('mediaId')); - $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( - 'keys' => array( - array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', [ + 'keys' => [ + ['title', 'Symfony\Component\Form\Extension\Core\Type\TextType', [ 'required' => false, 'label' => 'form.label_title', - )), - array('content', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', array( + ]], + ['content', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', [ 'required' => false, 'label' => 'form.label_content', - )), - array('orientation', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ]], + ['orientation', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'required' => false, - 'choices' => array( + 'choices' => [ 'left' => 'form.label_orientation_left', 'right' => 'form.label_orientation_right', - ), + ], 'label' => 'form.label_orientation', - )), - array($this->getMediaBuilder($formMapper), null, array()), - array('format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ]], + [$this->getMediaBuilder($formMapper), null, []], + ['format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'required' => count($formatChoices) > 0, 'choices' => $formatChoices, 'label' => 'form.label_format', - )), - ), + ]], + ], 'translation_domain' => 'SonataMediaBundle', - )); + ]); } /** @@ -79,9 +79,9 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) */ public function getStylesheets($media) { - return array( + return [ '/bundles/sonatamedia/blocks/feature_media/theme.css', - ); + ]; } /** @@ -89,8 +89,8 @@ public function getStylesheets($media) */ public function getBlockMetadata($code = null) { - return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', array( + return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', [ 'class' => 'fa fa-picture-o', - )); + ]); } } diff --git a/Block/GalleryBlockService.php b/Block/GalleryBlockService.php index 1a9e1aebde..8a71611229 100644 --- a/Block/GalleryBlockService.php +++ b/Block/GalleryBlockService.php @@ -81,7 +81,7 @@ public function getGalleryAdmin() */ public function configureSettings(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'gallery' => false, 'title' => false, 'context' => false, @@ -90,7 +90,7 @@ public function configureSettings(OptionsResolver $resolver) 'startPaused' => false, 'template' => 'SonataMediaBundle:Block:block_gallery.html.twig', 'galleryId' => null, - )); + ]); } /** @@ -98,7 +98,7 @@ public function configureSettings(OptionsResolver $resolver) */ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) { - $contextChoices = array(); + $contextChoices = []; foreach ($this->getMediaPool()->getContexts() as $name => $context) { $contextChoices[$name] = $name; @@ -106,7 +106,7 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) $gallery = $block->getSetting('galleryId'); - $formatChoices = array(); + $formatChoices = []; if ($gallery instanceof GalleryInterface) { $formats = $this->getMediaPool()->getFormatNamesByContext($gallery->getContext()); @@ -117,48 +117,48 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) } // simulate an association ... - $fieldDescription = $this->getGalleryAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->getGalleryAdmin()->getClass(), 'media', array( + $fieldDescription = $this->getGalleryAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->getGalleryAdmin()->getClass(), 'media', [ 'translation_domain' => 'SonataMediaBundle', - )); + ]); $fieldDescription->setAssociationAdmin($this->getGalleryAdmin()); $fieldDescription->setAdmin($formMapper->getAdmin()); $fieldDescription->setOption('edit', 'list'); - $fieldDescription->setAssociationMapping(array('fieldName' => 'gallery', 'type' => ClassMetadataInfo::MANY_TO_ONE)); + $fieldDescription->setAssociationMapping(['fieldName' => 'gallery', 'type' => ClassMetadataInfo::MANY_TO_ONE]); - $builder = $formMapper->create('galleryId', 'Sonata\AdminBundle\Form\Type\ModelListType', array( + $builder = $formMapper->create('galleryId', 'Sonata\AdminBundle\Form\Type\ModelListType', [ 'sonata_field_description' => $fieldDescription, 'class' => $this->getGalleryAdmin()->getClass(), 'model_manager' => $this->getGalleryAdmin()->getModelManager(), 'label' => 'form.label_gallery', - )); + ]); - $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( - 'keys' => array( - array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', [ + 'keys' => [ + ['title', 'Symfony\Component\Form\Extension\Core\Type\TextType', [ 'required' => false, 'label' => 'form.label_title', - )), - array('context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ]], + ['context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'required' => true, 'choices' => $contextChoices, 'label' => 'form.label_context', - )), - array('format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ]], + ['format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'required' => count($formatChoices) > 0, 'choices' => $formatChoices, 'label' => 'form.label_format', - )), - array($builder, null, array()), - array('pauseTime', 'Symfony\Component\Form\Extension\Core\Type\NumberType', array( + ]], + [$builder, null, []], + ['pauseTime', 'Symfony\Component\Form\Extension\Core\Type\NumberType', [ 'label' => 'form.label_pause_time', - )), - array('startPaused', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', array( + ]], + ['startPaused', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', [ 'required' => false, 'label' => 'form.label_start_paused', - )), - ), + ]], + ], 'translation_domain' => 'SonataMediaBundle', - )); + ]); } /** @@ -168,12 +168,12 @@ public function execute(BlockContextInterface $blockContext, Response $response { $gallery = $blockContext->getBlock()->getSetting('galleryId'); - return $this->renderResponse($blockContext->getTemplate(), array( + return $this->renderResponse($blockContext->getTemplate(), [ 'gallery' => $gallery, 'block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), - 'elements' => $gallery ? $this->buildElements($gallery) : array(), - ), $response); + 'elements' => $gallery ? $this->buildElements($gallery) : [], + ], $response); } /** @@ -184,7 +184,7 @@ public function load(BlockInterface $block) $gallery = $block->getSetting('galleryId'); if ($gallery) { - $gallery = $this->galleryManager->findOneBy(array('id' => $gallery)); + $gallery = $this->galleryManager->findOneBy(['id' => $gallery]); } $block->setSetting('galleryId', $gallery); @@ -211,9 +211,9 @@ public function preUpdate(BlockInterface $block) */ public function getBlockMetadata($code = null) { - return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', array( + return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', [ 'class' => 'fa fa-picture-o', - )); + ]); } /** @@ -223,7 +223,7 @@ public function getBlockMetadata($code = null) */ private function buildElements(GalleryInterface $gallery) { - $elements = array(); + $elements = []; foreach ($gallery->getGalleryItems() as $galleryItem) { if (!$galleryItem->getEnabled()) { continue; @@ -235,12 +235,12 @@ private function buildElements(GalleryInterface $gallery) continue; } - $elements[] = array( + $elements[] = [ 'title' => $galleryItem->getMedia()->getName(), 'caption' => $galleryItem->getMedia()->getDescription(), 'type' => $type, 'media' => $galleryItem->getMedia(), - ); + ]; } return $elements; diff --git a/Block/GalleryListBlockService.php b/Block/GalleryListBlockService.php index be6954245e..7e5dcca897 100755 --- a/Block/GalleryListBlockService.php +++ b/Block/GalleryListBlockService.php @@ -53,52 +53,52 @@ public function __construct($name, EngineInterface $templating, GalleryManagerIn */ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) { - $contextChoices = array(); + $contextChoices = []; foreach ($this->pool->getContexts() as $name => $context) { $contextChoices[$name] = $name; } - $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( - 'keys' => array( - array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', [ + 'keys' => [ + ['title', 'Symfony\Component\Form\Extension\Core\Type\TextType', [ 'label' => 'form.label_title', 'required' => false, - )), - array('number', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', array( + ]], + ['number', 'Symfony\Component\Form\Extension\Core\Type\IntegerType', [ 'label' => 'form.label_number', 'required' => true, - )), - array('context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ]], + ['context', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'required' => true, 'label' => 'form.label_context', 'choices' => $contextChoices, - )), - array('mode', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ]], + ['mode', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'label' => 'form.label_mode', - 'choices' => array( + 'choices' => [ 'public' => 'form.label_mode_public', 'admin' => 'form.label_mode_admin', - ), - )), - array('order', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ], + ]], + ['order', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'label' => 'form.label_order', - 'choices' => array( + 'choices' => [ 'name' => 'form.label_order_name', 'createdAt' => 'form.label_order_created_at', 'updatedAt' => 'form.label_order_updated_at', - ), - )), - array('sort', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ], + ]], + ['sort', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'label' => 'form.label_sort', - 'choices' => array( + 'choices' => [ 'desc' => 'form.label_sort_desc', 'asc' => 'form.label_sort_asc', - ), - )), - ), + ], + ]], + ], 'translation_domain' => 'SonataMediaBundle', - )); + ]); } /** @@ -108,16 +108,16 @@ public function execute(BlockContextInterface $blockContext, Response $response { $context = $blockContext->getBlock()->getSetting('context'); - $criteria = array( + $criteria = [ 'mode' => $blockContext->getSetting('mode'), 'context' => $context, - ); + ]; - $order = array( + $order = [ $blockContext->getSetting('order') => $blockContext->getSetting('sort'), - ); + ]; - return $this->renderResponse($blockContext->getTemplate(), array( + return $this->renderResponse($blockContext->getTemplate(), [ 'context' => $blockContext, 'settings' => $blockContext->getSettings(), 'block' => $blockContext->getBlock(), @@ -127,7 +127,7 @@ public function execute(BlockContextInterface $blockContext, Response $response $blockContext->getSetting('number'), $order ), - ), $response); + ], $response); } /** @@ -135,7 +135,7 @@ public function execute(BlockContextInterface $blockContext, Response $response */ public function configureSettings(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'number' => 15, 'mode' => 'public', 'order' => 'createdAt', @@ -143,7 +143,7 @@ public function configureSettings(OptionsResolver $resolver) 'context' => false, 'title' => 'Gallery List', 'template' => 'SonataMediaBundle:Block:block_gallery_list.html.twig', - )); + ]); } /** @@ -151,8 +151,8 @@ public function configureSettings(OptionsResolver $resolver) */ public function getBlockMetadata($code = null) { - return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', array( + return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', [ 'class' => 'fa fa-picture-o', - )); + ]); } } diff --git a/Block/MediaBlockService.php b/Block/MediaBlockService.php index 3fd3738496..74786163e0 100644 --- a/Block/MediaBlockService.php +++ b/Block/MediaBlockService.php @@ -81,14 +81,14 @@ public function getMediaAdmin() */ public function configureSettings(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'media' => false, 'title' => false, 'context' => false, 'mediaId' => null, 'format' => false, 'template' => 'SonataMediaBundle:Block:block_media.html.twig', - )); + ]); } /** @@ -102,21 +102,21 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block) $formatChoices = $this->getFormatChoices($block->getSetting('mediaId')); - $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', array( - 'keys' => array( - array('title', 'Symfony\Component\Form\Extension\Core\Type\TextType', array( + $formMapper->add('settings', 'Sonata\CoreBundle\Form\Type\ImmutableArrayType', [ + 'keys' => [ + ['title', 'Symfony\Component\Form\Extension\Core\Type\TextType', [ 'required' => false, 'label' => 'form.label_title', - )), - array($this->getMediaBuilder($formMapper), null, array()), - array('format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', array( + ]], + [$this->getMediaBuilder($formMapper), null, []], + ['format', 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', [ 'required' => count($formatChoices) > 0, 'choices' => $formatChoices, 'label' => 'form.label_format', - )), - ), + ]], + ], 'translation_domain' => 'SonataMediaBundle', - )); + ]); } /** @@ -134,11 +134,11 @@ public function execute(BlockContextInterface $blockContext, Response $response } } - return $this->renderResponse($blockContext->getTemplate(), array( + return $this->renderResponse($blockContext->getTemplate(), [ 'media' => $blockContext->getSetting('mediaId'), 'block' => $blockContext->getBlock(), 'settings' => $blockContext->getSettings(), - ), $response); + ], $response); } /** @@ -149,7 +149,7 @@ public function load(BlockInterface $block) $media = $block->getSetting('mediaId', null); if (is_int($media)) { - $media = $this->mediaManager->findOneBy(array('id' => $media)); + $media = $this->mediaManager->findOneBy(['id' => $media]); } $block->setSetting('mediaId', $media); @@ -176,9 +176,9 @@ public function preUpdate(BlockInterface $block) */ public function getBlockMetadata($code = null) { - return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', array( + return new Metadata($this->getName(), (!is_null($code) ? $code : $this->getName()), false, 'SonataMediaBundle', [ 'class' => 'fa fa-picture-o', - )); + ]); } /** @@ -188,7 +188,7 @@ public function getBlockMetadata($code = null) */ protected function getFormatChoices(MediaInterface $media = null) { - $formatChoices = array(); + $formatChoices = []; if (!$media instanceof MediaInterface) { return $formatChoices; @@ -211,22 +211,22 @@ protected function getFormatChoices(MediaInterface $media = null) protected function getMediaBuilder(FormMapper $formMapper) { // simulate an association ... - $fieldDescription = $this->getMediaAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->mediaAdmin->getClass(), 'media', array( + $fieldDescription = $this->getMediaAdmin()->getModelManager()->getNewFieldDescriptionInstance($this->mediaAdmin->getClass(), 'media', [ 'translation_domain' => 'SonataMediaBundle', - )); + ]); $fieldDescription->setAssociationAdmin($this->getMediaAdmin()); $fieldDescription->setAdmin($formMapper->getAdmin()); $fieldDescription->setOption('edit', 'list'); - $fieldDescription->setAssociationMapping(array( + $fieldDescription->setAssociationMapping([ 'fieldName' => 'media', 'type' => ClassMetadataInfo::MANY_TO_ONE, - )); + ]); - return $formMapper->create('mediaId', 'Sonata\AdminBundle\Form\Type\ModelListType', array( + return $formMapper->create('mediaId', 'Sonata\AdminBundle\Form\Type\ModelListType', [ 'sonata_field_description' => $fieldDescription, 'class' => $this->getMediaAdmin()->getClass(), 'model_manager' => $this->getMediaAdmin()->getModelManager(), 'label' => 'form.label_media', - )); + ]); } } diff --git a/CDN/CloudFront.php b/CDN/CloudFront.php index e498f2d703..e2c312fc4a 100644 --- a/CDN/CloudFront.php +++ b/CDN/CloudFront.php @@ -99,7 +99,7 @@ public function getPath($relativePath, $isFlushable = false) */ public function flushByString($string) { - return $this->flushPaths(array($string)); + return $this->flushPaths([$string]); } /** @@ -107,7 +107,7 @@ public function flushByString($string) */ public function flush($string) { - return $this->flushPaths(array($string)); + return $this->flushPaths([$string]); } /** @@ -127,16 +127,16 @@ public function flushPaths(array $paths) }, $paths); try { - $result = $this->getClient()->createInvalidation(array( + $result = $this->getClient()->createInvalidation([ 'DistributionId' => $this->distributionId, - 'Paths' => array( + 'Paths' => [ 'Quantity' => count($normalizedPaths), 'Items' => $normalizedPaths, - ), + ], 'CallerReference' => $this->getCallerReference($normalizedPaths), - )); + ]); - if (!in_array($status = $result->get('Status'), array('Completed', 'InProgress'))) { + if (!in_array($status = $result->get('Status'), ['Completed', 'InProgress'])) { throw new \RuntimeException('Unable to flush : '.$status); } @@ -162,10 +162,10 @@ public function setClient(CloudFrontClient $client) public function getFlushStatus($identifier) { try { - $result = $this->getClient()->getInvalidation(array( + $result = $this->getClient()->getInvalidation([ 'DistributionId' => $this->distributionId, 'Id' => $identifier, - )); + ]); return array_search($result->get('Status'), self::getStatusList()); } catch (CloudFrontException $ex) { @@ -181,13 +181,13 @@ public function getFlushStatus($identifier) public static function getStatusList() { // @todo: check for a complete list of available CloudFront statuses - return array( + return [ self::STATUS_OK => 'Completed', self::STATUS_TO_SEND => 'STATUS_TO_SEND', self::STATUS_TO_FLUSH => 'STATUS_TO_FLUSH', self::STATUS_ERROR => 'STATUS_ERROR', self::STATUS_WAITING => 'InProgress', - ); + ]; } /** @@ -212,10 +212,10 @@ protected function getCallerReference(array $paths) private function getClient() { if (!$this->client) { - $this->client = CloudFrontClient::factory(array( + $this->client = CloudFrontClient::factory([ 'key' => $this->key, 'secret' => $this->secret, - )); + ]); } return $this->client; diff --git a/CDN/PantherPortal.php b/CDN/PantherPortal.php index 9716e89a49..29d4f3e3bf 100644 --- a/CDN/PantherPortal.php +++ b/CDN/PantherPortal.php @@ -89,7 +89,7 @@ public function getPath($relativePath, $isFlushable) */ public function flushByString($string) { - $this->flushPaths(array($string)); + $this->flushPaths([$string]); } /** @@ -97,7 +97,7 @@ public function flushByString($string) */ public function flush($string) { - $this->flushPaths(array($string)); + $this->flushPaths([$string]); } /** diff --git a/Command/AddMassMediaCommand.php b/Command/AddMassMediaCommand.php index 8a67221186..4a4ef1acb3 100644 --- a/Command/AddMassMediaCommand.php +++ b/Command/AddMassMediaCommand.php @@ -29,12 +29,12 @@ public function configure() { $this->setName('sonata:media:add-multiple') ->setDescription('Add medias in mass into the database') - ->setDefinition(array( + ->setDefinition([ new InputOption('file', null, InputOption::VALUE_OPTIONAL, 'The file to parse'), new InputOption('delimiter', null, InputOption::VALUE_OPTIONAL, 'Set the field delimiter (one character only)', ','), new InputOption('enclosure', null, InputOption::VALUE_OPTIONAL, 'Set the field enclosure character (one character only).', '"'), new InputOption('escape', null, InputOption::VALUE_OPTIONAL, 'Set the escape character (one character only). Defaults as a backslash', '\\'), - )); + ]); } /** @@ -97,7 +97,7 @@ protected function insertMedia(array $data, OutputInterface $output) $media = $this->getMediaManager()->create(); foreach ($this->setters as $pos => $name) { - call_user_func(array($media, 'set'.$name), $data[$pos]); + call_user_func([$media, 'set'.$name], $data[$pos]); } try { diff --git a/Command/AddMediaCommand.php b/Command/AddMediaCommand.php index 7cc6c3bb80..3b84ca78ea 100644 --- a/Command/AddMediaCommand.php +++ b/Command/AddMediaCommand.php @@ -37,7 +37,7 @@ public function configure() { $this->setName('sonata:media:add') ->setDescription('Add a media into the database') - ->setDefinition(array( + ->setDefinition([ new InputArgument('providerName', InputArgument::REQUIRED, 'The provider'), new InputArgument('context', InputArgument::REQUIRED, 'The context'), new InputArgument('binaryContent', InputArgument::REQUIRED, 'The content'), @@ -46,7 +46,7 @@ public function configure() new InputOption('copyright', null, InputOption::VALUE_OPTIONAL, 'The media copyright field', null), new InputOption('author', null, InputOption::VALUE_OPTIONAL, 'The media author name field', null), new InputOption('enabled', null, InputOption::VALUE_OPTIONAL, 'The media enabled field', true), - )); + ]); } /** @@ -75,7 +75,7 @@ public function execute(InputInterface $input, OutputInterface $output) $media->setAuthorName($input->getOption('author')); } - if (in_array($input->getOption('enabled'), array(1, true, 'true'), true)) { + if (in_array($input->getOption('enabled'), [1, true, 'true'], true)) { $media->setEnabled(true); } else { $media->setEnabled(false); diff --git a/Command/CleanMediaCommand.php b/Command/CleanMediaCommand.php index f08a5133b8..6c8e711206 100755 --- a/Command/CleanMediaCommand.php +++ b/Command/CleanMediaCommand.php @@ -94,7 +94,7 @@ protected function execute(InputInterface $input, OutputInterface $output) private function getProviders() { if (!$this->providers) { - $this->providers = array(); + $this->providers = []; $pool = $this->getContainer()->get('sonata.media.pool'); @@ -121,15 +121,15 @@ private function mediaExists($filename, $context = null) $fileParts = explode('_', $filename); if (count($fileParts) > 1 && $fileParts[0] == 'thumb') { - return $mediaManager->findOneBy(array( + return $mediaManager->findOneBy([ 'id' => $fileParts[1], 'context' => $context, - )) != null; + ]) != null; } - return count($mediaManager->findBy(array( + return count($mediaManager->findBy([ 'providerReference' => $filename, 'providerName' => $this->getProviders(), - ))) > 0; + ])) > 0; } } diff --git a/Command/FixMediaContextCommand.php b/Command/FixMediaContextCommand.php index 4512b3b657..c45f910bb5 100755 --- a/Command/FixMediaContextCommand.php +++ b/Command/FixMediaContextCommand.php @@ -42,9 +42,9 @@ public function execute(InputInterface $input, OutputInterface $output) foreach ($pool->getContexts() as $context => $contextAttrs) { /** @var ContextInterface $defaultContext */ - $defaultContext = $contextManager->findOneBy(array( + $defaultContext = $contextManager->findOneBy([ 'id' => $context, - )); + ]); if (!$defaultContext) { $output->writeln(sprintf(" > default context for '%s' is missing, creating one", $context)); diff --git a/Command/MigrateToJsonTypeCommand.php b/Command/MigrateToJsonTypeCommand.php index 1813d7df14..7fc587bcfa 100644 --- a/Command/MigrateToJsonTypeCommand.php +++ b/Command/MigrateToJsonTypeCommand.php @@ -45,7 +45,7 @@ public function execute(InputInterface $input, OutputInterface $output) // if the row need to migrate if (0 !== strpos($media[$column], '{') && $media[$column] !== '[]') { $media[$column] = json_encode(unserialize($media[$column])); - $connection->update($table, array($column => $media[$column]), array($columnId => $media[$columnId])); + $connection->update($table, [$column => $media[$column]], [$columnId => $media[$columnId]]); ++$count; } } diff --git a/Command/RefreshMetadataCommand.php b/Command/RefreshMetadataCommand.php index cf4301d470..8c9939c8aa 100644 --- a/Command/RefreshMetadataCommand.php +++ b/Command/RefreshMetadataCommand.php @@ -39,10 +39,10 @@ public function configure() { $this->setName('sonata:media:refresh-metadata') ->setDescription('Refresh meta information') - ->setDefinition(array( + ->setDefinition([ new InputArgument('providerName', InputArgument::OPTIONAL, 'The provider'), new InputArgument('context', InputArgument::OPTIONAL, 'The context'), - ) + ] ); } @@ -68,10 +68,10 @@ public function execute(InputInterface $input, OutputInterface $output) $this->quiet = $input->getOption('quiet'); $this->output = $output; - $medias = $this->getMediaManager()->findBy(array( + $medias = $this->getMediaManager()->findBy([ 'providerName' => $provider, 'context' => $context, - )); + ]); $this->log(sprintf('Loaded %s medias for generating thumbs (provider: %s, context: %s)', count($medias), $provider, $context)); diff --git a/Command/RemoveThumbsCommand.php b/Command/RemoveThumbsCommand.php index 0f57da8d4d..30227bff24 100644 --- a/Command/RemoveThumbsCommand.php +++ b/Command/RemoveThumbsCommand.php @@ -47,14 +47,14 @@ public function configure() { $this->setName('sonata:media:remove-thumbnails') ->setDescription('Remove uploaded image thumbs') - ->setDefinition(array( + ->setDefinition([ new InputArgument('providerName', InputArgument::OPTIONAL, 'The provider'), new InputArgument('context', InputArgument::OPTIONAL, 'The context'), new InputArgument('format', InputArgument::OPTIONAL, 'The format (pass `all` to delete all thumbs)'), new InputOption('batchSize', null, InputOption::VALUE_REQUIRED, 'Media batch size (100 by default)', 100), new InputOption('batchesLimit', null, InputOption::VALUE_REQUIRED, 'Media batches limit (0 by default)', 0), new InputOption('startOffset', null, InputOption::VALUE_REQUIRED, 'Medias start offset (0 by default)', 0), - ) + ] ); } @@ -89,13 +89,13 @@ public function execute(InputInterface $input, OutputInterface $output) try { $batchOffset = $startOffset + ($batchCounter - 1) * $batchSize; $medias = $this->getMediaManager()->findBy( - array( + [ 'providerName' => $provider->getName(), 'context' => $context, - ), - array( + ], + [ 'id' => 'ASC', - ), + ], $batchSize, $batchOffset ); @@ -127,7 +127,7 @@ public function execute(InputInterface $input, OutputInterface $output) continue; } //clean filesystem registry for saving memory - $fsRegister->setValue($filesystem, array()); + $fsRegister->setValue($filesystem, []); } //clear entity manager for saving memory diff --git a/Command/SyncThumbsCommand.php b/Command/SyncThumbsCommand.php index bb958d2234..bc76e5e82c 100644 --- a/Command/SyncThumbsCommand.php +++ b/Command/SyncThumbsCommand.php @@ -42,13 +42,13 @@ public function configure() { $this->setName('sonata:media:sync-thumbnails') ->setDescription('Sync uploaded image thumbs with new media formats') - ->setDefinition(array( + ->setDefinition([ new InputArgument('providerName', InputArgument::OPTIONAL, 'The provider'), new InputArgument('context', InputArgument::OPTIONAL, 'The context'), new InputOption('batchSize', null, InputOption::VALUE_REQUIRED, 'Media batch size (100 by default)', 100), new InputOption('batchesLimit', null, InputOption::VALUE_REQUIRED, 'Media batches limit (0 by default)', 0), new InputOption('startOffset', null, InputOption::VALUE_REQUIRED, 'Medias start offset (0 by default)', 0), - ) + ] ); } @@ -92,13 +92,13 @@ public function execute(InputInterface $input, OutputInterface $output) try { $batchOffset = $startOffset + ($batchCounter - 1) * $batchSize; $medias = $this->getMediaManager()->findBy( - array( + [ 'providerName' => $providerName, 'context' => $context, - ), - array( + ], + [ 'id' => 'ASC', - ), + ], $batchSize, $batchOffset ); @@ -130,7 +130,7 @@ public function execute(InputInterface $input, OutputInterface $output) continue; } //clean filesystem registry for saving memory - $fsRegister->setValue($filesystem, array()); + $fsRegister->setValue($filesystem, []); } //clear entity manager for saving memory diff --git a/Command/UpdateCdnStatusCommand.php b/Command/UpdateCdnStatusCommand.php index f5651daa06..d1ed608b1d 100644 --- a/Command/UpdateCdnStatusCommand.php +++ b/Command/UpdateCdnStatusCommand.php @@ -41,10 +41,10 @@ public function configure() { $this->setName('sonata:media:update-cdn-status') ->setDescription('Refresh CDN status for medias that are in status flushing') - ->setDefinition(array( + ->setDefinition([ new InputArgument('providerName', InputArgument::OPTIONAL, 'The provider'), new InputArgument('context', InputArgument::OPTIONAL, 'The context'), - ) + ] ); } @@ -70,11 +70,11 @@ public function execute(InputInterface $input, OutputInterface $output) $this->quiet = $input->getOption('quiet'); $this->output = $output; - $medias = $this->getMediaManager()->findBy(array( + $medias = $this->getMediaManager()->findBy([ 'providerName' => $provider, 'context' => $context, 'cdnIsFlushable' => true, - )); + ]); $this->log(sprintf('Loaded %s medias for updating CDN status (provider: %s, context: %s)', count($medias), $provider, $context)); diff --git a/Consumer/CreateThumbnailConsumer.php b/Consumer/CreateThumbnailConsumer.php index 6445c7c291..098dab03c2 100644 --- a/Consumer/CreateThumbnailConsumer.php +++ b/Consumer/CreateThumbnailConsumer.php @@ -53,9 +53,9 @@ public function __construct(ManagerInterface $mediaManager, Pool $pool, Containe */ public function process(ConsumerEvent $event) { - $media = $this->mediaManager->findOneBy(array( + $media = $this->mediaManager->findOneBy([ 'id' => $event->getMessage()->getValue('mediaId'), - )); + ]); if (!$media) { throw new HandlingException(sprintf('Media not found - id: %s', $event->getMessage()->getValue('mediaId'))); diff --git a/Controller/Api/GalleryController.php b/Controller/Api/GalleryController.php index bcfa07de1a..6725ed230a 100644 --- a/Controller/Api/GalleryController.php +++ b/Controller/Api/GalleryController.php @@ -120,9 +120,9 @@ public function getGalleriesAction(ParamFetcherInterface $paramFetcher) $paramFetcher->addParam($orderByQueryParam); - $supportedCriteria = array( + $supportedCriteria = [ 'enabled' => '', - ); + ]; $page = $paramFetcher->get('page'); $limit = $paramFetcher->get('count'); @@ -136,9 +136,9 @@ public function getGalleriesAction(ParamFetcherInterface $paramFetcher) } if (!$sort) { - $sort = array(); + $sort = []; } elseif (!is_array($sort)) { - $sort = array($sort => 'asc'); + $sort = [$sort => 'asc']; } return $this->getGalleryManager()->getPager($criteria, $page, $limit, $sort); @@ -193,7 +193,7 @@ public function getGalleryMediasAction($id) { $galleryItems = $this->getGallery($id)->getGalleryItems(); - $media = array(); + $media = []; foreach ($galleryItems as $galleryItem) { $media[] = $galleryItem->getMedia(); } @@ -308,9 +308,9 @@ public function postGalleryMediaGalleryItemAction($galleryId, $mediaId, Request foreach ($gallery->getGalleryItems() as $galleryItem) { if ($galleryItem->getMedia()->getId() == $media->getId()) { - return FOSRestView::create(array( + return FOSRestView::create([ 'error' => sprintf('Gallery "%s" already has media "%s"', $galleryId, $mediaId), - ), 400); + ], 400); } } @@ -387,13 +387,13 @@ public function deleteGalleryMediaGalleryItemAction($galleryId, $mediaId) $gallery->getGalleryItems()->remove($key); $this->getGalleryManager()->save($gallery); - return array('deleted' => true); + return ['deleted' => true]; } } - return FOSRestView::create(array( + return FOSRestView::create([ 'error' => sprintf('Gallery "%s" does not have media "%s" associated', $galleryId, $mediaId), - ), 400); + ], 400); } /** @@ -422,7 +422,7 @@ public function deleteGalleryAction($id) $this->galleryManager->delete($gallery); - return array('deleted' => true); + return ['deleted' => true]; } /** @@ -437,9 +437,9 @@ public function deleteGalleryAction($id) */ protected function handleWriteGalleryItem(GalleryInterface $gallery, MediaInterface $media, GalleryItemInterface $galleryItem = null, Request $request) { - $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery_item', $galleryItem, array( + $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery_item', $galleryItem, [ 'csrf_protection' => false, - )); + ]); $form->handleRequest($request); @@ -455,12 +455,12 @@ protected function handleWriteGalleryItem(GalleryInterface $gallery, MediaInterf // BC for FOSRestBundle < 2.0 if (method_exists($view, 'setSerializationContext')) { $serializationContext = SerializationContext::create(); - $serializationContext->setGroups(array('sonata_api_read')); + $serializationContext->setGroups(['sonata_api_read']); $serializationContext->enableMaxDepthChecks(); $view->setSerializationContext($serializationContext); } else { $context = new Context(); - $context->setGroups(array('sonata_api_read')); + $context->setGroups(['sonata_api_read']); $context->setMaxDepth(0); $view->setContext($context); } @@ -482,7 +482,7 @@ protected function handleWriteGalleryItem(GalleryInterface $gallery, MediaInterf */ protected function getGallery($id) { - $gallery = $this->getGalleryManager()->findOneBy(array('id' => $id)); + $gallery = $this->getGalleryManager()->findOneBy(['id' => $id]); if (null === $gallery) { throw new NotFoundHttpException(sprintf('Gallery (%d) not found', $id)); @@ -502,7 +502,7 @@ protected function getGallery($id) */ protected function getMedia($id) { - $media = $this->getMediaManager()->findOneBy(array('id' => $id)); + $media = $this->getMediaManager()->findOneBy(['id' => $id]); if (null === $media) { throw new NotFoundHttpException(sprintf('Media (%d) not found', $id)); @@ -539,9 +539,9 @@ protected function handleWriteGallery($request, $id = null) { $gallery = $id ? $this->getGallery($id) : null; - $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery', $gallery, array( + $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_gallery', $gallery, [ 'csrf_protection' => false, - )); + ]); $form->handleRequest($request); @@ -554,12 +554,12 @@ protected function handleWriteGallery($request, $id = null) // BC for FOSRestBundle < 2.0 if (method_exists($view, 'setSerializationContext')) { $serializationContext = SerializationContext::create(); - $serializationContext->setGroups(array('sonata_api_read')); + $serializationContext->setGroups(['sonata_api_read']); $serializationContext->enableMaxDepthChecks(); $view->setSerializationContext($serializationContext); } else { $context = new Context(); - $context->setGroups(array('sonata_api_read')); + $context->setGroups(['sonata_api_read']); $context->setMaxDepth(0); $view->setContext($context); } diff --git a/Controller/Api/MediaController.php b/Controller/Api/MediaController.php index a55786d898..c4c646ec9b 100644 --- a/Controller/Api/MediaController.php +++ b/Controller/Api/MediaController.php @@ -102,9 +102,9 @@ public function getMediaAction(ParamFetcherInterface $paramFetcher) $paramFetcher->addParam($orderByQueryParam); - $supportedCriteria = array( + $supportedCriteria = [ 'enabled' => '', - ); + ]; $page = $paramFetcher->get('page'); $limit = $paramFetcher->get('count'); @@ -118,9 +118,9 @@ public function getMediaAction(ParamFetcherInterface $paramFetcher) } if (!$sort) { - $sort = array(); + $sort = []; } elseif (!is_array($sort)) { - $sort = array($sort => 'asc'); + $sort = [$sort => 'asc']; } return $this->mediaManager->getPager($criteria, $page, $limit, $sort); @@ -172,12 +172,12 @@ public function getMediumFormatsAction($id) { $media = $this->getMedium($id); - $formats = array(MediaProviderInterface::FORMAT_REFERENCE); + $formats = [MediaProviderInterface::FORMAT_REFERENCE]; $formats = array_merge($formats, array_keys($this->mediaPool->getFormatNamesByContext($media->getContext()))); $provider = $this->mediaPool->getProvider($media->getProviderName()); - $properties = array(); + $properties = []; foreach ($formats as $format) { $properties[$format]['url'] = $provider->generatePublicUrl($media, $format); $properties[$format]['properties'] = $provider->getHelperProperties($media, $format); @@ -245,7 +245,7 @@ public function deleteMediumAction($id) $this->mediaManager->delete($medium); - return array('deleted' => true); + return ['deleted' => true]; } /** @@ -373,7 +373,7 @@ public function putMediumBinaryContentAction($id, Request $request) */ protected function getMedium($id = null) { - $media = $this->mediaManager->findOneBy(array('id' => $id)); + $media = $this->mediaManager->findOneBy(['id' => $id]); if (null === $media) { throw new NotFoundHttpException(sprintf('Media (%d) was not found', $id)); @@ -393,10 +393,10 @@ protected function getMedium($id = null) */ protected function handleWriteMedium(Request $request, MediaInterface $media, MediaProviderInterface $provider) { - $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_media', $media, array( + $form = $this->formFactory->createNamed(null, 'sonata_media_api_form_media', $media, [ 'provider_name' => $provider->getName(), 'csrf_protection' => false, - )); + ]); $form->handleRequest($request); @@ -409,12 +409,12 @@ protected function handleWriteMedium(Request $request, MediaInterface $media, Me // BC for FOSRestBundle < 2.0 if (method_exists($view, 'setSerializationContext')) { $serializationContext = SerializationContext::create(); - $serializationContext->setGroups(array('sonata_api_read')); + $serializationContext->setGroups(['sonata_api_read']); $serializationContext->enableMaxDepthChecks(); $view->setSerializationContext($serializationContext); } else { $context = new Context(); - $context->setGroups(array('sonata_api_read')); + $context->setGroups(['sonata_api_read']); $context->setMaxDepth(0); $view->setContext($context); } diff --git a/Controller/GalleryAdminController.php b/Controller/GalleryAdminController.php index 7565be2fe8..4e8d53311e 100644 --- a/Controller/GalleryAdminController.php +++ b/Controller/GalleryAdminController.php @@ -25,7 +25,7 @@ class GalleryAdminController extends Controller * * @return Response */ - public function render($view, array $parameters = array(), Response $response = null) + public function render($view, array $parameters = [], Response $response = null) { $parameters['media_pool'] = $this->get('sonata.media.pool'); $parameters['persistent_parameters'] = $this->admin->getPersistentParameters(); @@ -56,12 +56,12 @@ public function listAction(Request $request = null) // set the theme for the current Admin Form $this->setFormTheme($formView, $this->admin->getFilterTheme()); - return $this->render($this->admin->getTemplate('list'), array( + return $this->render($this->admin->getTemplate('list'), [ 'action' => 'list', 'form' => $formView, 'datagrid' => $datagrid, 'csrf_token' => $this->getCsrfToken('sonata.batch'), - )); + ]); } /** diff --git a/Controller/GalleryController.php b/Controller/GalleryController.php index 4f051689ba..d03602d727 100644 --- a/Controller/GalleryController.php +++ b/Controller/GalleryController.php @@ -22,13 +22,13 @@ class GalleryController extends Controller */ public function indexAction() { - $galleries = $this->get('sonata.media.manager.gallery')->findBy(array( + $galleries = $this->get('sonata.media.manager.gallery')->findBy([ 'enabled' => true, - )); + ]); - return $this->render('SonataMediaBundle:Gallery:index.html.twig', array( + return $this->render('SonataMediaBundle:Gallery:index.html.twig', [ 'galleries' => $galleries, - )); + ]); } /** @@ -40,17 +40,17 @@ public function indexAction() */ public function viewAction($id) { - $gallery = $this->get('sonata.media.manager.gallery')->findOneBy(array( + $gallery = $this->get('sonata.media.manager.gallery')->findOneBy([ 'id' => $id, 'enabled' => true, - )); + ]); if (!$gallery) { throw new NotFoundHttpException('unable to find the gallery with the id'); } - return $this->render('SonataMediaBundle:Gallery:view.html.twig', array( + return $this->render('SonataMediaBundle:Gallery:view.html.twig', [ 'gallery' => $gallery, - )); + ]); } } diff --git a/Controller/MediaAdminController.php b/Controller/MediaAdminController.php index e4cc52b3a4..4e5b7609f4 100644 --- a/Controller/MediaAdminController.php +++ b/Controller/MediaAdminController.php @@ -28,12 +28,12 @@ public function createAction(Request $request = null) if (!$request->get('provider') && $request->isMethod('get')) { $pool = $this->get('sonata.media.pool'); - return $this->render('SonataMediaBundle:MediaAdmin:select_provider.html.twig', array( + return $this->render('SonataMediaBundle:MediaAdmin:select_provider.html.twig', [ 'providers' => $pool->getProvidersByContext( $request->get('context', $pool->getDefaultContext()) ), 'action' => 'create', - )); + ]); } return parent::createAction(); @@ -42,7 +42,7 @@ public function createAction(Request $request = null) /** * {@inheritdoc} */ - public function render($view, array $parameters = array(), Response $response = null) + public function render($view, array $parameters = [], Response $response = null) { $parameters['media_pool'] = $this->get('sonata.media.pool'); $parameters['persistent_parameters'] = $this->admin->getPersistentParameters(); @@ -83,10 +83,10 @@ public function listAction(Request $request = null) $datagrid->setValue('category', null, $rootCategory->getId()); } if ($this->has('sonata.media.manager.category') && $request->get('category')) { - $category = $this->get('sonata.media.manager.category')->findOneBy(array( + $category = $this->get('sonata.media.manager.category')->findOneBy([ 'id' => (int) $request->get('category'), 'context' => $context, - )); + ]); if (!empty($category)) { $datagrid->setValue('category', null, $category->getId()); @@ -99,13 +99,13 @@ public function listAction(Request $request = null) $this->setFormTheme($formView, $this->admin->getFilterTheme()); - return $this->render($this->admin->getTemplate('list'), array( + return $this->render($this->admin->getTemplate('list'), [ 'action' => 'list', 'form' => $formView, 'datagrid' => $datagrid, 'root_category' => $rootCategory, 'csrf_token' => $this->getCsrfToken('sonata.batch'), - )); + ]); } /** diff --git a/Controller/MediaController.php b/Controller/MediaController.php index 467f2e09fc..3d8b42a141 100644 --- a/Controller/MediaController.php +++ b/Controller/MediaController.php @@ -93,11 +93,11 @@ public function viewAction(Request $request, $id, $format = MediaProviderInterfa throw new AccessDeniedException(); } - return $this->render('SonataMediaBundle:Media:view.html.twig', array( + return $this->render('SonataMediaBundle:Media:view.html.twig', [ 'media' => $media, 'formats' => $this->get('sonata.media.pool')->getFormatNamesByContext($media->getContext()), 'format' => $format, - )); + ]); } /** diff --git a/DependencyInjection/Compiler/AddProviderCompilerPass.php b/DependencyInjection/Compiler/AddProviderCompilerPass.php index 2fe3014bae..bf6015ef51 100644 --- a/DependencyInjection/Compiler/AddProviderCompilerPass.php +++ b/DependencyInjection/Compiler/AddProviderCompilerPass.php @@ -40,7 +40,7 @@ public function process(ContainerBuilder $container) foreach ($container->findTaggedServiceIds('sonata.media.provider') as $id => $attributes) { $container->getDefinition($id)->addMethodCall( 'addFormat', - array(MediaProviderInterface::FORMAT_ADMIN, $format) + [MediaProviderInterface::FORMAT_ADMIN, $format] ); } } @@ -69,7 +69,7 @@ public function attachProviders(ContainerBuilder $container) { $pool = $container->getDefinition('sonata.media.pool'); foreach ($container->findTaggedServiceIds('sonata.media.provider') as $id => $attributes) { - $pool->addMethodCall('addProvider', array($id, new Reference($id))); + $pool->addMethodCall('addProvider', [$id, new Reference($id)]); } } @@ -92,7 +92,7 @@ public function attachArguments(ContainerBuilder $container, array $settings) ; if ($config['resizer']) { - $definition->addMethodCall('setResizer', array(new Reference($config['resizer']))); + $definition->addMethodCall('setResizer', [new Reference($config['resizer'])]); } } } @@ -119,7 +119,7 @@ public function applyFormats(ContainerBuilder $container, array $settings) $config['constraint'] = isset($config['constraint']) ? $config['constraint'] : true; $formatName = sprintf('%s_%s', $name, $format); - $definition->addMethodCall('addFormat', array($formatName, $config)); + $definition->addMethodCall('addFormat', [$formatName, $config]); } } } diff --git a/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php b/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php index 1ce56ec470..8668a16799 100644 --- a/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php +++ b/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php @@ -27,6 +27,6 @@ class GlobalVariablesCompilerPass implements CompilerPassInterface */ public function process(ContainerBuilder $container) { - $container->getDefinition('twig')->addMethodCall('addGlobal', array('sonata_media', new Reference('sonata.media.twig.global'))); + $container->getDefinition('twig')->addMethodCall('addGlobal', ['sonata_media', new Reference('sonata.media.twig.global')]); } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0823ba38e8..32db7c2692 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -88,7 +88,7 @@ private function addContextsSection(ArrayNodeDefinition $node) ->end() ->arrayNode('providers') ->prototype('scalar') - ->defaultValue(array()) + ->defaultValue([]) ->end() ->end() ->arrayNode('formats') @@ -202,7 +202,7 @@ private function addFilesystemSection(ArrayNodeDefinition $node) ->scalarNode('storage') ->defaultValue('standard') ->validate() - ->ifNotInArray(array('standard', 'reduced')) + ->ifNotInArray(['standard', 'reduced']) ->thenInvalid('Invalid storage type - "%s"') ->end() ->end() @@ -210,21 +210,21 @@ private function addFilesystemSection(ArrayNodeDefinition $node) ->scalarNode('acl') ->defaultValue('public') ->validate() - ->ifNotInArray(array('private', 'public', 'open', 'auth_read', 'owner_read', 'owner_full_control')) + ->ifNotInArray(['private', 'public', 'open', 'auth_read', 'owner_read', 'owner_full_control']) ->thenInvalid('Invalid acl permission - "%s"') ->end() ->end() ->scalarNode('encryption') ->defaultValue('') ->validate() - ->ifNotInArray(array('aes256')) + ->ifNotInArray(['aes256']) ->thenInvalid('Invalid encryption type - "%s"') ->end() ->end() ->scalarNode('region')->defaultValue('s3.amazonaws.com')->end() ->scalarNode('version')->defaultValue('latest')->end() ->enumNode('sdk_version') - ->values(array(2, 3)) + ->values([2, 3]) ->defaultValue(2) ->end() ->arrayNode('meta') @@ -307,24 +307,24 @@ private function addProvidersSection(ArrayNodeDefinition $node) ->scalarNode('thumbnail')->defaultValue('sonata.media.thumbnail.format')->end() ->arrayNode('allowed_extensions') ->prototype('scalar')->end() - ->defaultValue(array( + ->defaultValue([ 'pdf', 'txt', 'rtf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'odt', 'odg', 'odp', 'ods', 'odc', 'odf', 'odb', 'csv', 'xml', - )) + ]) ->end() ->arrayNode('allowed_mime_types') ->prototype('scalar')->end() - ->defaultValue(array( + ->defaultValue([ 'application/pdf', 'application/x-pdf', 'application/rtf', 'text/html', 'text/rtf', 'text/plain', 'application/excel', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.ms-powerpoint', 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.graphics', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.chart', 'application/vnd.oasis.opendocument.formula', 'application/vnd.oasis.opendocument.database', 'application/vnd.oasis.opendocument.image', 'text/comma-separated-values', 'text/xml', 'application/xml', 'application/zip', // seems to be used for xlsx document ... - )) + ]) ->end() ->end() ->end() @@ -341,16 +341,16 @@ private function addProvidersSection(ArrayNodeDefinition $node) ->scalarNode('adapter')->defaultValue('sonata.media.adapter.image.default')->end() ->arrayNode('allowed_extensions') ->prototype('scalar')->end() - ->defaultValue(array('jpg', 'png', 'jpeg')) + ->defaultValue(['jpg', 'png', 'jpeg']) ->end() ->arrayNode('allowed_mime_types') ->prototype('scalar')->end() - ->defaultValue(array( + ->defaultValue([ 'image/pjpeg', 'image/jpeg', 'image/png', 'image/x-png', - )) + ]) ->end() ->end() ->end() diff --git a/DependencyInjection/SonataMediaExtension.php b/DependencyInjection/SonataMediaExtension.php index a7c6b68da5..ef253a00a8 100644 --- a/DependencyInjection/SonataMediaExtension.php +++ b/DependencyInjection/SonataMediaExtension.php @@ -51,7 +51,7 @@ public function load(array $configs, ContainerBuilder $container) $loader->load('validators.xml'); $loader->load('serializer.xml'); - if (!in_array(strtolower($config['db_driver']), array('doctrine_orm', 'doctrine_mongodb', 'doctrine_phpcr'))) { + if (!in_array(strtolower($config['db_driver']), ['doctrine_orm', 'doctrine_mongodb', 'doctrine_phpcr'])) { throw new \InvalidArgumentException(sprintf('SonataMediaBundle - Invalid db driver "%s".', $config['db_driver'])); } @@ -101,7 +101,7 @@ public function load(array $configs, ContainerBuilder $container) $sonataAdminConfig = $this->bundleConfigs['SonataAdminBundle']; - $sonataRoles = array(); + $sonataRoles = []; if (isset($sonataAdminConfig['security']['role_admin'])) { $sonataRoles[] = $sonataAdminConfig['security']['role_admin']; } else { @@ -124,17 +124,17 @@ public function load(array $configs, ContainerBuilder $container) $pool = $container->getDefinition('sonata.media.pool'); $pool->replaceArgument(0, $config['default_context']); - $strategies = array(); + $strategies = []; foreach ($config['contexts'] as $name => $settings) { - $formats = array(); + $formats = []; foreach ($settings['formats'] as $format => $value) { $formats[$name.'_'.$format] = $value; } $strategies[] = $settings['download']['strategy']; - $pool->addMethodCall('addContext', array($name, $settings['providers'], $formats, $settings['download'])); + $pool->addMethodCall('addContext', [$name, $settings['providers'], $formats, $settings['download']]); } $container->setParameter('sonata.media.admin_format', $config['admin_format']); @@ -142,7 +142,7 @@ public function load(array $configs, ContainerBuilder $container) $strategies = array_unique($strategies); foreach ($strategies as $strategyId) { - $pool->addMethodCall('addDownloadStrategy', array($strategyId, new Reference($strategyId))); + $pool->addMethodCall('addDownloadStrategy', [$strategyId, new Reference($strategyId)]); } if ('doctrine_orm' == $config['db_driver']) { @@ -190,16 +190,16 @@ public function configureBuzz(ContainerBuilder $container, array $config) $container->getDefinition('sonata.media.buzz.browser') ->replaceArgument(0, new Reference($config['buzz']['connector'])); - foreach (array( + foreach ([ 'sonata.media.buzz.connector.curl', 'sonata.media.buzz.connector.file_get_contents', - ) as $connector) { + ] as $connector) { $container->getDefinition($connector) - ->addMethodCall('setIgnoreErrors', array($config['buzz']['client']['ignore_errors'])) - ->addMethodCall('setMaxRedirects', array($config['buzz']['client']['max_redirects'])) - ->addMethodCall('setTimeout', array($config['buzz']['client']['timeout'])) - ->addMethodCall('setVerifyPeer', array($config['buzz']['client']['verify_peer'])) - ->addMethodCall('setProxy', array($config['buzz']['client']['proxy'])); + ->addMethodCall('setIgnoreErrors', [$config['buzz']['client']['ignore_errors']]) + ->addMethodCall('setMaxRedirects', [$config['buzz']['client']['max_redirects']]) + ->addMethodCall('setTimeout', [$config['buzz']['client']['timeout']]) + ->addMethodCall('setVerifyPeer', [$config['buzz']['client']['verify_peer']]) + ->addMethodCall('setProxy', [$config['buzz']['client']['proxy']]); } } @@ -226,83 +226,83 @@ public function registerDoctrineMapping(array $config) { $collector = DoctrineCollector::getInstance(); - $collector->addAssociation($config['class']['media'], 'mapOneToMany', array( + $collector->addAssociation($config['class']['media'], 'mapOneToMany', [ 'fieldName' => 'galleryItems', 'targetEntity' => $config['class']['gallery_item'], - 'cascade' => array( + 'cascade' => [ 'persist', - ), + ], 'mappedBy' => 'media', 'orphanRemoval' => false, - )); + ]); - $collector->addAssociation($config['class']['gallery_item'], 'mapManyToOne', array( + $collector->addAssociation($config['class']['gallery_item'], 'mapManyToOne', [ 'fieldName' => 'gallery', 'targetEntity' => $config['class']['gallery'], - 'cascade' => array( + 'cascade' => [ 'persist', - ), + ], 'mappedBy' => null, 'inversedBy' => 'galleryItems', - 'joinColumns' => array( - array( + 'joinColumns' => [ + [ 'name' => 'gallery_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE', - ), - ), + ], + ], 'orphanRemoval' => false, - )); + ]); - $collector->addAssociation($config['class']['gallery_item'], 'mapManyToOne', array( + $collector->addAssociation($config['class']['gallery_item'], 'mapManyToOne', [ 'fieldName' => 'media', 'targetEntity' => $config['class']['media'], - 'cascade' => array( + 'cascade' => [ 'persist', - ), + ], 'mappedBy' => null, 'inversedBy' => 'galleryItems', - 'joinColumns' => array( - array( + 'joinColumns' => [ + [ 'name' => 'media_id', 'referencedColumnName' => 'id', 'onDelete' => 'CASCADE', - ), - ), + ], + ], 'orphanRemoval' => false, - )); + ]); - $collector->addAssociation($config['class']['gallery'], 'mapOneToMany', array( + $collector->addAssociation($config['class']['gallery'], 'mapOneToMany', [ 'fieldName' => 'galleryItems', 'targetEntity' => $config['class']['gallery_item'], - 'cascade' => array( + 'cascade' => [ 'persist', - ), + ], 'mappedBy' => 'gallery', 'orphanRemoval' => true, - 'orderBy' => array( + 'orderBy' => [ 'position' => 'ASC', - ), - )); + ], + ]); if ($this->isClassificationEnabled($config)) { - $collector->addAssociation($config['class']['media'], 'mapManyToOne', array( + $collector->addAssociation($config['class']['media'], 'mapManyToOne', [ 'fieldName' => 'category', 'targetEntity' => $config['class']['category'], - 'cascade' => array( + 'cascade' => [ 'persist', - ), + ], 'mappedBy' => null, 'inversedBy' => null, - 'joinColumns' => array( - array( + 'joinColumns' => [ + [ 'name' => 'category_id', 'referencedColumnName' => 'id', 'onDelete' => 'SET NULL', - ), - ), + ], + ], 'orphanRemoval' => false, - )); + ]); } } @@ -378,14 +378,14 @@ public function configureFilesystemAdapter(ContainerBuilder $container, array $c $container->getDefinition('sonata.media.adapter.filesystem.ftp') ->addArgument($config['filesystem']['ftp']['directory']) ->addArgument($config['filesystem']['ftp']['host']) - ->addArgument(array( + ->addArgument([ 'port' => $config['filesystem']['ftp']['port'], 'username' => $config['filesystem']['ftp']['username'], 'password' => $config['filesystem']['ftp']['password'], 'passive' => $config['filesystem']['ftp']['passive'], 'create' => $config['filesystem']['ftp']['create'], 'mode' => $config['filesystem']['ftp']['mode'], - )) + ]) ; } else { $container->removeDefinition('sonata.media.adapter.filesystem.ftp'); @@ -397,36 +397,36 @@ public function configureFilesystemAdapter(ContainerBuilder $container, array $c $container->getDefinition('sonata.media.adapter.filesystem.s3') ->replaceArgument(0, new Reference('sonata.media.adapter.service.s3')) ->replaceArgument(1, $config['filesystem']['s3']['bucket']) - ->replaceArgument(2, array('create' => $config['filesystem']['s3']['create'], 'region' => $config['filesystem']['s3']['region'], 'directory' => $config['filesystem']['s3']['directory'], 'ACL' => $config['filesystem']['s3']['acl'])) + ->replaceArgument(2, ['create' => $config['filesystem']['s3']['create'], 'region' => $config['filesystem']['s3']['region'], 'directory' => $config['filesystem']['s3']['directory'], 'ACL' => $config['filesystem']['s3']['acl']]) ; $container->getDefinition('sonata.media.metadata.amazon') - ->addArgument(array( + ->addArgument([ 'acl' => $config['filesystem']['s3']['acl'], 'storage' => $config['filesystem']['s3']['storage'], 'encryption' => $config['filesystem']['s3']['encryption'], 'meta' => $config['filesystem']['s3']['meta'], 'cache_control' => $config['filesystem']['s3']['cache_control'], - )) + ]) ; if (3 === $config['filesystem']['s3']['sdk_version']) { $container->getDefinition('sonata.media.adapter.service.s3') - ->replaceArgument(0, array( - 'credentials' => array( + ->replaceArgument(0, [ + 'credentials' => [ 'secret' => $config['filesystem']['s3']['secretKey'], 'key' => $config['filesystem']['s3']['accessKey'], - ), + ], 'region' => $config['filesystem']['s3']['region'], 'version' => $config['filesystem']['s3']['version'], - )) + ]) ; } else { $container->getDefinition('sonata.media.adapter.service.s3') - ->replaceArgument(0, array( + ->replaceArgument(0, [ 'secret' => $config['filesystem']['s3']['secretKey'], 'key' => $config['filesystem']['s3']['accessKey'], - )) + ]) ; } } else { @@ -505,7 +505,7 @@ public function configureClassesToCompile() return; } - $this->addClassesToCompile(array( + $this->addClassesToCompile([ 'Sonata\\MediaBundle\\CDN\\CDNInterface', 'Sonata\\MediaBundle\\CDN\\CloudFront', 'Sonata\\MediaBundle\\CDN\\Fallback', @@ -553,7 +553,7 @@ public function configureClassesToCompile() 'Sonata\\MediaBundle\\Thumbnail\\FormatThumbnail', 'Sonata\\MediaBundle\\Thumbnail\\ThumbnailInterface', 'Sonata\\MediaBundle\\Twig\\Extension\\MediaExtension', - )); + ]); } /** @@ -590,7 +590,7 @@ private function isClassificationEnabled(array $config) */ private function configureAdapters(ContainerBuilder $container, array $config) { - foreach (array('gd', 'imagick', 'gmagick') as $adapter) { + foreach (['gd', 'imagick', 'gmagick'] as $adapter) { if ($container->hasParameter('sonata.media.adapter.image.'.$adapter.'.class')) { $container->register('sonata.media.adapter.image.'.$adapter, $container->getParameter('sonata.media.adapter.image.'.$adapter.'.class')); } @@ -606,21 +606,21 @@ private function configureResizers(ContainerBuilder $container, array $config) { if ($container->hasParameter('sonata.media.resizer.simple.class')) { $class = $container->getParameter('sonata.media.resizer.simple.class'); - $definition = new Definition($class, array( + $definition = new Definition($class, [ new Reference('sonata.media.adapter.image.default'), '%sonata.media.resizer.simple.adapter.mode%', new Reference('sonata.media.metadata.proxy'), - )); + ]); $container->setDefinition('sonata.media.resizer.simple', $definition); } if ($container->hasParameter('sonata.media.resizer.square.class')) { $class = $container->getParameter('sonata.media.resizer.square.class'); - $definition = new Definition($class, array( + $definition = new Definition($class, [ new Reference('sonata.media.adapter.image.default'), '%sonata.media.resizer.square.adapter.mode%', new Reference('sonata.media.metadata.proxy'), - )); + ]); $container->setDefinition('sonata.media.resizer.square', $definition); } diff --git a/Document/GalleryManager.php b/Document/GalleryManager.php index f32cec2b6a..09d3234cac 100644 --- a/Document/GalleryManager.php +++ b/Document/GalleryManager.php @@ -34,7 +34,7 @@ public function update(GalleryInterface $gallery) /** * {@inheritdoc} */ - public function getPager(array $criteria, $page, $limit = 10, array $sort = array()) + public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { throw new \RuntimeException('Not Implemented yet'); } diff --git a/Document/MediaManager.php b/Document/MediaManager.php index 3dc3363d18..b8e96d83ae 100644 --- a/Document/MediaManager.php +++ b/Document/MediaManager.php @@ -41,7 +41,7 @@ public function save($entity, $andFlush = true) /** * {@inheritdoc} */ - public function getPager(array $criteria, $page, $limit = 10, array $sort = array()) + public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { throw new \RuntimeException('Not Implemented yet'); } diff --git a/Entity/GalleryManager.php b/Entity/GalleryManager.php index d98072ec33..393e4a92e8 100644 --- a/Entity/GalleryManager.php +++ b/Entity/GalleryManager.php @@ -36,7 +36,7 @@ public function update(GalleryInterface $gallery) /** * {@inheritdoc} */ - public function getPager(array $criteria, $page, $limit = 10, array $sort = array()) + public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { $query = $this->getRepository() ->createQueryBuilder('g') @@ -49,13 +49,13 @@ public function getPager(array $criteria, $page, $limit = 10, array $sort = arra } } if (count($sort) == 0) { - $sort = array('name' => 'ASC'); + $sort = ['name' => 'ASC']; } foreach ($sort as $field => $direction) { $query->orderBy(sprintf('g.%s', $field), strtoupper($direction)); } - $parameters = array(); + $parameters = []; if (isset($criteria['enabled'])) { $query->andWhere('g.enabled = :enabled'); diff --git a/Entity/MediaManager.php b/Entity/MediaManager.php index 315945636f..f984fefee5 100644 --- a/Entity/MediaManager.php +++ b/Entity/MediaManager.php @@ -48,7 +48,7 @@ public function save($media, $andFlush = true) /** * {@inheritdoc} */ - public function getPager(array $criteria, $page, $limit = 10, array $sort = array()) + public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { $query = $this->getRepository() ->createQueryBuilder('m') @@ -65,7 +65,7 @@ public function getPager(array $criteria, $page, $limit = 10, array $sort = arra $query->orderBy(sprintf('m.%s', $field), strtoupper($direction)); } - $parameters = array(); + $parameters = []; if (isset($criteria['enabled'])) { $query->andWhere('m.enabled = :enabled'); diff --git a/Extra/Pixlr.php b/Extra/Pixlr.php index f9b1ed7ae4..dc356d1973 100644 --- a/Extra/Pixlr.php +++ b/Extra/Pixlr.php @@ -90,7 +90,7 @@ public function __construct($referrer, $secret, Pool $pool, MediaManagerInterfac $this->templating = $templating; $this->container = $container; - $this->validFormats = array('jpg', 'jpeg', 'png'); + $this->validFormats = ['jpg', 'jpeg', 'png']; $this->allowEreg = '@https?://([a-zA-Z0-9]*).pixlr.com/_temp/[0-9a-z]{24}\.[a-z]*@'; } @@ -104,7 +104,7 @@ public function __construct($referrer, $secret, Pool $pool, MediaManagerInterfac */ public function editAction($id, $mode) { - if (!in_array($mode, array('express', 'editor'))) { + if (!in_array($mode, ['express', 'editor'])) { throw new NotFoundHttpException('Invalid mode'); } @@ -114,16 +114,16 @@ public function editAction($id, $mode) $hash = $this->generateHash($media); - $parameters = array( + $parameters = [ 's' => 'c', // ?? 'referrer' => $this->referrer, - 'exit' => $this->router->generate('sonata_media_pixlr_exit', array('hash' => $hash, 'id' => $media->getId()), UrlGeneratorInterface::ABSOLUTE_URL), + 'exit' => $this->router->generate('sonata_media_pixlr_exit', ['hash' => $hash, 'id' => $media->getId()], UrlGeneratorInterface::ABSOLUTE_URL), 'image' => $provider->generatePublicUrl($media, MediaProviderInterface::FORMAT_REFERENCE), 'title' => $media->getName(), - 'target' => $this->router->generate('sonata_media_pixlr_target', array('hash' => $hash, 'id' => $media->getId()), UrlGeneratorInterface::ABSOLUTE_URL), + 'target' => $this->router->generate('sonata_media_pixlr_target', ['hash' => $hash, 'id' => $media->getId()], UrlGeneratorInterface::ABSOLUTE_URL), 'locktitle' => true, 'locktarget' => true, - ); + ]; $url = sprintf('https://pixlr.com/%s/?%s', $mode, $this->buildQuery($parameters)); @@ -207,10 +207,10 @@ public function openEditorAction($id) throw new NotFoundHttpException('The media is not editable'); } - return new Response($this->templating->render('SonataMediaBundle:Extra:pixlr_editor.html.twig', array( + return new Response($this->templating->render('SonataMediaBundle:Extra:pixlr_editor.html.twig', [ 'media' => $media, 'admin_pool' => $this->container->get('sonata.admin.pool'), - ))); + ])); } /** @@ -232,7 +232,7 @@ private function generateHash(MediaInterface $media) */ private function getMedia($id) { - $media = $this->mediaManager->findOneBy(array('id' => $id)); + $media = $this->mediaManager->findOneBy(['id' => $id]); if (!$media) { throw new NotFoundHttpException('Media not found'); @@ -263,9 +263,9 @@ private function checkMedia($hash, MediaInterface $media) * * @return string */ - private function buildQuery(array $parameters = array()) + private function buildQuery(array $parameters = []) { - $query = array(); + $query = []; foreach ($parameters as $name => $value) { $query[] = sprintf('%s=%s', $name, $value); } diff --git a/Filesystem/Replicate.php b/Filesystem/Replicate.php index bbbc0a065a..39a0390602 100644 --- a/Filesystem/Replicate.php +++ b/Filesystem/Replicate.php @@ -202,7 +202,7 @@ public function getMetadata($key) return $this->slave->getMetadata($key); } - return array(); + return []; } /** @@ -212,10 +212,10 @@ public function getMetadata($key) */ public function getAdapterClassNames() { - return array( + return [ get_class($this->master), get_class($this->slave), - ); + ]; } /** diff --git a/Form/DataTransformer/ProviderDataTransformer.php b/Form/DataTransformer/ProviderDataTransformer.php index 619871685d..58b39e36e4 100644 --- a/Form/DataTransformer/ProviderDataTransformer.php +++ b/Form/DataTransformer/ProviderDataTransformer.php @@ -42,7 +42,7 @@ class ProviderDataTransformer implements DataTransformerInterface, LoggerAwareIn * @param string $class * @param array $options */ - public function __construct(Pool $pool, $class, array $options = array()) + public function __construct(Pool $pool, $class, array $options = []) { $this->pool = $pool; $this->options = $this->getOptions($options); @@ -124,7 +124,7 @@ public function reverseTransform($media) // Error message inspired from Monolog\ErrorHandler $this->logger->error( sprintf('Caught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), - array('exception' => $e) + ['exception' => $e] ); } @@ -140,11 +140,11 @@ public function reverseTransform($media) */ protected function getOptions(array $options) { - return array_merge(array( + return array_merge([ 'provider' => false, 'context' => false, 'empty_on_new' => true, 'new_on_update' => true, - ), $options); + ], $options); } } diff --git a/Form/DataTransformer/ServiceProviderDataTransformer.php b/Form/DataTransformer/ServiceProviderDataTransformer.php index 285c6bc3fa..ba77db33ab 100644 --- a/Form/DataTransformer/ServiceProviderDataTransformer.php +++ b/Form/DataTransformer/ServiceProviderDataTransformer.php @@ -77,7 +77,7 @@ public function reverseTransform($media) // Error message taken from Monolog\ErrorHandler $this->logger->error( sprintf('Caught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), - array('exception' => $e) + ['exception' => $e] ); } diff --git a/Form/Type/ApiMediaType.php b/Form/Type/ApiMediaType.php index 448119295a..11e3e55d80 100644 --- a/Form/Type/ApiMediaType.php +++ b/Form/Type/ApiMediaType.php @@ -68,9 +68,9 @@ public function setLogger(LoggerInterface $logger) */ public function buildForm(FormBuilderInterface $builder, array $options) { - $dataTransformer = new ProviderDataTransformer($this->mediaPool, $this->class, array( + $dataTransformer = new ProviderDataTransformer($this->mediaPool, $this->class, [ 'empty_on_new' => false, - )); + ]); $dataTransformer->setLogger($this->logger); $builder->addModelTransformer($dataTransformer, true); @@ -84,10 +84,10 @@ public function buildForm(FormBuilderInterface $builder, array $options) */ public function configureOptions(OptionsResolver $resolver) { - $resolver->setDefaults(array( + $resolver->setDefaults([ 'provider_name' => 'sonata.media.provider.image', 'context' => 'api', - )); + ]); } /** diff --git a/Form/Type/MediaType.php b/Form/Type/MediaType.php index dddde780b0..d20dff14c7 100644 --- a/Form/Type/MediaType.php +++ b/Form/Type/MediaType.php @@ -69,12 +69,12 @@ public function setLogger(LoggerInterface $logger) */ public function buildForm(FormBuilderInterface $builder, array $options) { - $dataTransformer = new ProviderDataTransformer($this->pool, $this->class, array( + $dataTransformer = new ProviderDataTransformer($this->pool, $this->class, [ 'provider' => $options['provider'], 'context' => $options['context'], 'empty_on_new' => $options['empty_on_new'], 'new_on_update' => $options['new_on_update'], - )); + ]); $dataTransformer->setLogger($this->logger); $builder->addModelTransformer($dataTransformer); @@ -90,12 +90,12 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add( 'unlink', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType', - array( + [ 'label' => 'widget_label_unlink', 'mapped' => false, 'data' => false, 'required' => false, - ) + ] ); } @@ -114,16 +114,16 @@ public function buildView(FormView $view, FormInterface $form, array $options) public function configureOptions(OptionsResolver $resolver) { $resolver - ->setDefaults(array( + ->setDefaults([ 'data_class' => $this->class, 'empty_on_new' => true, 'new_on_update' => true, 'translation_domain' => 'SonataMediaBundle', - )) - ->setRequired(array( + ]) + ->setRequired([ 'provider', 'context', - )); + ]); $resolver ->setAllowedTypes('provider', 'string') diff --git a/Listener/ODM/MediaEventSubscriber.php b/Listener/ODM/MediaEventSubscriber.php index f1a2567469..7da813425b 100644 --- a/Listener/ODM/MediaEventSubscriber.php +++ b/Listener/ODM/MediaEventSubscriber.php @@ -22,14 +22,14 @@ class MediaEventSubscriber extends BaseMediaEventSubscriber */ public function getSubscribedEvents() { - return array( + return [ Events::prePersist, Events::preUpdate, Events::preRemove, Events::postUpdate, Events::postRemove, Events::postPersist, - ); + ]; } /** diff --git a/Listener/ORM/MediaEventSubscriber.php b/Listener/ORM/MediaEventSubscriber.php index ece648800b..6aec07c73e 100644 --- a/Listener/ORM/MediaEventSubscriber.php +++ b/Listener/ORM/MediaEventSubscriber.php @@ -29,7 +29,7 @@ class MediaEventSubscriber extends BaseMediaEventSubscriber */ public function getSubscribedEvents() { - return array( + return [ Events::prePersist, Events::preUpdate, Events::preRemove, @@ -37,7 +37,7 @@ public function getSubscribedEvents() Events::postRemove, Events::postPersist, Events::onClear, - ); + ]; } public function onClear() diff --git a/Listener/PHPCR/MediaEventSubscriber.php b/Listener/PHPCR/MediaEventSubscriber.php index 6afd513420..ff2cce5e31 100644 --- a/Listener/PHPCR/MediaEventSubscriber.php +++ b/Listener/PHPCR/MediaEventSubscriber.php @@ -22,14 +22,14 @@ class MediaEventSubscriber extends BaseMediaEventSubscriber */ public function getSubscribedEvents() { - return array( + return [ Event::prePersist, Event::preUpdate, Event::preRemove, Event::postUpdate, Event::postRemove, Event::postPersist, - ); + ]; } /** diff --git a/Metadata/AmazonMetadataBuilder.php b/Metadata/AmazonMetadataBuilder.php index 011c231c1c..e801d38846 100644 --- a/Metadata/AmazonMetadataBuilder.php +++ b/Metadata/AmazonMetadataBuilder.php @@ -35,14 +35,14 @@ class AmazonMetadataBuilder implements MetadataBuilderInterface /** * @var string[] */ - protected $acl = array( + protected $acl = [ 'private' => self::PRIVATE_ACCESS, 'public' => self::PUBLIC_READ, 'open' => self::PUBLIC_READ_WRITE, 'auth_read' => self::AUTHENTICATED_READ, 'owner_read' => self::BUCKET_OWNER_READ, 'owner_full_control' => self::BUCKET_OWNER_FULL_CONTROL, - ); + ]; /** * @param array $settings @@ -71,7 +71,7 @@ public function get(MediaInterface $media, $filename) protected function getDefaultMetadata() { //merge acl - $output = array(); + $output = []; if (isset($this->settings['acl']) && !empty($this->settings['acl'])) { $output['ACL'] = $this->acl[$this->settings['acl']]; } @@ -117,6 +117,6 @@ protected function getContentType($filename) $extension = pathinfo($filename, PATHINFO_EXTENSION); $contentType = Mimetypes::getInstance()->fromExtension($extension); - return array('contentType' => $contentType); + return ['contentType' => $contentType]; } } diff --git a/Metadata/NoopMetadataBuilder.php b/Metadata/NoopMetadataBuilder.php index 74460374b1..5f9be05825 100644 --- a/Metadata/NoopMetadataBuilder.php +++ b/Metadata/NoopMetadataBuilder.php @@ -20,6 +20,6 @@ class NoopMetadataBuilder implements MetadataBuilderInterface */ public function get(MediaInterface $media, $filename) { - return array(); + return []; } } diff --git a/Metadata/ProxyMetadataBuilder.php b/Metadata/ProxyMetadataBuilder.php index 916e3d0140..bdd669ce78 100644 --- a/Metadata/ProxyMetadataBuilder.php +++ b/Metadata/ProxyMetadataBuilder.php @@ -47,7 +47,7 @@ public function get(MediaInterface $media, $filename) { //get adapter for current media if (!$this->container->has($media->getProviderName())) { - return array(); + return []; } if ($meta = $this->getAmazonBuilder($media, $filename)) { @@ -55,7 +55,7 @@ public function get(MediaInterface $media, $filename) } if (!$this->container->has('sonata.media.metadata.noop')) { - return array(); + return []; } return $this->container->get('sonata.media.metadata.noop')->get($media, $filename); @@ -75,7 +75,7 @@ protected function getAmazonBuilder(MediaInterface $media, $filename) if ($adapter instanceof Replicate) { $adapterClassNames = $adapter->getAdapterClassNames(); } else { - $adapterClassNames = array(get_class($adapter)); + $adapterClassNames = [get_class($adapter)]; } //for amazon s3 diff --git a/Model/Media.php b/Model/Media.php index 7faa075408..7d1697d5da 100644 --- a/Model/Media.php +++ b/Model/Media.php @@ -49,7 +49,7 @@ abstract class Media implements MediaInterface /** * @var array */ - protected $providerMetadata = array(); + protected $providerMetadata = []; /** * @var int @@ -167,13 +167,13 @@ public function preUpdate() */ public static function getStatusList() { - return array( + return [ self::STATUS_OK => 'ok', self::STATUS_SENDING => 'sending', self::STATUS_PENDING => 'pending', self::STATUS_ERROR => 'error', self::STATUS_ENCODING => 'encoding', - ); + ]; } /** @@ -331,7 +331,7 @@ public function getProviderReference() /** * {@inheritdoc} */ - public function setProviderMetadata(array $providerMetadata = array()) + public function setProviderMetadata(array $providerMetadata = []) { $this->providerMetadata = $providerMetadata; } diff --git a/Model/MediaInterface.php b/Model/MediaInterface.php index 5045044468..36a768ecb3 100644 --- a/Model/MediaInterface.php +++ b/Model/MediaInterface.php @@ -151,7 +151,7 @@ public function getProviderReference(); * * @param array $providerMetadata */ - public function setProviderMetadata(array $providerMetadata = array()); + public function setProviderMetadata(array $providerMetadata = []); /** * Get provider_metadata. diff --git a/PHPCR/GalleryManager.php b/PHPCR/GalleryManager.php index 43cdca2861..9f9d018b61 100644 --- a/PHPCR/GalleryManager.php +++ b/PHPCR/GalleryManager.php @@ -34,7 +34,7 @@ public function update(GalleryInterface $gallery) /** * {@inheritdoc} */ - public function getPager(array $criteria, $page, $limit = 10, array $sort = array()) + public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { throw new \RuntimeException('Not Implemented yet'); } diff --git a/PHPCR/MediaManager.php b/PHPCR/MediaManager.php index a9fb992416..79fa0f57e4 100644 --- a/PHPCR/MediaManager.php +++ b/PHPCR/MediaManager.php @@ -41,7 +41,7 @@ public function save($entity, $andFlush = true) /** * {@inheritdoc} */ - public function getPager(array $criteria, $page, $limit = 10, array $sort = array()) + public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { throw new \RuntimeException('Not Implemented yet'); } diff --git a/Provider/BaseProvider.php b/Provider/BaseProvider.php index d470fd0fcf..393fde044b 100644 --- a/Provider/BaseProvider.php +++ b/Provider/BaseProvider.php @@ -25,12 +25,12 @@ abstract class BaseProvider implements MediaProviderInterface /** * @var array */ - protected $formats = array(); + protected $formats = []; /** * @var string[] */ - protected $templates = array(); + protected $templates = []; /** * @var ResizerInterface @@ -97,7 +97,7 @@ final public function transform(MediaInterface $media) public function flushCdn(MediaInterface $media) { if ($media->getId() && $this->requireThumbnails() && !$media->getCdnIsFlushable()) { - $flushPaths = array(); + $flushPaths = []; foreach ($this->getFormats() as $format => $settings) { if (MediaProviderInterface::FORMAT_ADMIN === $format || substr($format, 0, strlen($media->getContext())) === $media->getContext()) { @@ -179,7 +179,7 @@ public function getFormatName(MediaInterface $media, $format) */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-file')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', ['class' => 'fa fa-file']); } /** diff --git a/Provider/BaseVideoProvider.php b/Provider/BaseVideoProvider.php index 9fbe033223..1791579fe4 100644 --- a/Provider/BaseVideoProvider.php +++ b/Provider/BaseVideoProvider.php @@ -64,7 +64,7 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().'.description', null, 'SonataMediaBundle', array('class' => 'fa fa-video-camera')); + return new Metadata($this->getName(), $this->getName().'.description', null, 'SonataMediaBundle', ['class' => 'fa fa-video-camera']); } /** @@ -87,7 +87,7 @@ public function getReferenceFile(MediaInterface $media) $referenceFile = $this->getFilesystem()->get($key); } else { $referenceFile = $this->getFilesystem()->get($key, true); - $metadata = $this->metadata ? $this->metadata->get($media, $referenceFile->getName()) : array(); + $metadata = $this->metadata ? $this->metadata->get($media, $referenceFile->getName()) : []; $referenceFile->setContent($this->browser->get($this->getReferenceImage($media))->getContent(), $metadata); } @@ -124,7 +124,7 @@ public function generatePrivateUrl(MediaInterface $media, $format) public function buildEditForm(FormMapper $formMapper) { $formMapper->add('name'); - $formMapper->add('enabled', null, array('required' => false)); + $formMapper->add('enabled', null, ['required' => false]); $formMapper->add('authorName'); $formMapper->add('cdnIsFlushable'); $formMapper->add('description'); @@ -132,7 +132,7 @@ public function buildEditForm(FormMapper $formMapper) $formMapper->add( 'binaryContent', 'Symfony\Component\Form\Extension\Core\Type\TextType', - array('required' => false) + ['required' => false] ); } @@ -144,12 +144,12 @@ public function buildCreateForm(FormMapper $formMapper) $formMapper->add( 'binaryContent', 'Symfony\Component\Form\Extension\Core\Type\TextType', - array( - 'constraints' => array( + [ + 'constraints' => [ new NotBlank(), new NotNull(), - ), - ) + ], + ] ); } @@ -161,9 +161,9 @@ public function buildMediaType(FormBuilder $formBuilder) $formBuilder->add( 'binaryContent', 'Symfony\Component\Form\Extension\Core\Type\TextType', - array( + [ 'label' => 'widget_label_binary_content', - ) + ] ); } @@ -238,17 +238,17 @@ protected function getMetadata(MediaInterface $media, $url) * * @return Box */ - protected function getBoxHelperProperties(MediaInterface $media, $format, $options = array()) + protected function getBoxHelperProperties(MediaInterface $media, $format, $options = []) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { return $media->getBox(); } if (isset($options['width']) || isset($options['height'])) { - $settings = array( + $settings = [ 'width' => isset($options['width']) ? $options['width'] : null, 'height' => isset($options['height']) ? $options['height'] : null, - ); + ]; } else { $settings = $this->getFormat($format); } diff --git a/Provider/DailyMotionProvider.php b/Provider/DailyMotionProvider.php index 05e3474dd0..bcf97a6e6e 100644 --- a/Provider/DailyMotionProvider.php +++ b/Provider/DailyMotionProvider.php @@ -20,11 +20,11 @@ class DailyMotionProvider extends BaseVideoProvider /** * {@inheritdoc} */ - public function getHelperProperties(MediaInterface $media, $format, $options = array()) + public function getHelperProperties(MediaInterface $media, $format, $options = []) { // documentation : http://www.dailymotion.com/en/doc/api/player - $defaults = array( + $defaults = [ // Values: 0 or 1. Default is 0. Determines if the player loads related videos when // the current video begins playback. 'related' => 0, @@ -68,19 +68,19 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a 'foreground' => null, 'background' => null, 'highlight' => null, - ); + ]; - $player_parameters = array_merge($defaults, isset($options['player_parameters']) ? $options['player_parameters'] : array()); + $player_parameters = array_merge($defaults, isset($options['player_parameters']) ? $options['player_parameters'] : []); $box = $this->getBoxHelperProperties($media, $format, $options); - $params = array( + $params = [ 'player_parameters' => http_build_query($player_parameters), 'allowFullScreen' => isset($options['allowFullScreen']) ? $options['allowFullScreen'] : 'true', 'allowScriptAccess' => isset($options['allowScriptAccess']) ? $options['allowScriptAccess'] : 'always', 'width' => $box->getWidth(), 'height' => $box->getHeight(), - ); + ]; return $params; } @@ -123,7 +123,7 @@ public function updateMetadata(MediaInterface $media, $force = false) /** * {@inheritdoc} */ - public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array()) + public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { return new RedirectResponse($this->getReferenceUrl($media), 302, $headers); } diff --git a/Provider/FileProvider.php b/Provider/FileProvider.php index d11d3a51af..559bfa217f 100644 --- a/Provider/FileProvider.php +++ b/Provider/FileProvider.php @@ -50,7 +50,7 @@ class FileProvider extends BaseProvider * @param array $allowedMimeTypes * @param MetadataBuilderInterface $metadata */ - public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, GeneratorInterface $pathGenerator, ThumbnailInterface $thumbnail, array $allowedExtensions = array(), array $allowedMimeTypes = array(), MetadataBuilderInterface $metadata = null) + public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, GeneratorInterface $pathGenerator, ThumbnailInterface $thumbnail, array $allowedExtensions = [], array $allowedMimeTypes = [], MetadataBuilderInterface $metadata = null) { parent::__construct($name, $filesystem, $cdn, $pathGenerator, $thumbnail); @@ -64,7 +64,7 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-file-text-o')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', ['class' => 'fa fa-file-text-o']); } /** @@ -92,7 +92,7 @@ public function getReferenceFile(MediaInterface $media) public function buildEditForm(FormMapper $formMapper) { $formMapper->add('name'); - $formMapper->add('enabled', null, array('required' => false)); + $formMapper->add('enabled', null, ['required' => false]); $formMapper->add('authorName'); $formMapper->add('cdnIsFlushable'); $formMapper->add('description'); @@ -100,7 +100,7 @@ public function buildEditForm(FormMapper $formMapper) $formMapper->add( 'binaryContent', 'Symfony\Component\Form\Extension\Core\Type\FileType', - array('required' => false) + ['required' => false] ); } @@ -112,12 +112,12 @@ public function buildCreateForm(FormMapper $formMapper) $formMapper->add( 'binaryContent', 'Symfony\Component\Form\Extension\Core\Type\FileType', - array( - 'constraints' => array( + [ + 'constraints' => [ new NotBlank(), new NotNull(), - ), - ) + ], + ] ); } @@ -132,10 +132,10 @@ public function buildMediaType(FormBuilder $formBuilder) $formBuilder->add('binaryContent', $fileType); $formBuilder->add('contentType'); } else { - $formBuilder->add('binaryContent', $fileType, array( + $formBuilder->add('binaryContent', $fileType, [ 'required' => false, 'label' => 'widget_label_binary_content', - )); + ]); } } @@ -222,13 +222,13 @@ public function generatePublicUrl(MediaInterface $media, $format) /** * {@inheritdoc} */ - public function getHelperProperties(MediaInterface $media, $format, $options = array()) + public function getHelperProperties(MediaInterface $media, $format, $options = []) { - return array_merge(array( + return array_merge([ 'title' => $media->getName(), 'thumbnail' => $this->getReferenceImage($media), 'file' => $this->getReferenceImage($media), - ), $options); + ], $options); } /** @@ -246,15 +246,15 @@ public function generatePrivateUrl(MediaInterface $media, $format) /** * {@inheritdoc} */ - public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array()) + public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { // build the default headers - $headers = array_merge(array( + $headers = array_merge([ 'Content-Type' => $media->getContentType(), 'Content-Disposition' => sprintf('attachment; filename="%s"', $media->getMetadataValue('filename')), - ), $headers); + ], $headers); - if (!in_array($mode, array('http', 'X-Sendfile', 'X-Accel-Redirect'))) { + if (!in_array($mode, ['http', 'X-Sendfile', 'X-Accel-Redirect'])) { throw new \RuntimeException('Invalid mode provided'); } @@ -316,7 +316,7 @@ public function validate(ErrorElement $errorElement, MediaInterface $media) if ('' != $media->getBinaryContent()->getFilename() && !in_array($media->getBinaryContent()->getMimeType(), $this->allowedMimeTypes)) { $errorElement ->with('binaryContent') - ->addViolation('Invalid mime type : %type%', array('%type%' => $media->getBinaryContent()->getMimeType())) + ->addViolation('Invalid mime type : %type%', ['%type%' => $media->getBinaryContent()->getMimeType()]) ->end(); } } @@ -406,7 +406,7 @@ protected function doTransform(MediaInterface $media) protected function setFileContents(MediaInterface $media, $contents = null) { $file = $this->getFilesystem()->get(sprintf('%s/%s', $this->generatePath($media), $media->getProviderReference()), true); - $metadata = $this->metadata ? $this->metadata->get($media, $file->getName()) : array(); + $metadata = $this->metadata ? $this->metadata->get($media, $file->getName()) : []; if ($contents) { $file->setContent($contents, $metadata); diff --git a/Provider/ImageProvider.php b/Provider/ImageProvider.php index fbb4cdd7c1..2e1facaeed 100644 --- a/Provider/ImageProvider.php +++ b/Provider/ImageProvider.php @@ -52,13 +52,13 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-picture-o')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', ['class' => 'fa fa-picture-o']); } /** * {@inheritdoc} */ - public function getHelperProperties(MediaInterface $media, $format, $options = array()) + public function getHelperProperties(MediaInterface $media, $format, $options = []) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { $box = $media->getBox(); @@ -74,16 +74,16 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a $mediaWidth = $box->getWidth(); - $params = array( + $params = [ 'alt' => $media->getName(), 'title' => $media->getName(), 'src' => $this->generatePublicUrl($media, $format), 'width' => $mediaWidth, 'height' => $box->getHeight(), - ); + ]; if ($format !== MediaProviderInterface::FORMAT_ADMIN) { - $srcSet = array(); + $srcSet = []; foreach ($this->getFormats() as $providerFormat => $settings) { // Check if format belongs to the current media's context diff --git a/Provider/MediaProviderInterface.php b/Provider/MediaProviderInterface.php index 960e844c7a..c1b4e20423 100644 --- a/Provider/MediaProviderInterface.php +++ b/Provider/MediaProviderInterface.php @@ -140,7 +140,7 @@ public function postPersist(MediaInterface $media); * @param string $format * @param array $options */ - public function getHelperProperties(MediaInterface $media, $format, $options = array()); + public function getHelperProperties(MediaInterface $media, $format, $options = []); /** * Generate the media path. @@ -218,7 +218,7 @@ public function getTemplate($name); * * @return Response */ - public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array()); + public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []); /** * @return ResizerInterface diff --git a/Provider/Pool.php b/Provider/Pool.php index afb2b4c16e..f4820a58c9 100644 --- a/Provider/Pool.php +++ b/Provider/Pool.php @@ -20,12 +20,12 @@ class Pool /** * @var array */ - protected $providers = array(); + protected $providers = []; /** * @var array */ - protected $contexts = array(); + protected $contexts = []; /** * NEXT_MAJOR: remove this property. @@ -34,12 +34,12 @@ class Pool * * @var DownloadStrategyInterface[] */ - protected $downloadSecurities = array(); + protected $downloadSecurities = []; /** * @var DownloadStrategyInterface[] */ - protected $downloadStrategies = array(); + protected $downloadStrategies = []; /** * @var string @@ -136,14 +136,14 @@ public function getProviders() * @param array $formats * @param array $download */ - public function addContext($name, array $providers = array(), array $formats = array(), array $download = array()) + public function addContext($name, array $providers = [], array $formats = [], array $download = []) { if (!$this->hasContext($name)) { - $this->contexts[$name] = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $this->contexts[$name] = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; } $this->contexts[$name]['providers'] = $providers; @@ -224,7 +224,7 @@ public function getFormatNamesByContext($name) */ public function getProvidersByContext($name) { - $providers = array(); + $providers = []; if (!$this->hasContext($name)) { return $providers; @@ -242,7 +242,7 @@ public function getProvidersByContext($name) */ public function getProviderList() { - $choices = array(); + $choices = []; foreach (array_keys($this->providers) as $name) { $choices[$name] = $name; } diff --git a/Provider/VimeoProvider.php b/Provider/VimeoProvider.php index 4d5c3deb82..e9f7c43096 100644 --- a/Provider/VimeoProvider.php +++ b/Provider/VimeoProvider.php @@ -20,10 +20,10 @@ class VimeoProvider extends BaseVideoProvider /** * {@inheritdoc} */ - public function getHelperProperties(MediaInterface $media, $format, $options = array()) + public function getHelperProperties(MediaInterface $media, $format, $options = []) { // documentation : http://vimeo.com/api/docs/moogaloop - $defaults = array( + $defaults = [ // (optional) Flash Player version of app. Defaults to 9 .NEW! // 10 - New Moogaloop. 9 - Old Moogaloop without newest features. 'fp_version' => 10, @@ -54,13 +54,13 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // Unique id that is passed into all player events as the ending parameter. 'js_swf_id' => uniqid('vimeo_player_'), - ); + ]; - $player_parameters = array_merge($defaults, isset($options['player_parameters']) ? $options['player_parameters'] : array()); + $player_parameters = array_merge($defaults, isset($options['player_parameters']) ? $options['player_parameters'] : []); $box = $this->getBoxHelperProperties($media, $format, $options); - $params = array( + $params = [ 'src' => http_build_query($player_parameters), 'id' => $player_parameters['js_swf_id'], 'frameborder' => isset($options['frameborder']) ? $options['frameborder'] : 0, @@ -68,7 +68,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a 'height' => $box->getHeight(), 'class' => isset($options['class']) ? $options['class'] : '', 'allow_fullscreen' => isset($options['allowfullscreen']) ? true : false, - ); + ]; return $params; } @@ -78,7 +78,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-vimeo-square')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', ['class' => 'fa fa-vimeo-square']); } /** @@ -116,7 +116,7 @@ public function updateMetadata(MediaInterface $media, $force = false) /** * {@inheritdoc} */ - public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array()) + public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { return new RedirectResponse($this->getReferenceUrl($media), 302, $headers); } diff --git a/Provider/YouTubeProvider.php b/Provider/YouTubeProvider.php index 73a4f68717..79ff76427d 100644 --- a/Provider/YouTubeProvider.php +++ b/Provider/YouTubeProvider.php @@ -49,13 +49,13 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge */ public function getProviderMetadata() { - return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', array('class' => 'fa fa-youtube')); + return new Metadata($this->getName(), $this->getName().'.description', false, 'SonataMediaBundle', ['class' => 'fa fa-youtube']); } /** * {@inheritdoc} */ - public function getHelperProperties(MediaInterface $media, $format, $options = array()) + public function getHelperProperties(MediaInterface $media, $format, $options = []) { // Override html5 value if $options['html5'] is a boolean if (!isset($options['html5'])) { @@ -64,7 +64,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // documentation : http://code.google.com/apis/youtube/player_parameters.html - $default_player_url_parameters = array( + $default_player_url_parameters = [ //Values: 0 or 1. Default is 1. Sets whether the player should load related // videos once playback of the initial video starts. Related videos are // displayed in the "genie menu" when the menu button is pressed. The player @@ -155,9 +155,9 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // When wmode=opaque, the Flash movie is rendered as part of the page. // When wmode=transparent, the Flash movie is rendered as part of the page. 'wmode' => 'window', - ); + ]; - $default_player_parameters = array( + $default_player_parameters = [ // Values: 0 or 1. Default is 0. Setting to 1 enables a border around the entire video // player. The border's primary color can be set via the color1 parameter, and a // secondary color can be set by the color2 parameter. @@ -177,22 +177,22 @@ public function getHelperProperties(MediaInterface $media, $format, $options = a // When wmode=opaque, the Flash movie is rendered as part of the page. // When wmode=transparent, the Flash movie is rendered as part of the page. 'wmode' => $default_player_url_parameters['wmode'], - ); + ]; - $player_url_parameters = array_merge($default_player_url_parameters, isset($options['player_url_parameters']) ? $options['player_url_parameters'] : array()); + $player_url_parameters = array_merge($default_player_url_parameters, isset($options['player_url_parameters']) ? $options['player_url_parameters'] : []); $box = $this->getBoxHelperProperties($media, $format, $options); - $player_parameters = array_merge($default_player_parameters, isset($options['player_parameters']) ? $options['player_parameters'] : array(), array( + $player_parameters = array_merge($default_player_parameters, isset($options['player_parameters']) ? $options['player_parameters'] : [], [ 'width' => $box->getWidth(), 'height' => $box->getHeight(), - )); + ]); - $params = array( + $params = [ 'html5' => $options['html5'], 'player_url_parameters' => http_build_query($player_url_parameters), 'player_parameters' => $player_parameters, - ); + ]; return $params; } @@ -228,7 +228,7 @@ public function updateMetadata(MediaInterface $media, $force = false) /** * {@inheritdoc} */ - public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array()) + public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { return new RedirectResponse($this->getReferenceUrl($media), 302, $headers); } diff --git a/Resizer/SimpleResizer.php b/Resizer/SimpleResizer.php index a4c72d9887..b85d546169 100644 --- a/Resizer/SimpleResizer.php +++ b/Resizer/SimpleResizer.php @@ -61,7 +61,7 @@ public function resize(MediaInterface $media, File $in, File $out, $format, arra $content = $image ->thumbnail($this->getBox($media, $settings), $this->mode) - ->get($format, array('quality' => $settings['quality'])); + ->get($format, ['quality' => $settings['quality']]); $out->setContent($content, $this->metadata->get($media, $out->getName())); } @@ -104,10 +104,10 @@ protected function computeBox(MediaInterface $media, array $settings) $size = $media->getBox(); - $ratios = array( + $ratios = [ $settings['width'] / $size->getWidth(), $settings['height'] / $size->getHeight(), - ); + ]; if ($this->mode === ImageInterface::THUMBNAIL_INSET) { $ratio = min($ratios); diff --git a/Resizer/SquareResizer.php b/Resizer/SquareResizer.php index 2e988b7b7a..ec66defd99 100755 --- a/Resizer/SquareResizer.php +++ b/Resizer/SquareResizer.php @@ -101,9 +101,9 @@ public function resize(MediaInterface $media, File $in, File $out, $format, arra if ($settings['height'] < $size->getHeight() && $settings['width'] < $size->getWidth()) { $content = $image ->thumbnail(new Box($settings['width'], $settings['height']), $this->mode) - ->get($format, array('quality' => $settings['quality'])); + ->get($format, ['quality' => $settings['quality']]); } else { - $content = $image->get($format, array('quality' => $settings['quality'])); + $content = $image->get($format, ['quality' => $settings['quality']]); } $out->setContent($content, $this->metadata->get($media, $out->getName())); diff --git a/Security/ForbiddenDownloadStrategy.php b/Security/ForbiddenDownloadStrategy.php index 544d7402b5..97f565e38e 100644 --- a/Security/ForbiddenDownloadStrategy.php +++ b/Security/ForbiddenDownloadStrategy.php @@ -43,6 +43,6 @@ public function isGranted(MediaInterface $media, Request $request) */ public function getDescription() { - return $this->translator->trans('description.forbidden_download_strategy', array(), 'SonataMediaBundle'); + return $this->translator->trans('description.forbidden_download_strategy', [], 'SonataMediaBundle'); } } diff --git a/Security/PublicDownloadStrategy.php b/Security/PublicDownloadStrategy.php index bc50b9f095..9618bc1c59 100644 --- a/Security/PublicDownloadStrategy.php +++ b/Security/PublicDownloadStrategy.php @@ -43,6 +43,6 @@ public function isGranted(MediaInterface $media, Request $request) */ public function getDescription() { - return $this->translator->trans('description.public_download_strategy', array(), 'SonataMediaBundle'); + return $this->translator->trans('description.public_download_strategy', [], 'SonataMediaBundle'); } } diff --git a/Security/RolesDownloadStrategy.php b/Security/RolesDownloadStrategy.php index d5c64fd658..9300001e80 100644 --- a/Security/RolesDownloadStrategy.php +++ b/Security/RolesDownloadStrategy.php @@ -39,7 +39,7 @@ class RolesDownloadStrategy implements DownloadStrategyInterface * @param AuthorizationCheckerInterface $security * @param string[] $roles */ - public function __construct(TranslatorInterface $translator, AuthorizationCheckerInterface $security, array $roles = array()) + public function __construct(TranslatorInterface $translator, AuthorizationCheckerInterface $security, array $roles = []) { $this->roles = $roles; $this->security = $security; @@ -64,6 +64,6 @@ public function isGranted(MediaInterface $media, Request $request) */ public function getDescription() { - return $this->translator->trans('description.roles_download_strategy', array('%roles%' => ''.implode(', ', $this->roles).''), 'SonataMediaBundle'); + return $this->translator->trans('description.roles_download_strategy', ['%roles%' => ''.implode(', ', $this->roles).''], 'SonataMediaBundle'); } } diff --git a/Security/SessionDownloadStrategy.php b/Security/SessionDownloadStrategy.php index cc15552629..4d246180c7 100644 --- a/Security/SessionDownloadStrategy.php +++ b/Security/SessionDownloadStrategy.php @@ -79,7 +79,7 @@ public function getDescription() return $this->translator->transChoice( 'description.session_download_strategy', $this->times, - array('%times%' => $this->times), + ['%times%' => $this->times], 'SonataMediaBundle' ); } diff --git a/SonataMediaBundle.php b/SonataMediaBundle.php index 09295f49aa..c0ff0d5fde 100644 --- a/SonataMediaBundle.php +++ b/SonataMediaBundle.php @@ -48,12 +48,12 @@ public function boot() */ public function registerFormMapping() { - FormHelper::registerFormTypeMapping(array( + FormHelper::registerFormTypeMapping([ 'sonata_media_type' => 'Sonata\MediaBundle\Form\Type\MediaType', 'sonata_media_api_form_media' => 'Sonata\MediaBundle\Form\Type\ApiMediaType', 'sonata_media_api_form_doctrine_media' => 'Sonata\MediaBundle\Form\Type\ApiDoctrineMediaType', 'sonata_media_api_form_gallery' => 'Sonata\MediaBundle\Form\Type\ApiGalleryType', 'sonata_media_api_form_gallery_item' => 'Sonata\MediaBundle\Form\Type\ApiGalleryItemType', - )); + ]); } } diff --git a/Templating/Helper/MediaHelper.php b/Templating/Helper/MediaHelper.php index 550d966886..9145ba816b 100644 --- a/Templating/Helper/MediaHelper.php +++ b/Templating/Helper/MediaHelper.php @@ -60,7 +60,7 @@ public function getName() * * @return string */ - public function media($media, $format, $options = array()) + public function media($media, $format, $options = []) { if (!$media) { return ''; @@ -72,11 +72,11 @@ public function media($media, $format, $options = array()) $options = $provider->getHelperProperties($media, $format, $options); - return $this->templating->render($provider->getTemplate('helper_view'), array( + return $this->templating->render($provider->getTemplate('helper_view'), [ 'media' => $media, 'format' => $format, 'options' => $options, - )); + ]); } /** @@ -88,7 +88,7 @@ public function media($media, $format, $options = array()) * * @return string */ - public function thumbnail($media, $format, $options = array()) + public function thumbnail($media, $format, $options = []) { if (!$media) { return ''; @@ -100,17 +100,17 @@ public function thumbnail($media, $format, $options = array()) $formatDefinition = $provider->getFormat($format); // build option - $options = array_merge(array( + $options = array_merge([ 'title' => $media->getName(), 'width' => $formatDefinition['width'], - ), $options); + ], $options); $options['src'] = $provider->generatePublicUrl($media, $format); - return $this->getTemplating()->render($provider->getTemplate('helper_thumbnail'), array( + return $this->getTemplating()->render($provider->getTemplate('helper_thumbnail'), [ 'media' => $media, 'options' => $options, - )); + ]); } /** diff --git a/Tests/Admin/BaseMediaAdminTest.php b/Tests/Admin/BaseMediaAdminTest.php index 36fce28c4e..e371d27d23 100644 --- a/Tests/Admin/BaseMediaAdminTest.php +++ b/Tests/Admin/BaseMediaAdminTest.php @@ -85,9 +85,9 @@ private function configureGetPersistentParameters() $this->request->query = $query->reveal(); $this->pool->getDefaultContext()->willReturn('default_context'); - $this->pool->getProvidersByContext('context')->willReturn(array($provider->reveal())); + $this->pool->getProvidersByContext('context')->willReturn([$provider->reveal()]); $this->categoryManager->getRootCategory('context')->willReturn($category->reveal()); - $this->request->get('filter')->willReturn(array()); + $this->request->get('filter')->willReturn([]); $this->request->get('provider')->willReturn(null); $this->request->get('category')->willReturn(null); $this->request->get('hide_context')->willReturn(true); @@ -97,7 +97,7 @@ private function configureGetPersistentParameters() private function configureGetProviderName($media) { - $this->request->get('uniqid')->willReturn(array('providerName' => 'providerName')); + $this->request->get('uniqid')->willReturn(['providerName' => 'providerName']); $media->setProviderName('providerName')->shouldBeCalled(); } } diff --git a/Tests/Block/FeatureMediaBlockServiceTest.php b/Tests/Block/FeatureMediaBlockServiceTest.php index 6df467117e..013c5d5e15 100644 --- a/Tests/Block/FeatureMediaBlockServiceTest.php +++ b/Tests/Block/FeatureMediaBlockServiceTest.php @@ -39,11 +39,11 @@ public function testDefaultSettings() { $blockContext = $this->getBlockContext($this->blockService); - $this->assertSettings(array( - 'attr' => array(), + $this->assertSettings([ + 'attr' => [], 'content' => false, 'context' => false, - 'extra_cache_keys' => array(), + 'extra_cache_keys' => [], 'format' => false, 'media' => false, 'mediaId' => null, @@ -52,6 +52,6 @@ public function testDefaultSettings() 'title' => false, 'ttl' => 0, 'use_cache' => true, - ), $blockContext); + ], $blockContext); } } diff --git a/Tests/Block/GalleryBlockServiceTest.php b/Tests/Block/GalleryBlockServiceTest.php index 7889bd5d5e..05c6e51e42 100644 --- a/Tests/Block/GalleryBlockServiceTest.php +++ b/Tests/Block/GalleryBlockServiceTest.php @@ -42,10 +42,10 @@ public function testExecute() $blockContext = $this->prophesize('Sonata\BlockBundle\Block\BlockContext'); $blockContext->getBlock()->willReturn($block->reveal()); - $blockContext->getSettings()->willReturn(array('settings')); + $blockContext->getSettings()->willReturn(['settings']); $blockContext->getTemplate()->willReturn('template'); $block->getSetting('galleryId')->willReturn($gallery->reveal()); - $gallery->getGalleryItems()->willReturn(array()); + $gallery->getGalleryItems()->willReturn([]); $this->blockService->execute($blockContext->reveal()); @@ -60,10 +60,10 @@ public function testDefaultSettings() { $blockContext = $this->getBlockContext($this->blockService); - $this->assertSettings(array( - 'attr' => array(), + $this->assertSettings([ + 'attr' => [], 'context' => false, - 'extra_cache_keys' => array(), + 'extra_cache_keys' => [], 'format' => false, 'gallery' => false, 'galleryId' => null, @@ -73,6 +73,6 @@ public function testDefaultSettings() 'title' => false, 'ttl' => 0, 'use_cache' => true, - ), $blockContext); + ], $blockContext); } } diff --git a/Tests/Block/GalleryListBlockServiceTest.php b/Tests/Block/GalleryListBlockServiceTest.php index b53ea44e4a..8a151a929a 100644 --- a/Tests/Block/GalleryListBlockServiceTest.php +++ b/Tests/Block/GalleryListBlockServiceTest.php @@ -45,7 +45,7 @@ public function testExecute() $block = new Block(); - $blockContext = new BlockContext($block, array( + $blockContext = new BlockContext($block, [ 'number' => 15, 'mode' => 'public', 'order' => 'createdAt', @@ -53,7 +53,7 @@ public function testExecute() 'context' => false, 'title' => 'Gallery List', 'template' => 'SonataMediaBundle:Block:block_gallery_list.html.twig', - )); + ]); $blockService = new GalleryListBlockService('block.service', $this->templating, $this->galleryManager, $this->pool); $blockService->execute($blockContext); @@ -71,7 +71,7 @@ public function testDefaultSettings() $blockService = new GalleryListBlockService('block.service', $this->templating, $this->galleryManager, $this->pool); $blockContext = $this->getBlockContext($blockService); - $this->assertSettings(array( + $this->assertSettings([ 'number' => 15, 'mode' => 'public', 'order' => 'createdAt', @@ -79,6 +79,6 @@ public function testDefaultSettings() 'context' => false, 'title' => 'Gallery List', 'template' => 'SonataMediaBundle:Block:block_gallery_list.html.twig', - ), $blockContext); + ], $blockContext); } } diff --git a/Tests/Block/MediaBlockServiceTest.php b/Tests/Block/MediaBlockServiceTest.php index 0aa14bf1a2..90fd43d47b 100644 --- a/Tests/Block/MediaBlockServiceTest.php +++ b/Tests/Block/MediaBlockServiceTest.php @@ -41,11 +41,11 @@ public function testExecute() $media = $this->prophesize('Sonata\MediaBundle\Model\MediaInterface'); $blockContext = $this->prophesize('Sonata\BlockBundle\Block\BlockContext'); - $this->configureGetFormatChoices($media, array('format1' => 'format1')); + $this->configureGetFormatChoices($media, ['format1' => 'format1']); $blockContext->getBlock()->willReturn($block->reveal()); $blockContext->getSetting('format')->willReturn('format'); $blockContext->setSetting('format', 'format1')->shouldBeCalled(); - $blockContext->getSettings()->willReturn(array()); + $blockContext->getSettings()->willReturn([]); $blockContext->getTemplate()->willReturn('template'); $blockContext->getSetting('mediaId')->willReturn($media->reveal()); $block->getSetting('mediaId')->willReturn($media->reveal()); @@ -62,10 +62,10 @@ public function testDefaultSettings() { $blockContext = $this->getBlockContext($this->blockService); - $this->assertSettings(array( - 'attr' => array(), + $this->assertSettings([ + 'attr' => [], 'context' => false, - 'extra_cache_keys' => array(), + 'extra_cache_keys' => [], 'format' => false, 'media' => false, 'mediaId' => null, @@ -73,7 +73,7 @@ public function testDefaultSettings() 'title' => false, 'ttl' => 0, 'use_cache' => true, - ), $blockContext); + ], $blockContext); } private function configureGetFormatChoices($media, $choices) diff --git a/Tests/CDN/CloudFrontTest.php b/Tests/CDN/CloudFrontTest.php index c4543f783e..26d09d7de1 100644 --- a/Tests/CDN/CloudFrontTest.php +++ b/Tests/CDN/CloudFrontTest.php @@ -24,14 +24,14 @@ class CloudFrontTest extends PHPUnit_Framework_TestCase public function testLegacyCloudFront() { $client = $this->getMockBuilder('Aws\CloudFront\CloudFrontClient') - ->setMethods(array('createInvalidation')) + ->setMethods(['createInvalidation']) ->disableOriginalConstructor() ->getMock(); $client->expects($this->exactly(3))->method('createInvalidation')->will($this->returnValue(new CloudFrontResultSpy())); $cloudFront = $this->getMockBuilder('Sonata\MediaBundle\CDN\CloudFront') - ->setConstructorArgs(array('/foo', 'secret', 'key', 'xxxxxxxxxxxxxx')) + ->setConstructorArgs(['/foo', 'secret', 'key', 'xxxxxxxxxxxxxx']) ->setMethods(null) ->getMock(); $cloudFront->setClient($client); @@ -42,7 +42,7 @@ public function testLegacyCloudFront() $cloudFront->flushByString($path); $cloudFront->flush($path); - $cloudFront->flushPaths(array($path)); + $cloudFront->flushPaths([$path]); } /** @@ -53,17 +53,17 @@ public function testLegacyException() $this->setExpectedException('\RuntimeException', 'Unable to flush : '); $client = $this->getMockBuilder('Aws\CloudFront\CloudFrontClient') - ->setMethods(array('createInvalidation')) + ->setMethods(['createInvalidation']) ->disableOriginalConstructor() ->getMock(); $client->expects($this->exactly(1))->method('createInvalidation')->will($this->returnValue(new CloudFrontResultSpy(true))); $cloudFront = $this->getMockBuilder('Sonata\MediaBundle\CDN\CloudFront') - ->setConstructorArgs(array('/foo', 'secret', 'key', 'xxxxxxxxxxxxxx')) + ->setConstructorArgs(['/foo', 'secret', 'key', 'xxxxxxxxxxxxxx']) ->setMethods(null) ->getMock(); $cloudFront->setClient($client); - $cloudFront->flushPaths(array('boom')); + $cloudFront->flushPaths(['boom']); } } diff --git a/Tests/CDN/PantherPortalTest.php b/Tests/CDN/PantherPortalTest.php index 19ba452824..7c7e8d6ee1 100644 --- a/Tests/CDN/PantherPortalTest.php +++ b/Tests/CDN/PantherPortalTest.php @@ -20,8 +20,8 @@ public function testPortal() { $client = $this->createMock( 'Sonata\MediaBundle\Tests\CDN\ClientSpy', - array('flush'), - array(), + ['flush'], + [], '', false ); @@ -36,7 +36,7 @@ public function testPortal() $panther->flushByString($path); $panther->flush($path); - $panther->flushPaths(array($path)); + $panther->flushPaths([$path]); } public function testException() @@ -45,8 +45,8 @@ public function testException() $client = $this->createMock( 'Sonata\MediaBundle\Tests\CDN\ClientSpy', - array('flush'), - array(), + ['flush'], + [], '', false ); @@ -55,7 +55,7 @@ public function testException() $panther = new PantherPortal('/foo', 'login', 'pass', 42); $panther->setClient($client); - $panther->flushPaths(array('boom')); + $panther->flushPaths(['boom']); } } diff --git a/Tests/Command/CleanMediaCommandTest.php b/Tests/Command/CleanMediaCommandTest.php index 69c9ca1a5a..b18891c6bb 100755 --- a/Tests/Command/CleanMediaCommandTest.php +++ b/Tests/Command/CleanMediaCommandTest.php @@ -116,15 +116,15 @@ protected function setUp() public function testExecuteDirectoryNotExists() { - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; - $this->pool->expects($this->once())->method('getContexts')->will($this->returnValue(array('foo' => $context))); + $this->pool->expects($this->once())->method('getContexts')->will($this->returnValue(['foo' => $context])); - $output = $this->tester->execute(array('command' => $this->command->getName())); + $output = $this->tester->execute(['command' => $this->command->getName()]); $this->assertRegExp('@\'.+\' does not exist\s+done!@', $this->tester->getDisplay()); @@ -135,15 +135,15 @@ public function testExecuteEmptyDirectory() { $this->filesystem->mkdir($this->workspace.DIRECTORY_SEPARATOR.'foo'); - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; - $this->pool->expects($this->once())->method('getContexts')->will($this->returnValue(array('foo' => $context))); + $this->pool->expects($this->once())->method('getContexts')->will($this->returnValue(['foo' => $context])); - $output = $this->tester->execute(array('command' => $this->command->getName())); + $output = $this->tester->execute(['command' => $this->command->getName()]); $this->assertRegExp('@Context: foo\s+done!@', $this->tester->getDisplay()); @@ -156,28 +156,28 @@ public function testExecuteFilesExists() $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'thumb_1_bar.ext'); - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; $provider = $this->getMockBuilder('Sonata\MediaBundle\Provider\FileProvider')->disableOriginalConstructor()->getMock(); $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue(array($provider))); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); $media = $this->getMockBuilder('Sonata\MediaBundle\Model\MediaInterface')->getMock(); $this->mediaManager->expects($this->once())->method('findOneBy') - ->with($this->equalTo(array('id' => 1, 'context' => 'foo'))) - ->will($this->returnValue(array($media))); + ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) + ->will($this->returnValue([$media])); $this->mediaManager->expects($this->once())->method('findBy') - ->with($this->equalTo(array('providerReference' => 'qwertz.ext', 'providerName' => array('fooprovider')))) - ->will($this->returnValue(array($media))); + ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) + ->will($this->returnValue([$media])); - $output = $this->tester->execute(array('command' => $this->command->getName())); + $output = $this->tester->execute(['command' => $this->command->getName()]); $this->assertRegExp('@Context: foo\s+done!@', $this->tester->getDisplay()); @@ -190,38 +190,38 @@ public function testExecuteFilesExistsVerbose() $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'thumb_1_bar.ext'); - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; $provider = $this->getMockBuilder('Sonata\MediaBundle\Provider\FileProvider')->disableOriginalConstructor()->getMock(); $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue(array($provider))); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); $media = $this->getMockBuilder('Sonata\MediaBundle\Model\MediaInterface')->getMock(); $this->mediaManager->expects($this->once())->method('findOneBy') - ->with($this->equalTo(array('id' => 1, 'context' => 'foo'))) - ->will($this->returnValue(array($media))); + ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) + ->will($this->returnValue([$media])); $this->mediaManager->expects($this->once())->method('findBy') - ->with($this->equalTo(array('providerReference' => 'qwertz.ext', 'providerName' => array('fooprovider')))) - ->will($this->returnValue(array($media))); + ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) + ->will($this->returnValue([$media])); $output = $this->tester->execute( - array('command' => $this->command->getName()), - array('verbosity' => OutputInterface::VERBOSITY_VERBOSE) + ['command' => $this->command->getName()], + ['verbosity' => OutputInterface::VERBOSITY_VERBOSE] ); $this->assertOutputFoundInContext( '/Context: foo\s+(.+)\s+done!/ms', - array( + [ '\'qwertz.ext\' found', '\'thumb_1_bar.ext\' found', - ), + ], $this->tester->getDisplay() ); $this->assertSame(0, $output); @@ -233,33 +233,33 @@ public function testExecuteDryRun() $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'thumb_1_bar.ext'); - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; $provider = $this->getMockBuilder('Sonata\MediaBundle\Provider\FileProvider')->disableOriginalConstructor()->getMock(); $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue(array($provider))); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); $this->mediaManager->expects($this->once())->method('findOneBy') - ->with($this->equalTo(array('id' => 1, 'context' => 'foo'))) - ->will($this->returnValue(array())); + ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) + ->will($this->returnValue([])); $this->mediaManager->expects($this->once())->method('findBy') - ->with($this->equalTo(array('providerReference' => 'qwertz.ext', 'providerName' => array('fooprovider')))) - ->will($this->returnValue(array())); + ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) + ->will($this->returnValue([])); - $output = $this->tester->execute(array('command' => $this->command->getName(), '--dry-run' => true)); + $output = $this->tester->execute(['command' => $this->command->getName(), '--dry-run' => true]); $this->assertOutputFoundInContext( '/Context: foo\s+(.+)\s+done!/ms', - array( + [ '\'qwertz.ext\' is orphanend', '\'thumb_1_bar.ext\' is orphanend', - ), + ], $this->tester->getDisplay() ); $this->assertSame(0, $output); @@ -271,33 +271,33 @@ public function testExecute() $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'thumb_1_bar.ext'); - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; $provider = $this->getMockBuilder('Sonata\MediaBundle\Provider\FileProvider')->disableOriginalConstructor()->getMock(); $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue(array($provider))); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); $this->mediaManager->expects($this->once())->method('findOneBy') - ->with($this->equalTo(array('id' => 1, 'context' => 'foo'))) - ->will($this->returnValue(array())); + ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) + ->will($this->returnValue([])); $this->mediaManager->expects($this->once())->method('findBy') - ->with($this->equalTo(array('providerReference' => 'qwertz.ext', 'providerName' => array('fooprovider')))) - ->will($this->returnValue(array())); + ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) + ->will($this->returnValue([])); - $output = $this->tester->execute(array('command' => $this->command->getName())); + $output = $this->tester->execute(['command' => $this->command->getName()]); $this->assertOutputFoundInContext( '/Context: foo\s+(.+)\s+done!/ms', - array( + [ '\'qwertz.ext\' was successfully removed', '\'thumb_1_bar.ext\' was successfully removed', - ), + ], $this->tester->getDisplay() ); $this->assertSame(0, $output); diff --git a/Tests/Command/FixMediaContextCommandTest.php b/Tests/Command/FixMediaContextCommandTest.php index 2695347192..ae63363694 100755 --- a/Tests/Command/FixMediaContextCommandTest.php +++ b/Tests/Command/FixMediaContextCommandTest.php @@ -98,31 +98,31 @@ public function testExecuteWithDisabledClassfication() $this->setExpectedException('\LogicException'); - $this->tester->execute(array('command' => $this->command->getName())); + $this->tester->execute(['command' => $this->command->getName()]); } public function testExecuteWithExisting() { - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) ->will($this->returnValue(true)); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); $contextModel = $this->getMockBuilder('Sonata\ClassificationBundle\Model\ContextInterface')->getMock(); - $this->contextManger->expects($this->once())->method('findOneBy')->with($this->equalTo(array('id' => 'foo')))->will($this->returnValue($contextModel)); + $this->contextManger->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->will($this->returnValue($contextModel)); $category = $this->getMockBuilder('Sonata\ClassificationBundle\Model\CategoryInterface')->getMock(); $this->categoryManger->expects($this->once())->method('getRootCategory')->with($this->equalTo($contextModel))->will($this->returnValue($category)); - $output = $this->tester->execute(array('command' => $this->command->getName())); + $output = $this->tester->execute(['command' => $this->command->getName()]); $this->assertRegExp('@Done!@', $this->tester->getDisplay()); @@ -131,20 +131,20 @@ public function testExecuteWithExisting() public function testExecuteWithEmptyRoot() { - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) ->will($this->returnValue(true)); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); $contextModel = $this->getMockBuilder('Sonata\ClassificationBundle\Model\ContextInterface')->getMock(); - $this->contextManger->expects($this->once())->method('findOneBy')->with($this->equalTo(array('id' => 'foo')))->will($this->returnValue($contextModel)); + $this->contextManger->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->will($this->returnValue($contextModel)); $category = $this->getMockBuilder('Sonata\ClassificationBundle\Model\CategoryInterface')->getMock(); @@ -152,7 +152,7 @@ public function testExecuteWithEmptyRoot() $this->categoryManger->expects($this->once())->method('create')->will($this->returnValue($category)); $this->categoryManger->expects($this->once())->method('save')->with($this->equalTo($category)); - $output = $this->tester->execute(array('command' => $this->command->getName())); + $output = $this->tester->execute(['command' => $this->command->getName()]); $this->assertRegExp('@ > default category for \'foo\' is missing, creating one\s+Done!@', $this->tester->getDisplay()); @@ -161,20 +161,20 @@ public function testExecuteWithEmptyRoot() public function testExecuteWithNew() { - $context = array( - 'providers' => array(), - 'formats' => array(), - 'download' => array(), - ); + $context = [ + 'providers' => [], + 'formats' => [], + 'download' => [], + ]; $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) ->will($this->returnValue(true)); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(array('foo' => $context))); + $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); $contextModel = $this->getMockBuilder('Sonata\ClassificationBundle\Model\ContextInterface')->getMock(); - $this->contextManger->expects($this->once())->method('findOneBy')->with($this->equalTo(array('id' => 'foo')))->will($this->returnValue(null)); + $this->contextManger->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->will($this->returnValue(null)); $this->contextManger->expects($this->once())->method('create')->will($this->returnValue($contextModel)); $this->contextManger->expects($this->once())->method('save')->with($this->equalTo($contextModel)); @@ -184,7 +184,7 @@ public function testExecuteWithNew() $this->categoryManger->expects($this->once())->method('create')->will($this->returnValue($category)); $this->categoryManger->expects($this->once())->method('save')->with($this->equalTo($category)); - $output = $this->tester->execute(array('command' => $this->command->getName())); + $output = $this->tester->execute(['command' => $this->command->getName()]); $this->assertRegExp('@ > default category for \'foo\' is missing, creating one\s+Done!@', $this->tester->getDisplay()); diff --git a/Tests/Controller/Api/GalleryControllerTest.php b/Tests/Controller/Api/GalleryControllerTest.php index 298097032c..b8370a10e0 100644 --- a/Tests/Controller/Api/GalleryControllerTest.php +++ b/Tests/Controller/Api/GalleryControllerTest.php @@ -44,7 +44,7 @@ public function testGetGalleriesAction() $mediaManager = $this->createMock('Sonata\MediaBundle\Model\MediaManagerInterface'); $formFactory = $this->createMock('Symfony\Component\Form\FormFactoryInterface'); - $galleryManager->expects($this->once())->method('getPager')->will($this->returnValue(array())); + $galleryManager->expects($this->once())->method('getPager')->will($this->returnValue([])); $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); @@ -55,13 +55,13 @@ public function testGetGalleriesAction() $paramFetcher ->expects($this->once()) ->method('all') - ->will($this->returnValue(array( + ->will($this->returnValue([ 'page' => 1, 'count' => 10, - 'orderBy' => array('id' => 'ASC'), - ))); + 'orderBy' => ['id' => 'ASC'], + ])); - $this->assertSame(array(), $gController->getGalleriesAction($paramFetcher)); + $this->assertSame([], $gController->getGalleriesAction($paramFetcher)); } public function testGetGalleryAction() @@ -103,7 +103,7 @@ public function testGetGalleryGalleryItemsAction() $gallery = $this->createMock('Sonata\MediaBundle\Model\GalleryInterface'); $formFactory = $this->createMock('Symfony\Component\Form\FormFactoryInterface'); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue(array($galleryItem))); + $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); @@ -111,7 +111,7 @@ public function testGetGalleryGalleryItemsAction() $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); - $this->assertSame(array($galleryItem), $gController->getGalleryGalleryItemAction(1)); + $this->assertSame([$galleryItem], $gController->getGalleryGalleryItemAction(1)); } public function testGetGalleryMediaAction() @@ -124,12 +124,12 @@ public function testGetGalleryMediaAction() $mediaManager = $this->createMock('Sonata\MediaBundle\Model\MediaManagerInterface'); $galleryItem->expects($this->once())->method('getMedia')->will($this->returnValue($media)); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue(array($galleryItem))); + $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); - $this->assertSame(array($media), $gController->getGalleryMediasAction(1)); + $this->assertSame([$media], $gController->getGalleryMediasAction(1)); } public function testPostGalleryMediaGalleryItemAction() @@ -143,7 +143,7 @@ public function testPostGalleryMediaGalleryItemAction() $media2->expects($this->any())->method('getId')->will($this->returnValue(1)); $galleryItem->expects($this->once())->method('getMedia')->will($this->returnValue($media2)); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue(array($galleryItem))); + $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); $mediaManager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); @@ -177,7 +177,7 @@ public function testPostGalleryMediaGalleryItemInvalidAction() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $galleryItem->expects($this->once())->method('getMedia')->will($this->returnValue($media)); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue(array($galleryItem))); + $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); $mediaManager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); @@ -205,7 +205,7 @@ public function testPutGalleryMediaGalleryItemAction() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $galleryItem->expects($this->once())->method('getMedia')->will($this->returnValue($media)); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue(array($galleryItem))); + $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); $mediaManager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); @@ -239,7 +239,7 @@ public function testPutGalleryMediaGalleryItemInvalidAction() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $galleryItem->expects($this->once())->method('getMedia')->will($this->returnValue($media)); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue(array($galleryItem))); + $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); $mediaManager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); @@ -274,7 +274,7 @@ public function testDeleteGalleryMediaGalleryItemAction() $gallery ->expects($this->any()) ->method('getGalleryItems') - ->will($this->returnValue(new ArrayCollection(array($galleryItem)))); + ->will($this->returnValue(new ArrayCollection([$galleryItem]))); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); $mediaManager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); @@ -288,7 +288,7 @@ public function testDeleteGalleryMediaGalleryItemAction() ); $view = $galleryController->deleteGalleryMediaGalleryItemAction(1, 1); - $this->assertSame(array('deleted' => true), $view); + $this->assertSame(['deleted' => true], $view); } public function testDeleteGalleryMediaGalleryItemInvalidAction() @@ -305,7 +305,7 @@ public function testDeleteGalleryMediaGalleryItemInvalidAction() $gallery ->expects($this->any()) ->method('getGalleryItems') - ->will($this->returnValue(new ArrayCollection(array($galleryItem)))); + ->will($this->returnValue(new ArrayCollection([$galleryItem]))); $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); $mediaManager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); diff --git a/Tests/Controller/Api/MediaControllerTest.php b/Tests/Controller/Api/MediaControllerTest.php index 6606c23769..361873b02a 100644 --- a/Tests/Controller/Api/MediaControllerTest.php +++ b/Tests/Controller/Api/MediaControllerTest.php @@ -25,7 +25,7 @@ public function testGetMediaAction() $mManager = $this->createMock('Sonata\MediaBundle\Model\MediaManagerInterface'); $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); - $mManager->expects($this->once())->method('getPager')->will($this->returnValue(array($media))); + $mManager->expects($this->once())->method('getPager')->will($this->returnValue([$media])); $mController = $this->createMediaController($mManager); @@ -33,9 +33,9 @@ public function testGetMediaAction() ->disableOriginalConstructor() ->getMock(); $paramFetcher->expects($this->exactly(3))->method('get'); - $paramFetcher->expects($this->once())->method('all')->will($this->returnValue(array())); + $paramFetcher->expects($this->once())->method('all')->will($this->returnValue([])); - $this->assertSame(array($media), $mController->getMediaAction($paramFetcher)); + $this->assertSame([$media], $mController->getMediaAction($paramFetcher)); } public function testGetMediumAction() @@ -67,28 +67,28 @@ public function testGetMediumFormatsAction() $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); $provider = $this->createMock('Sonata\MediaBundle\Provider\MediaProviderInterface'); - $provider->expects($this->exactly(2))->method('getHelperProperties')->will($this->returnValue(array('foo' => 'bar'))); + $provider->expects($this->exactly(2))->method('getHelperProperties')->will($this->returnValue(['foo' => 'bar'])); $pool = $this->getMockBuilder('Sonata\MediaBundle\Provider\Pool')->disableOriginalConstructor()->getMock(); $pool->expects($this->any())->method('getProvider')->will($this->returnValue($provider)); - $pool->expects($this->once())->method('getFormatNamesByContext')->will($this->returnValue(array('format_name1' => 'value1'))); + $pool->expects($this->once())->method('getFormatNamesByContext')->will($this->returnValue(['format_name1' => 'value1'])); $controller = $this->createMediaController($manager, $pool); - $expected = array( - 'reference' => array( + $expected = [ + 'reference' => [ 'url' => null, - 'properties' => array( + 'properties' => [ 'foo' => 'bar', - ), - ), - 'format_name1' => array( + ], + ], + 'format_name1' => [ 'url' => null, - 'properties' => array( + 'properties' => [ 'foo' => 'bar', - ), - ), - ); + ], + ], + ]; $this->assertSame($expected, $controller->getMediumFormatsAction(1)); } @@ -120,7 +120,7 @@ public function testDeleteMediumAction() $controller = $this->createMediaController($manager); - $expected = array('deleted' => true); + $expected = ['deleted' => true]; $this->assertSame($expected, $controller->deleteMediumAction(1)); } diff --git a/Tests/Controller/GalleryAdminControllerTest.php b/Tests/Controller/GalleryAdminControllerTest.php index 8645aafb07..94a421a781 100644 --- a/Tests/Controller/GalleryAdminControllerTest.php +++ b/Tests/Controller/GalleryAdminControllerTest.php @@ -125,7 +125,7 @@ private function configureRender($template, $data, $rendered) $templating = $this->prophesize('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); - $this->admin->getPersistentParameters()->willReturn(array('param' => 'param')); + $this->admin->getPersistentParameters()->willReturn(['param' => 'param']); $this->container->has('templating')->willReturn(true); $this->container->get('templating')->willReturn($templating->reveal()); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); diff --git a/Tests/Controller/MediaAdminControllerTest.php b/Tests/Controller/MediaAdminControllerTest.php index 9ce0834480..5cf237ce83 100644 --- a/Tests/Controller/MediaAdminControllerTest.php +++ b/Tests/Controller/MediaAdminControllerTest.php @@ -49,7 +49,7 @@ public function testCreateActionToSelectProvider() Argument::type('array'), 'renderResponse' ); - $pool->getProvidersByContext('context')->willReturn(array('provider')); + $pool->getProvidersByContext('context')->willReturn(['provider']); $pool->getDefaultContext()->willReturn('default_context'); $this->admin->checkAccess('create')->shouldBeCalled(); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); @@ -94,10 +94,10 @@ public function testListAction() $datagrid->getForm()->willReturn($form->reveal()); $pool->getDefaultContext()->willReturn('context'); $categoryManager->getRootCategory('another_context')->willReturn($category->reveal()); - $categoryManager->findOneBy(array( + $categoryManager->findOneBy([ 'id' => 2, 'context' => 'another_context', - ))->willReturn($category->reveal()); + ])->willReturn($category->reveal()); $category->getId()->willReturn(1); $form->createView()->willReturn($formView->reveal()); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); @@ -110,7 +110,7 @@ public function testListAction() $this->admin->getFilterTheme()->willReturn('filterTheme'); $this->admin->getTemplate('list')->willReturn('templateList'); $this->request->get('_list_mode', 'mosaic')->willReturn('mosaic'); - $this->request->get('filter')->willReturn(array()); + $this->request->get('filter')->willReturn([]); $this->request->get('category')->willReturn(2); $response = $this->controller->listAction($this->request->reveal()); @@ -202,7 +202,7 @@ private function configureRender($template, $data, $rendered) $templating = $this->prophesize('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); - $this->admin->getPersistentParameters()->willReturn(array('param' => 'param')); + $this->admin->getPersistentParameters()->willReturn(['param' => 'param']); $this->container->has('templating')->willReturn(true); $this->container->get('templating')->willReturn($templating->reveal()); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); diff --git a/Tests/Controller/MediaControllerTest.php b/Tests/Controller/MediaControllerTest.php index 91f7cf1628..b3ba271d4c 100644 --- a/Tests/Controller/MediaControllerTest.php +++ b/Tests/Controller/MediaControllerTest.php @@ -108,14 +108,14 @@ public function testViewActionRendersView() $this->configureGetMedia(1, $media->reveal()); $this->configureDownloadSecurity($pool, $media->reveal(), $request->reveal(), true); - $this->configureRender('SonataMediaBundle:Media:view.html.twig', array( + $this->configureRender('SonataMediaBundle:Media:view.html.twig', [ 'media' => $media->reveal(), - 'formats' => array('format'), + 'formats' => ['format'], 'format' => 'format', - ), 'renderResponse'); + ], 'renderResponse'); $this->container->get('sonata.media.pool')->willReturn($pool->reveal()); $media->getContext()->willReturn('context'); - $pool->getFormatNamesByContext('context')->willReturn(array('format')); + $pool->getFormatNamesByContext('context')->willReturn(['format']); $response = $this->controller->viewAction($request->reveal(), 1, 'format'); diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index e2631216d9..3ff624bf90 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -23,12 +23,12 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $configs = array( - 'sonata_media' => array( + $configs = [ + 'sonata_media' => [ 'db_driver' => 'doctrine_orm', 'default_context' => 'default', - ), - ); + ], + ]; $processor = new Processor(); $configuration = new Configuration(); $this->config = $processor->processConfiguration($configuration, $configs); diff --git a/Tests/DependencyInjection/SonataMediaExtensionTest.php b/Tests/DependencyInjection/SonataMediaExtensionTest.php index 48d0961d20..0e50439bab 100644 --- a/Tests/DependencyInjection/SonataMediaExtensionTest.php +++ b/Tests/DependencyInjection/SonataMediaExtensionTest.php @@ -24,30 +24,30 @@ protected function setUp() { parent::setUp(); - $this->container->setParameter('kernel.bundles', array('SonataAdminBundle' => true)); + $this->container->setParameter('kernel.bundles', ['SonataAdminBundle' => true]); } public function testLoadWithDefaultAndCustomCategoryManager() { - $this->load(array( - 'class' => array( + $this->load([ + 'class' => [ 'category' => '\stdClass', - ), + ], 'category_manager' => 'dummy.service.name', - )); + ]); $this->assertContainerBuilderHasAlias('sonata.media.manager.category', 'dummy.service.name'); } public function testLoadWithForceDisableTrueAndWithCategoryManager() { - $this->load(array( - 'class' => array( + $this->load([ + 'class' => [ 'category' => '\stdClass', - ), + ], 'category_manager' => 'dummy.service.name', 'force_disable_category' => true, - )); + ]); $this->assertContainerBuilderNotHasService('sonata.media.manager.category'); } @@ -65,21 +65,21 @@ public function testLoadWithDefaultAndClassificationBundleEnable() public function testLoadWithDefaultAndClassificationBundleEnableAndForceDisableCategory() { - $this->load(array( + $this->load([ 'force_disable_category' => true, - )); + ]); $this->assertContainerBuilderNotHasService('sonata.media.manager.category'); } public function testLoadWithDefaultAndClassificationBundleEnableAndCustomCategoryManager() { - $this->load(array( - 'class' => array( + $this->load([ + 'class' => [ 'category' => '\stdClass', - ), + ], 'category_manager' => 'dummy.service.name', - )); + ]); $this->assertContainerBuilderHasAlias('sonata.media.manager.category', 'dummy.service.name'); } @@ -110,11 +110,11 @@ public function testAdapter($serviceId, $extension, $type) public function dataAdapter() { - return array( - array('sonata.media.adapter.image.gd', 'gd', 'Imagine\\Gd\\Imagine'), - array('sonata.media.adapter.image.gmagick', 'gmagick', 'Imagine\\Gmagick\\Imagine'), - array('sonata.media.adapter.image.imagick', 'imagick', 'Imagine\\Imagick\\Imagine'), - ); + return [ + ['sonata.media.adapter.image.gd', 'gd', 'Imagine\\Gd\\Imagine'], + ['sonata.media.adapter.image.gmagick', 'gmagick', 'Imagine\\Gmagick\\Imagine'], + ['sonata.media.adapter.image.imagick', 'imagick', 'Imagine\\Imagick\\Imagine'], + ]; } public function testDefaultResizer() @@ -148,10 +148,10 @@ public function testResizer($serviceId, $type) public function dataResizer() { - return array( - array('sonata.media.resizer.simple', 'Sonata\\MediaBundle\\Resizer\\SimpleResizer'), - array('sonata.media.resizer.square', 'Sonata\\MediaBundle\\Resizer\\SquareResizer'), - ); + return [ + ['sonata.media.resizer.simple', 'Sonata\\MediaBundle\\Resizer\\SimpleResizer'], + ['sonata.media.resizer.square', 'Sonata\\MediaBundle\\Resizer\\SquareResizer'], + ]; } public function testLoadWithSonataAdminDefaults() @@ -160,14 +160,14 @@ public function testLoadWithSonataAdminDefaults() $this->assertEquals( $this->container->getDefinition('sonata.media.security.superadmin_strategy')->getArgument(2), - array('ROLE_ADMIN', 'ROLE_SUPER_ADMIN') + ['ROLE_ADMIN', 'ROLE_SUPER_ADMIN'] ); } public function testLoadWithSonataAdminCustomConfiguration() { $fakeContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder') - ->setMethods(array('getParameter', 'getExtensionConfig')) + ->setMethods(['getParameter', 'getExtensionConfig']) ->getMock(); $fakeContainer->expects($this->once()) @@ -178,14 +178,14 @@ public function testLoadWithSonataAdminCustomConfiguration() $fakeContainer->expects($this->once()) ->method('getExtensionConfig') ->with($this->equalTo('sonata_admin')) - ->willReturn(array(array( - 'security' => array( + ->willReturn([[ + 'security' => [ 'role_admin' => 'ROLE_FOO', 'role_super_admin' => 'ROLE_BAR', - ), - ))); + ], + ]]); - $configs = array($this->getMinimalConfiguration()); + $configs = [$this->getMinimalConfiguration()]; foreach ($this->getContainerExtensions() as $extension) { if ($extension instanceof PrependExtensionInterface) { $extension->prepend($fakeContainer); @@ -196,31 +196,31 @@ public function testLoadWithSonataAdminCustomConfiguration() $this->assertEquals( $this->container->getDefinition('sonata.media.security.superadmin_strategy')->getArgument(2), - array('ROLE_FOO', 'ROLE_BAR') + ['ROLE_FOO', 'ROLE_BAR'] ); } protected function getMinimalConfiguration() { - return array( + return [ 'default_context' => 'default', 'db_driver' => 'doctrine_orm', - 'contexts' => array( - 'default' => array( - 'formats' => array( - 'small' => array( + 'contexts' => [ + 'default' => [ + 'formats' => [ + 'small' => [ 'width' => 100, 'quality' => 50, - ), - ), - ), - ), - 'filesystem' => array( - 'local' => array( + ], + ], + ], + ], + 'filesystem' => [ + 'local' => [ 'directory' => '/tmp/', - ), - ), - ); + ], + ], + ]; } /** @@ -228,8 +228,8 @@ protected function getMinimalConfiguration() */ protected function getContainerExtensions() { - return array( + return [ new SonataMediaExtension(), - ); + ]; } } diff --git a/Tests/Document/MediaManagerTest.php b/Tests/Document/MediaManagerTest.php index fd20102b48..41dbadf7b0 100644 --- a/Tests/Document/MediaManagerTest.php +++ b/Tests/Document/MediaManagerTest.php @@ -67,7 +67,7 @@ public function testDeleteException() protected function createRegistryMock() { $dm = $this->getMockBuilder('Doctrine\ODM\MongoDB\DocumentManager') - ->setMethods(array('persist', 'flush')) + ->setMethods(['persist', 'flush']) ->disableOriginalConstructor() ->getMock(); $registry = $this->createMock('Doctrine\Common\Persistence\ManagerRegistry'); diff --git a/Tests/Entity/GalleryManagerTest.php b/Tests/Entity/GalleryManagerTest.php index 3f6e5b647b..1c6416b5f4 100644 --- a/Tests/Entity/GalleryManagerTest.php +++ b/Tests/Entity/GalleryManagerTest.php @@ -25,15 +25,15 @@ public function testGetPager() $self = $this; $this ->getGalleryManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->once())->method('orderBy')->with( $self->equalTo('g.name'), $self->equalTo('ASC') ); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array())); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo([])); }) - ->getPager(array(), 1); + ->getPager([], 1); } /** @@ -46,7 +46,7 @@ public function testGetPagerWithInvalidSort() $this ->getGalleryManager(function ($qb) use ($self) { }) - ->getPager(array(), 1, 10, array('invalid' => 'ASC')); + ->getPager([], 1, 10, ['invalid' => 'ASC']); } public function testGetPagerWithMultipleSort() @@ -54,7 +54,7 @@ public function testGetPagerWithMultipleSort() $self = $this; $this ->getGalleryManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->exactly(2))->method('orderBy')->with( $self->logicalOr( @@ -66,12 +66,12 @@ public function testGetPagerWithMultipleSort() $self->equalTo('DESC') ) ); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array())); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo([])); }) - ->getPager(array(), 1, 10, array( + ->getPager([], 1, 10, [ 'name' => 'ASC', 'context' => 'DESC', - )); + ]); } public function testGetPagerWithEnabledGalleries() @@ -79,11 +79,11 @@ public function testGetPagerWithEnabledGalleries() $self = $this; $this ->getGalleryManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('g.enabled = :enabled')); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array('enabled' => true))); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo(['enabled' => true])); }) - ->getPager(array('enabled' => true), 1); + ->getPager(['enabled' => true], 1); } public function testGetPagerWithNoEnabledGalleries() @@ -91,20 +91,20 @@ public function testGetPagerWithNoEnabledGalleries() $self = $this; $this ->getGalleryManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('g.enabled = :enabled')); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array('enabled' => false))); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo(['enabled' => false])); }) - ->getPager(array('enabled' => false), 1); + ->getPager(['enabled' => false], 1); } protected function getGalleryManager($qbCallback) { - $em = EntityManagerMockFactory::create($this, $qbCallback, array( + $em = EntityManagerMockFactory::create($this, $qbCallback, [ 'name', 'context', 'enabled', - )); + ]); $registry = $this->createMock('Doctrine\Common\Persistence\ManagerRegistry'); $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($em)); diff --git a/Tests/Entity/MediaManagerTest.php b/Tests/Entity/MediaManagerTest.php index 27a38fdc53..0e74abb5fd 100644 --- a/Tests/Entity/MediaManagerTest.php +++ b/Tests/Entity/MediaManagerTest.php @@ -25,11 +25,11 @@ public function testGetPager() $self = $this; $this ->getMediaManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->never())->method('andWhere'); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array())); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo([])); }) - ->getPager(array(), 1); + ->getPager([], 1); } /** @@ -42,7 +42,7 @@ public function testGetPagerWithInvalidSort() $this ->getMediaManager(function ($qb) use ($self) { }) - ->getPager(array(), 1, 10, array('invalid' => 'ASC')); + ->getPager([], 1, 10, ['invalid' => 'ASC']); } public function testGetPagerWithMultipleSort() @@ -50,7 +50,7 @@ public function testGetPagerWithMultipleSort() $self = $this; $this ->getMediaManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->exactly(2))->method('orderBy')->with( $self->logicalOr( @@ -62,12 +62,12 @@ public function testGetPagerWithMultipleSort() $self->equalTo('DESC') ) ); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array())); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo([])); }) - ->getPager(array(), 1, 10, array( + ->getPager([], 1, 10, [ 'name' => 'ASC', 'description' => 'DESC', - )); + ]); } public function testGetPagerWithEnabledMedia() @@ -75,11 +75,11 @@ public function testGetPagerWithEnabledMedia() $self = $this; $this ->getMediaManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('m.enabled = :enabled')); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array('enabled' => true))); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo(['enabled' => true])); }) - ->getPager(array('enabled' => true), 1); + ->getPager(['enabled' => true], 1); } public function testGetPagerWithNoEnabledMedias() @@ -87,20 +87,20 @@ public function testGetPagerWithNoEnabledMedias() $self = $this; $this ->getMediaManager(function ($qb) use ($self) { - $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(array('g'))); + $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('m.enabled = :enabled')); - $qb->expects($self->once())->method('setParameters')->with($self->equalTo(array('enabled' => false))); + $qb->expects($self->once())->method('setParameters')->with($self->equalTo(['enabled' => false])); }) - ->getPager(array('enabled' => false), 1); + ->getPager(['enabled' => false], 1); } protected function getMediaManager($qbCallback) { - $em = EntityManagerMockFactory::create($this, $qbCallback, array( + $em = EntityManagerMockFactory::create($this, $qbCallback, [ 'name', 'description', 'enabled', - )); + ]); $registry = $this->createMock('Doctrine\Common\Persistence\ManagerRegistry'); $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($em)); diff --git a/Tests/Entity/MediaTest.php b/Tests/Entity/MediaTest.php index 54ab90b15b..b90033f7fb 100644 --- a/Tests/Entity/MediaTest.php +++ b/Tests/Entity/MediaTest.php @@ -19,7 +19,7 @@ public function testMetadata() { $media = new Media(); - $media->setProviderMetadata(array('thumbnail_url' => 'http://pasloin.com/thumb.png')); + $media->setProviderMetadata(['thumbnail_url' => 'http://pasloin.com/thumb.png']); $this->assertSame($media->getMetadataValue('thumbnail_url'), 'http://pasloin.com/thumb.png', '::getMetadataValue() return the good value'); $this->assertSame($media->getMetadataValue('thumbnail_url1', 'default'), 'default', '::getMetadataValue() return the default'); diff --git a/Tests/Filesystem/ReplicateTest.php b/Tests/Filesystem/ReplicateTest.php index 7caf86efc5..3e8b8e965c 100644 --- a/Tests/Filesystem/ReplicateTest.php +++ b/Tests/Filesystem/ReplicateTest.php @@ -30,8 +30,8 @@ public function testReplicate() $slave->expects($this->once())->method('delete')->will($this->returnValue('master')); $replicate->delete('foo'); - $master->expects($this->once())->method('keys')->will($this->returnValue(array())); - $slave->expects($this->never())->method('keys')->will($this->returnValue(array())); + $master->expects($this->once())->method('keys')->will($this->returnValue([])); + $slave->expects($this->never())->method('keys')->will($this->returnValue([])); $this->assertInternalType('array', $replicate->keys()); $master->expects($this->once())->method('exists')->will($this->returnValue(true)); diff --git a/Tests/Form/DataTransformer/ProviderDataTransformerTest.php b/Tests/Form/DataTransformer/ProviderDataTransformerTest.php index 3b02f62928..3044a8564a 100644 --- a/Tests/Form/DataTransformer/ProviderDataTransformerTest.php +++ b/Tests/Form/DataTransformer/ProviderDataTransformerTest.php @@ -39,9 +39,9 @@ public function testReverseTransformUnknownProvider() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue('xcs')); - $transformer = new ProviderDataTransformer($pool, 'stdClass', array( + $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, - )); + ]); $transformer->reverseTransform($media); } @@ -58,9 +58,9 @@ public function testReverseTransformValidProvider() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue('xcs')); - $transformer = new ProviderDataTransformer($pool, 'stdClass', array( + $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, - )); + ]); $transformer->reverseTransform($media); } @@ -78,10 +78,10 @@ public function testReverseTransformWithNewMediaAndNoBinaryContent() $media->expects($this->once())->method('setProviderReference')->with(MediaInterface::MISSING_BINARY_REFERENCE); $media->expects($this->once())->method('setProviderStatus')->with(MediaInterface::STATUS_PENDING); - $transformer = new ProviderDataTransformer($pool, 'stdClass', array( + $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, 'empty_on_new' => false, - )); + ]); $this->assertSame($media, $transformer->reverseTransform($media)); } @@ -112,9 +112,9 @@ public function testReverseTransformWithMediaAndUploadFileInstance() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); - $transformer = new ProviderDataTransformer($pool, 'stdClass', array( + $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, - )); + ]); $transformer->reverseTransform($media); } @@ -131,9 +131,9 @@ public function testReverseTransformWithThrowingProviderNoThrow() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); - $transformer = new ProviderDataTransformer($pool, 'stdClass', array( + $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, - )); + ]); $transformer->reverseTransform($media); } @@ -153,9 +153,9 @@ public function testReverseTransformWithThrowingProviderLogsException() $media->expects($this->any())->method('getId')->will($this->returnValue(1)); $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); - $transformer = new ProviderDataTransformer($pool, 'stdClass', array( + $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, - )); + ]); $transformer->setLogger($logger); $transformer->reverseTransform($media); } diff --git a/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php b/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php index cd959535eb..87a531dba5 100644 --- a/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php +++ b/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php @@ -71,7 +71,7 @@ public function testReverseTransformWithThrowingProviderLogsException() $logger = $this->prophesize('Psr\Log\LoggerInterface'); $logger->error( Argument::containingString('Caught Exception Exception: "foo" at'), - Argument::is(array('exception' => $exception)) + Argument::is(['exception' => $exception]) )->shouldBeCalled(); $transformer = new ServiceProviderDataTransformer($provider->reveal()); diff --git a/Tests/Form/Type/AbstractTypeTest.php b/Tests/Form/Type/AbstractTypeTest.php index 26085ad01f..cdf3975b20 100644 --- a/Tests/Form/Type/AbstractTypeTest.php +++ b/Tests/Form/Type/AbstractTypeTest.php @@ -63,13 +63,13 @@ protected function setUp() public function testBuildForm() { - $this->formType->buildForm($this->formBuilder, array( + $this->formType->buildForm($this->formBuilder, [ 'provider_name' => 'sonata.media.provider.image', 'provider' => null, 'context' => null, 'empty_on_new' => true, 'new_on_update' => true, - )); + ]); } public function testGetParent() diff --git a/Tests/Form/Type/ApiMediaTypeTest.php b/Tests/Form/Type/ApiMediaTypeTest.php index fb5ed98985..1dc01b3d87 100644 --- a/Tests/Form/Type/ApiMediaTypeTest.php +++ b/Tests/Form/Type/ApiMediaTypeTest.php @@ -31,7 +31,7 @@ public function testBuildForm() $builder = $this->getMockBuilder('Symfony\Component\Form\FormBuilder')->disableOriginalConstructor()->getMock(); $builder->expects($this->once())->method('addModelTransformer'); - $type->buildForm($builder, array('provider_name' => 'sonata.media.provider.image')); + $type->buildForm($builder, ['provider_name' => 'sonata.media.provider.image']); } protected function getTestedInstance() diff --git a/Tests/Form/Type/MediaTypeTest.php b/Tests/Form/Type/MediaTypeTest.php index fb0bff68dd..b2f4538cd3 100644 --- a/Tests/Form/Type/MediaTypeTest.php +++ b/Tests/Form/Type/MediaTypeTest.php @@ -42,14 +42,14 @@ protected function setUp() public function testMissingFormOptions() { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue(array( + $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ))); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue(array( - 'video' => array(), - 'pic' => array(), - ))); + ])); + $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + 'video' => [], + 'pic' => [], + ])); $this->setExpectedException( 'Symfony\Component\OptionsResolver\Exception\MissingOptionsException', @@ -61,82 +61,82 @@ public function testMissingFormOptions() public function testMissingFormContextOption() { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue(array( + $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ))); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue(array( - 'video' => array(), - 'pic' => array(), - ))); + ])); + $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + 'video' => [], + 'pic' => [], + ])); $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); - $this->factory->create($this->getFormType(), null, array( + $this->factory->create($this->getFormType(), null, [ 'provider' => 'provider_a', - )); + ]); } public function testMissingFormProviderOption() { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue(array( + $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ))); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue(array( - 'video' => array(), - 'pic' => array(), - ))); + ])); + $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + 'video' => [], + 'pic' => [], + ])); $this->setExpectedException('Symfony\Component\OptionsResolver\Exception\MissingOptionsException'); - $this->factory->create($this->getFormType(), null, array( + $this->factory->create($this->getFormType(), null, [ 'context' => 'pic', - )); + ]); } public function testInvalidFormProviderOption() { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue(array( + $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ))); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue(array( - 'video' => array(), - 'pic' => array(), - ))); + ])); + $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + 'video' => [], + 'pic' => [], + ])); $this->setExpectedException( 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', 'The option "provider" with value "provider_c" is invalid. Accepted values are: "provider_a", "provider_b".' ); - $this->factory->create($this->getFormType(), null, array( + $this->factory->create($this->getFormType(), null, [ 'provider' => 'provider_c', 'context' => 'pic', - )); + ]); } public function testInvalidFormContextOption() { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue(array( + $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ))); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue(array( - 'video' => array(), - 'pic' => array(), - ))); + ])); + $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + 'video' => [], + 'pic' => [], + ])); $this->setExpectedException( 'Symfony\Component\OptionsResolver\Exception\InvalidOptionsException', 'The option "context" with value "photo" is invalid. Accepted values are: "video", "pic".' ); - $this->factory->create($this->getFormType(), null, array( + $this->factory->create($this->getFormType(), null, [ 'provider' => 'provider_b', 'context' => 'photo', - )); + ]); } protected function getTestedInstance() diff --git a/Tests/Listener/ORM/MediaEventSubscriberTest.php b/Tests/Listener/ORM/MediaEventSubscriberTest.php index ed11f5ce41..588de91262 100644 --- a/Tests/Listener/ORM/MediaEventSubscriberTest.php +++ b/Tests/Listener/ORM/MediaEventSubscriberTest.php @@ -32,20 +32,20 @@ public function testRefetchCategoriesAfterClear() $provider = $this->createMock('Sonata\\MediaBundle\\Provider\\MediaProviderInterface'); $pool = $this->getMockBuilder('Sonata\\MediaBundle\\Provider\\Pool') - ->setMethods(array('getProvider')) - ->setConstructorArgs(array('default')) + ->setMethods(['getProvider']) + ->setConstructorArgs(['default']) ->getMock(); - $pool->method('getProvider')->will($this->returnValueMap(array(array('provider', $provider)))); + $pool->method('getProvider')->will($this->returnValueMap([['provider', $provider]])); $category = $this->createMock('Sonata\\ClassificationBundle\\Model\\CategoryInterface'); $catManager = $this->createMock('Sonata\\MediaBundle\\Model\\CategoryManagerInterface'); $container = $this->createMock('Symfony\\Component\\DependencyInjection\\ContainerInterface'); - $container->method('get')->will($this->returnValueMap(array( - array('sonata.media.pool', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $pool), - array('sonata.media.manager.category', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $catManager), - ))); + $container->method('get')->will($this->returnValueMap([ + ['sonata.media.pool', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $pool], + ['sonata.media.manager.category', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $catManager], + ])); $container->method('has') ->with($this->equalTo('sonata.media.manager.category')) @@ -53,20 +53,20 @@ public function testRefetchCategoriesAfterClear() $catManager->expects($this->exactly(2)) ->method('getRootCategories') - ->willReturn(array('context' => $category)); + ->willReturn(['context' => $category]); $subscriber = new MediaEventSubscriber($container); $this->assertContains(Events::onClear, $subscriber->getSubscribedEvents()); $media1 = $this->getMockBuilder('Sonata\\MediaBundle\\Model\\Media') - ->setMethods(array('getId', 'getCategory', 'getProvider', 'getContext')) + ->setMethods(['getId', 'getCategory', 'getProvider', 'getContext']) ->getMock(); $media1->method('getProvider')->willReturn('provider'); $media1->method('getContext')->willReturn('context'); $args1 = $this->getMockBuilder('Doctrine\\Common\\EventArgs') - ->setMethods(array('getEntity')) + ->setMethods(['getEntity']) ->getMock(); $args1->method('getEntity')->willReturn($media1); @@ -75,13 +75,13 @@ public function testRefetchCategoriesAfterClear() $subscriber->onClear(); $media2 = $this->getMockBuilder('Sonata\\MediaBundle\\Model\\Media') - ->setMethods(array('getId', 'getCategory', 'getProvider', 'getContext')) + ->setMethods(['getId', 'getCategory', 'getProvider', 'getContext']) ->getMock(); $media2->method('getProvider')->willReturn('provider'); $media2->method('getContext')->willReturn('context'); $args2 = $this->getMockBuilder('Doctrine\\Common\\EventArgs') - ->setMethods(array('getEntity')) + ->setMethods(['getEntity']) ->getMock(); $args2->method('getEntity')->willReturn($media2); diff --git a/Tests/Metadata/AmazonMetadataBuilderTest.php b/Tests/Metadata/AmazonMetadataBuilderTest.php index bf3aa4e2c9..647eb9eae3 100644 --- a/Tests/Metadata/AmazonMetadataBuilderTest.php +++ b/Tests/Metadata/AmazonMetadataBuilderTest.php @@ -34,19 +34,19 @@ public function testAmazon() */ public function provider() { - return array( - array(array('acl' => 'private'), array('ACL' => AmazonMetadataBuilder::PRIVATE_ACCESS, 'contentType' => 'image/png')), - array(array('acl' => 'public'), array('ACL' => AmazonMetadataBuilder::PUBLIC_READ, 'contentType' => 'image/png')), - array(array('acl' => 'open'), array('ACL' => AmazonMetadataBuilder::PUBLIC_READ_WRITE, 'contentType' => 'image/png')), - array(array('acl' => 'auth_read'), array('ACL' => AmazonMetadataBuilder::AUTHENTICATED_READ, 'contentType' => 'image/png')), - array(array('acl' => 'owner_read'), array('ACL' => AmazonMetadataBuilder::BUCKET_OWNER_READ, 'contentType' => 'image/png')), - array(array('acl' => 'owner_full_control'), array('ACL' => AmazonMetadataBuilder::BUCKET_OWNER_FULL_CONTROL, 'contentType' => 'image/png')), - array(array('storage' => 'standard'), array('storage' => AmazonMetadataBuilder::STORAGE_STANDARD, 'contentType' => 'image/png')), - array(array('storage' => 'reduced'), array('storage' => AmazonMetadataBuilder::STORAGE_REDUCED, 'contentType' => 'image/png')), - array(array('cache_control' => 'max-age=86400'), array('CacheControl' => 'max-age=86400', 'contentType' => 'image/png')), - array(array('encryption' => 'aes256'), array('encryption' => 'AES256', 'contentType' => 'image/png')), - array(array('meta' => array('key' => 'value')), array('meta' => array('key' => 'value'), 'contentType' => 'image/png')), - array(array('acl' => 'public', 'storage' => 'standard', 'cache_control' => 'max-age=86400', 'encryption' => 'aes256', 'meta' => array('key' => 'value')), array('ACL' => AmazonMetadataBuilder::PUBLIC_READ, 'storage' => Storage::STANDARD, 'meta' => array('key' => 'value'), 'CacheControl' => 'max-age=86400', 'encryption' => 'AES256', 'contentType' => 'image/png')), - ); + return [ + [['acl' => 'private'], ['ACL' => AmazonMetadataBuilder::PRIVATE_ACCESS, 'contentType' => 'image/png']], + [['acl' => 'public'], ['ACL' => AmazonMetadataBuilder::PUBLIC_READ, 'contentType' => 'image/png']], + [['acl' => 'open'], ['ACL' => AmazonMetadataBuilder::PUBLIC_READ_WRITE, 'contentType' => 'image/png']], + [['acl' => 'auth_read'], ['ACL' => AmazonMetadataBuilder::AUTHENTICATED_READ, 'contentType' => 'image/png']], + [['acl' => 'owner_read'], ['ACL' => AmazonMetadataBuilder::BUCKET_OWNER_READ, 'contentType' => 'image/png']], + [['acl' => 'owner_full_control'], ['ACL' => AmazonMetadataBuilder::BUCKET_OWNER_FULL_CONTROL, 'contentType' => 'image/png']], + [['storage' => 'standard'], ['storage' => AmazonMetadataBuilder::STORAGE_STANDARD, 'contentType' => 'image/png']], + [['storage' => 'reduced'], ['storage' => AmazonMetadataBuilder::STORAGE_REDUCED, 'contentType' => 'image/png']], + [['cache_control' => 'max-age=86400'], ['CacheControl' => 'max-age=86400', 'contentType' => 'image/png']], + [['encryption' => 'aes256'], ['encryption' => 'AES256', 'contentType' => 'image/png']], + [['meta' => ['key' => 'value']], ['meta' => ['key' => 'value'], 'contentType' => 'image/png']], + [['acl' => 'public', 'storage' => 'standard', 'cache_control' => 'max-age=86400', 'encryption' => 'aes256', 'meta' => ['key' => 'value']], ['ACL' => AmazonMetadataBuilder::PUBLIC_READ, 'storage' => Storage::STANDARD, 'meta' => ['key' => 'value'], 'CacheControl' => 'max-age=86400', 'encryption' => 'AES256', 'contentType' => 'image/png']], + ]; } } diff --git a/Tests/Metadata/NoopMetadataBuilderTest.php b/Tests/Metadata/NoopMetadataBuilderTest.php index 953c4f98cf..a21d8a0464 100644 --- a/Tests/Metadata/NoopMetadataBuilderTest.php +++ b/Tests/Metadata/NoopMetadataBuilderTest.php @@ -23,6 +23,6 @@ public function testNoop() $noopmetadatabuilder = new NoopMetadataBuilder(); - $this->assertSame(array(), $noopmetadatabuilder->get($media, $filename)); + $this->assertSame([], $noopmetadatabuilder->get($media, $filename)); } } diff --git a/Tests/Metadata/ProxyMetadataBuilderTest.php b/Tests/Metadata/ProxyMetadataBuilderTest.php index 0d27ecf975..577ebd2bec 100644 --- a/Tests/Metadata/ProxyMetadataBuilderTest.php +++ b/Tests/Metadata/ProxyMetadataBuilderTest.php @@ -25,15 +25,15 @@ public function testProxyAmazon() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key' => 'amazon'))); + ->will($this->returnValue(['key' => 'amazon'])); $noop = $this->createMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key' => 'noop'))); + ->will($this->returnValue(['key' => 'noop'])); //adapter cannot be mocked - $amazonclient = new AmazonClient(array('key' => 'XXXXXXXXXXXX', 'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')); + $amazonclient = new AmazonClient(['key' => 'XXXXXXXXXXXX', 'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']); $adapter = new AmazonS3($amazonclient, ''); $filesystem = $this->getMockBuilder('Gaufrette\Filesystem')->disableOriginalConstructor()->getMock(); @@ -49,15 +49,15 @@ public function testProxyAmazon() $filename = '/test/folder/testfile.png'; - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, 'sonata.media.provider.image' => $provider, - )); + ]); $proxymetadatabuilder = new ProxyMetadataBuilder($container); - $this->assertSame(array('key' => 'amazon'), $proxymetadatabuilder->get($media, $filename)); + $this->assertSame(['key' => 'amazon'], $proxymetadatabuilder->get($media, $filename)); } public function testProxyLocal() @@ -65,12 +65,12 @@ public function testProxyLocal() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key' => 'amazon'))); + ->will($this->returnValue(['key' => 'amazon'])); $noop = $this->createMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key' => 'noop'))); + ->will($this->returnValue(['key' => 'noop'])); //adapter cannot be mocked $adapter = new Local(''); @@ -88,15 +88,15 @@ public function testProxyLocal() $filename = '/test/folder/testfile.png'; - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, 'sonata.media.provider.image' => $provider, - )); + ]); $proxymetadatabuilder = new ProxyMetadataBuilder($container); - $this->assertSame(array('key' => 'noop'), $proxymetadatabuilder->get($media, $filename)); + $this->assertSame(['key' => 'noop'], $proxymetadatabuilder->get($media, $filename)); } public function testProxyNoProvider() @@ -104,12 +104,12 @@ public function testProxyNoProvider() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key' => 'amazon'))); + ->will($this->returnValue(['key' => 'amazon'])); $noop = $this->createMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key' => 'noop'))); + ->will($this->returnValue(['key' => 'noop'])); //adapter cannot be mocked $adapter = new Local(''); @@ -127,15 +127,15 @@ public function testProxyNoProvider() $filename = '/test/folder/testfile.png'; - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, 'sonata.media.provider.image' => $provider, - )); + ]); $proxymetadatabuilder = new ProxyMetadataBuilder($container); - $this->assertSame(array(), $proxymetadatabuilder->get($media, $filename)); + $this->assertSame([], $proxymetadatabuilder->get($media, $filename)); } public function testProxyReplicateWithAmazon() @@ -143,15 +143,15 @@ public function testProxyReplicateWithAmazon() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key' => 'amazon'))); + ->will($this->returnValue(['key' => 'amazon'])); $noop = $this->createMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key' => 'noop'))); + ->will($this->returnValue(['key' => 'noop'])); //adapter cannot be mocked - $amazonclient = new AmazonClient(array('key' => 'XXXXXXXXXXXX', 'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')); + $amazonclient = new AmazonClient(['key' => 'XXXXXXXXXXXX', 'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX']); $adapter1 = new AmazonS3($amazonclient, ''); $adapter2 = new Local(''); $adapter = new Replicate($adapter1, $adapter2); @@ -169,15 +169,15 @@ public function testProxyReplicateWithAmazon() $filename = '/test/folder/testfile.png'; - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, 'sonata.media.provider.image' => $provider, - )); + ]); $proxymetadatabuilder = new ProxyMetadataBuilder($container); - $this->assertSame(array('key' => 'amazon'), $proxymetadatabuilder->get($media, $filename)); + $this->assertSame(['key' => 'amazon'], $proxymetadatabuilder->get($media, $filename)); } public function testProxyReplicateWithoutAmazon() @@ -185,12 +185,12 @@ public function testProxyReplicateWithoutAmazon() $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(array('key' => 'amazon'))); + ->will($this->returnValue(['key' => 'amazon'])); $noop = $this->createMock('Sonata\MediaBundle\Metadata\NoopMetadataBuilder'); $noop->expects($this->once()) ->method('get') - ->will($this->returnValue(array('key' => 'noop'))); + ->will($this->returnValue(['key' => 'noop'])); //adapter cannot be mocked $adapter1 = new Local(''); @@ -210,15 +210,15 @@ public function testProxyReplicateWithoutAmazon() $filename = '/test/folder/testfile.png'; - $container = $this->getContainerMock(array( + $container = $this->getContainerMock([ 'sonata.media.metadata.noop' => $noop, 'sonata.media.metadata.amazon' => $amazon, 'sonata.media.provider.image' => $provider, - )); + ]); $proxymetadatabuilder = new ProxyMetadataBuilder($container); - $this->assertSame(array('key' => 'noop'), $proxymetadatabuilder->get($media, $filename)); + $this->assertSame(['key' => 'noop'], $proxymetadatabuilder->get($media, $filename)); } /** diff --git a/Tests/Model/MediaTest.php b/Tests/Model/MediaTest.php index b0720ce03f..2a91e1a88b 100644 --- a/Tests/Model/MediaTest.php +++ b/Tests/Model/MediaTest.php @@ -23,12 +23,12 @@ public function testSetMetadataValue() $this->assertArrayHasKey('name', $metadata, 'name metadata should be stored in the empty array'); $this->assertSame('value', $metadata['name'], 'the string value should be returned'); - $cropData = array( + $cropData = [ 'x' => 10, 'y' => 20, 'width' => 500, 'height' => 500, - ); + ]; $media->setMetadataValue('crop', $cropData); $metadata = $metadataProperty->getValue($media); $this->assertArrayHasKey('crop', $metadata, 'crop should be stored in the existing array'); diff --git a/Tests/PHPCR/MediaManagerTest.php b/Tests/PHPCR/MediaManagerTest.php index a0b124bc73..66a4b8ab72 100644 --- a/Tests/PHPCR/MediaManagerTest.php +++ b/Tests/PHPCR/MediaManagerTest.php @@ -67,7 +67,7 @@ public function testDeleteException() protected function createRegistryMock() { $dm = $this->getMockBuilder('Doctrine\ODM\PHPCR\DocumentManager') - ->setMethods(array('persist', 'flush')) + ->setMethods(['persist', 'flush']) ->disableOriginalConstructor() ->getMock(); $registry = $this->createMock('Doctrine\Common\Persistence\ManagerRegistry'); diff --git a/Tests/Provider/BaseProviderTest.php b/Tests/Provider/BaseProviderTest.php index 63f7907d45..d2a3848805 100644 --- a/Tests/Provider/BaseProviderTest.php +++ b/Tests/Provider/BaseProviderTest.php @@ -24,11 +24,11 @@ public function getProvider() $adapter = $this->createMock('Gaufrette\Adapter'); $filesystem = $this->getMockBuilder('Gaufrette\Filesystem') - ->setMethods(array('get')) - ->setConstructorArgs(array($adapter)) + ->setMethods(['get']) + ->setConstructorArgs([$adapter]) ->getMock(); $file = $this->getMockBuilder('Gaufrette\File') - ->setConstructorArgs(array('foo', $filesystem)) + ->setConstructorArgs(['foo', $filesystem]) ->getMock(); $filesystem->expects($this->any()) @@ -51,16 +51,16 @@ public function getProvider() public function testBaseProvider() { $provider = $this->getProvider(); - $provider->setTemplates(array( + $provider->setTemplates([ 'edit' => 'edit.twig', - )); + ]); $this->assertInternalType('array', $provider->getTemplates()); $this->assertSame('edit.twig', $provider->getTemplate('edit')); $this->assertInstanceOf('\Sonata\MediaBundle\CDN\CDNInterface', $provider->getCdn()); - $provider->addFormat('small', array()); + $provider->addFormat('small', []); $this->assertInternalType('array', $provider->getFormat('small')); @@ -96,7 +96,7 @@ class TestProvider extends BaseProvider /** * {@inheritdoc} */ - public function getHelperProperties(MediaInterface $media, $format, $options = array()) + public function getHelperProperties(MediaInterface $media, $format, $options = []) { // TODO: Implement getHelperProperties() method. } @@ -200,7 +200,7 @@ public function prePersist(MediaInterface $media) /** * {@inheritdoc} */ - public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array()) + public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { // TODO: Implement getDownloadResponse() method. } diff --git a/Tests/Provider/DailyMotionProviderTest.php b/Tests/Provider/DailyMotionProviderTest.php index c2970fdab3..6a0c8cf953 100644 --- a/Tests/Provider/DailyMotionProviderTest.php +++ b/Tests/Provider/DailyMotionProviderTest.php @@ -33,11 +33,11 @@ public function getProvider(Browser $browser = null) $adapter = $this->createMock('Gaufrette\Adapter'); $filesystem = $this->getMockBuilder('Gaufrette\Filesystem') - ->setMethods(array('get')) - ->setConstructorArgs(array($adapter)) + ->setMethods(['get']) + ->setConstructorArgs([$adapter]) ->getMock(); $file = $this->getMockBuilder('Gaufrette\File') - ->setConstructorArgs(array('foo', $filesystem)) + ->setConstructorArgs(['foo', $filesystem]) ->getMock(); $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); @@ -96,7 +96,7 @@ public function testThumbnail() $this->assertTrue($provider->requireThumbnails($media)); - $provider->addFormat('big', array('width' => 200, 'height' => null, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => null, 'constraint' => true]); $this->assertNotEmpty($provider->getFormats(), '::getFormats() return an array'); @@ -115,7 +115,7 @@ public function testTransformWithSig() $provider = $this->getProvider($browser); - $provider->addFormat('big', array('width' => 200, 'height' => null, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => null, 'constraint' => true]); $media = new Media(); $media->setBinaryContent('x9wjql'); @@ -138,7 +138,7 @@ public function testTransformWithUrl() $provider = $this->getProvider($browser); - $provider->addFormat('big', array('width' => 200, 'height' => null, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => null, 'constraint' => true]); $media = new Media(); $media->setBinaryContent('http://www.dailymotion.com/video/x9wjql_asdasdasdsa_asdsds'); @@ -161,7 +161,7 @@ public function testForm() ->will($this->returnValue('message')); $formMapper = $this->getMockBuilder('Sonata\AdminBundle\Form\FormMapper') - ->setMethods(array('add', 'getAdmin')) + ->setMethods(['add', 'getAdmin']) ->disableOriginalConstructor() ->getMock(); $formMapper->expects($this->exactly(8)) @@ -177,7 +177,7 @@ public function testHelperProperies() { $provider = $this->getProvider(); - $provider->addFormat('admin', array('width' => 100)); + $provider->addFormat('admin', ['width' => 100]); $media = new Media(); $media->setName('Les tests'); $media->setProviderReference('ASDASDAS.png'); diff --git a/Tests/Provider/FakeHttpWrapper.php b/Tests/Provider/FakeHttpWrapper.php index 9669ecf73a..b2b3293cd9 100644 --- a/Tests/Provider/FakeHttpWrapper.php +++ b/Tests/Provider/FakeHttpWrapper.php @@ -13,7 +13,7 @@ class FakeHttpWrapper { - public static $ref = array( + public static $ref = [ // youtube content 'http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=BDYAbAtaDzA&format=json' => 'valide_youtube.txt', 'http://i3.ytimg.com/vi/BDYAbAtaDzA/hqdefault.jpg' => 'logo.jpg', @@ -25,7 +25,7 @@ class FakeHttpWrapper // vimeo content 'http://vimeo.com/api/oembed.json?url=http://vimeo.com/BDYAbAtaDzA' => 'valide_vimeo.txt', 'http://b.vimeocdn.com/ts/136/375/136375440_1280.jpg' => 'logo.jpg', - ); + ]; /* Properties */ public $context; diff --git a/Tests/Provider/FileProviderTest.php b/Tests/Provider/FileProviderTest.php index 7121fcbba4..feab207c9b 100644 --- a/Tests/Provider/FileProviderTest.php +++ b/Tests/Provider/FileProviderTest.php @@ -28,11 +28,11 @@ public function getProvider() $adapter->expects($this->any())->method('getDirectory')->will($this->returnValue(realpath(__DIR__).'/../fixtures')); $filesystem = $this->getMockBuilder('Gaufrette\Filesystem') - ->setMethods(array('get')) - ->setConstructorArgs(array($adapter)) + ->setMethods(['get']) + ->setConstructorArgs([$adapter]) ->getMock(); $file = $this->getMockBuilder('Gaufrette\File') - ->setConstructorArgs(array('foo', $filesystem)) + ->setConstructorArgs(['foo', $filesystem]) ->getMock(); $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); @@ -44,7 +44,7 @@ public function getProvider() $metadata = $this->createMock('Sonata\MediaBundle\Metadata\MetadataBuilderInterface'); - $provider = new FileProvider('file', $filesystem, $cdn, $generator, $thumbnail, array('txt'), array('foo/bar'), $metadata); + $provider = new FileProvider('file', $filesystem, $cdn, $generator, $thumbnail, ['txt'], ['foo/bar'], $metadata); $provider->setResizer($resizer); return $provider; @@ -72,7 +72,7 @@ public function testHelperProperies() { $provider = $this->getProvider(); - $provider->addFormat('admin', array('width' => 100)); + $provider->addFormat('admin', ['width' => 100]); $media = new Media(); $media->setName('test.png'); $media->setProviderReference('ASDASDAS.png'); @@ -95,7 +95,7 @@ public function testForm() ->will($this->returnValue('message')); $formMapper = $this->getMockBuilder('Sonata\AdminBundle\Form\FormMapper') - ->setMethods(array('add', 'getAdmin')) + ->setMethods(['add', 'getAdmin']) ->disableOriginalConstructor() ->getMock(); $formMapper->expects($this->exactly(8)) @@ -121,7 +121,7 @@ public function testEvent() { $provider = $this->getProvider(); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $file = __DIR__.'/../fixtures/file.txt'; @@ -205,7 +205,7 @@ public function mediaProvider() { $file = new \Symfony\Component\HttpFoundation\File\File(realpath(__DIR__.'/../fixtures/file.txt')); $content = file_get_contents(realpath(__DIR__.'/../fixtures/file.txt')); - $request = new Request(array(), array(), array(), array(), array(), array(), $content); + $request = new Request([], [], [], [], [], [], $content); $media1 = new Media(); $media1->setBinaryContent($file); @@ -221,12 +221,12 @@ public function mediaProvider() $media3->setBinaryContent($request); $media3->setId(1023456); - return array( - array('\Symfony\Component\HttpFoundation\File\File', $media1, false), - array('\Symfony\Component\HttpFoundation\File\File', $media1), - array('\Symfony\Component\HttpFoundation\File\File', $media2), - array(null, $media3), - ); + return [ + ['\Symfony\Component\HttpFoundation\File\File', $media1, false], + ['\Symfony\Component\HttpFoundation\File\File', $media1], + ['\Symfony\Component\HttpFoundation\File\File', $media2], + [null, $media3], + ]; } /** @@ -251,7 +251,7 @@ public function testBinaryContentWithRealPath() ->willReturn('context'); $binaryContent = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->setMethods(array('getRealPath', 'getPathname')) + ->setMethods(['getRealPath', 'getPathname']) ->disableOriginalConstructor() ->getMock(); @@ -296,7 +296,7 @@ public function testBinaryContentStreamWrapped() ->willReturn('context'); $binaryContent = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File') - ->setMethods(array('getRealPath', 'getPathname')) + ->setMethods(['getRealPath', 'getPathname']) ->disableOriginalConstructor() ->getMock(); @@ -346,7 +346,7 @@ public function testValidateUploadSize() ->will($this->returnSelf()); $upload = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array(tempnam(sys_get_temp_dir(), ''), 'dummy')) + ->setConstructorArgs([tempnam(sys_get_temp_dir(), ''), 'dummy']) ->getMock(); $upload->expects($this->any())->method('getClientSize') ->will($this->returnValue(0)); @@ -372,13 +372,13 @@ public function testValidateUploadType() $errorElement->expects($this->once())->method('with') ->will($this->returnSelf()); $errorElement->expects($this->once())->method('addViolation') - ->with($this->stringContains('Invalid mime type : %type%', array('type' => 'bar/baz'))) + ->with($this->stringContains('Invalid mime type : %type%', ['type' => 'bar/baz'])) ->will($this->returnSelf()); $errorElement->expects($this->once())->method('end') ->will($this->returnSelf()); $upload = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array(tempnam(sys_get_temp_dir(), ''), 'dummy')) + ->setConstructorArgs([tempnam(sys_get_temp_dir(), ''), 'dummy']) ->getMock(); $upload->expects($this->any())->method('getClientSize') ->will($this->returnValue(23)); diff --git a/Tests/Provider/ImageProviderTest.php b/Tests/Provider/ImageProviderTest.php index 7838a30007..126c9ce14d 100644 --- a/Tests/Provider/ImageProviderTest.php +++ b/Tests/Provider/ImageProviderTest.php @@ -18,7 +18,7 @@ class ImageProviderTest extends AbstractProviderTest { - public function getProvider($allowedExtensions = array(), $allowedMimeTypes = array(), $box = false) + public function getProvider($allowedExtensions = [], $allowedMimeTypes = [], $box = false) { $resizer = $this->createMock('Sonata\MediaBundle\Resizer\ResizerInterface'); $resizer->expects($this->any())->method('resize')->will($this->returnValue(true)); @@ -29,11 +29,11 @@ public function getProvider($allowedExtensions = array(), $allowedMimeTypes = ar $adapter = $this->createMock('Gaufrette\Adapter'); $filesystem = $this->getMockBuilder('Gaufrette\Filesystem') - ->setMethods(array('get')) - ->setConstructorArgs(array($adapter)) + ->setMethods(['get']) + ->setConstructorArgs([$adapter]) ->getMock(); $file = $this->getMockBuilder('Gaufrette\File') - ->setConstructorArgs(array('foo', $filesystem)) + ->setConstructorArgs(['foo', $filesystem]) ->getMock(); $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); @@ -88,8 +88,8 @@ public function testHelperProperies() $largeBox = new Box(1000, 500); $provider = $this->getProvider( - array(), - array(), + [], + [], $this->onConsecutiveCalls( $largeBox, // first properties call $mediumBox, @@ -100,9 +100,9 @@ public function testHelperProperies() $adminBox // Third call )); - $provider->addFormat('admin', array('width' => 100)); - $provider->addFormat('default_medium', array('width' => 500)); - $provider->addFormat('default_large', array('width' => 1000)); + $provider->addFormat('admin', ['width' => 100]); + $provider->addFormat('default_medium', ['width' => 500]); + $provider->addFormat('default_large', ['width' => 1000]); $media = new Media(); $media->setName('test.png'); @@ -134,9 +134,9 @@ public function testHelperProperies() ); $this->assertSame('(max-width: 500px) 100vw, 500px', $properties['sizes']); - $properties = $provider->getHelperProperties($media, 'admin', array( + $properties = $provider->getHelperProperties($media, 'admin', [ 'width' => 150, - )); + ]); $this->assertArrayNotHasKey('sizes', $properties); $this->assertArrayNotHasKey('srcset', $properties); @@ -155,7 +155,7 @@ public function testThumbnail() $this->assertTrue($provider->requireThumbnails($media)); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $this->assertNotEmpty($provider->getFormats(), '::getFormats() return an array'); @@ -168,7 +168,7 @@ public function testEvent() { $provider = $this->getProvider(); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $file = new \Symfony\Component\HttpFoundation\File\File(realpath(__DIR__.'/../fixtures/logo.png')); diff --git a/Tests/Provider/PoolTest.php b/Tests/Provider/PoolTest.php index 236af2f3e1..5d55341588 100644 --- a/Tests/Provider/PoolTest.php +++ b/Tests/Provider/PoolTest.php @@ -64,10 +64,10 @@ public function testGetInvalidProviderName() ->setMethods(null) ->getMock() ; - $mediaPool->setProviders(array( + $mediaPool->setProviders([ 'provider_a' => $this->createProvider('provider_a'), 'provider_b' => $this->createProvider('provider_b'), - )); + ]); $mediaPool->getProvider('provider_c'); } @@ -84,6 +84,6 @@ protected function createProvider($name) $thumbnail = new FormatThumbnail('jpg'); $metadata = $this->createMock('Sonata\MediaBundle\Metadata\MetadataBuilderInterface'); - return new FileProvider($name, $filesystem, $cdn, $generator, $thumbnail, array(), array(), $metadata); + return new FileProvider($name, $filesystem, $cdn, $generator, $thumbnail, [], [], $metadata); } } diff --git a/Tests/Provider/VimeoProviderTest.php b/Tests/Provider/VimeoProviderTest.php index 0f57ab752d..ab3e7f373c 100644 --- a/Tests/Provider/VimeoProviderTest.php +++ b/Tests/Provider/VimeoProviderTest.php @@ -33,11 +33,11 @@ public function getProvider(Browser $browser = null) $adapter = $this->createMock('Gaufrette\Adapter'); $filesystem = $this->getMockBuilder('Gaufrette\Filesystem') - ->setMethods(array('get')) - ->setConstructorArgs(array($adapter)) + ->setMethods(['get']) + ->setConstructorArgs([$adapter]) ->getMock(); $file = $this->getMockBuilder('Gaufrette\File') - ->setConstructorArgs(array('foo', $filesystem)) + ->setConstructorArgs(['foo', $filesystem]) ->getMock(); $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); @@ -95,7 +95,7 @@ public function testThumbnail() $this->assertTrue($provider->requireThumbnails($media)); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $this->assertNotEmpty($provider->getFormats(), '::getFormats() return an array'); @@ -114,7 +114,7 @@ public function testTransformWithSig() $provider = $this->getProvider($browser); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $media = new Media(); $media->setBinaryContent('BDYAbAtaDzA'); @@ -141,7 +141,7 @@ public function testTransformWithUrl($media) $provider = $this->getProvider($browser); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); // pre persist the media $provider->transform($media); @@ -161,10 +161,10 @@ public function getTransformWithUrlMedia() $mediaPlayer->setBinaryContent('http://player.vimeo.com/video/012341231'); $mediaPlayer->setId(1023456); - return array( - 'transform with website url' => array($mediaWebsite), - 'transform with player url' => array($mediaPlayer), - ); + return [ + 'transform with website url' => [$mediaWebsite], + 'transform with player url' => [$mediaPlayer], + ]; } public function testForm() @@ -177,7 +177,7 @@ public function testForm() ->will($this->returnValue('message')); $formMapper = $this->getMockBuilder('Sonata\AdminBundle\Form\FormMapper') - ->setMethods(array('add', 'getAdmin')) + ->setMethods(['add', 'getAdmin']) ->disableOriginalConstructor() ->getMock(); $formMapper->expects($this->exactly(8)) @@ -193,7 +193,7 @@ public function testHelperProperies() { $provider = $this->getProvider(); - $provider->addFormat('admin', array('width' => 100)); + $provider->addFormat('admin', ['width' => 100]); $media = new Media(); $media->setName('Les tests'); $media->setProviderReference('ASDASDAS.png'); diff --git a/Tests/Provider/YouTubeProviderTest.php b/Tests/Provider/YouTubeProviderTest.php index a1d2926be4..00217c1b98 100644 --- a/Tests/Provider/YouTubeProviderTest.php +++ b/Tests/Provider/YouTubeProviderTest.php @@ -33,11 +33,11 @@ public function getProvider(Browser $browser = null) $adapter = $this->createMock('Gaufrette\Adapter'); $filesystem = $this->getMockBuilder('Gaufrette\Filesystem') - ->setMethods(array('get')) - ->setConstructorArgs(array($adapter)) + ->setMethods(['get']) + ->setConstructorArgs([$adapter]) ->getMock(); $file = $this->getMockBuilder('Gaufrette\File') - ->setConstructorArgs(array('foo', $filesystem)) + ->setConstructorArgs(['foo', $filesystem]) ->getMock(); $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); @@ -95,7 +95,7 @@ public function testThumbnail() $this->assertTrue($provider->requireThumbnails($media)); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $this->assertNotEmpty($provider->getFormats(), '::getFormats() return an array'); @@ -114,7 +114,7 @@ public function testTransformWithSig() $provider = $this->getProvider($browser); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $media = new Media(); $media->setBinaryContent('BDYAbAtaDzA'); @@ -140,7 +140,7 @@ public function testTransformWithUrl($url) $provider = $this->getProvider($browser); - $provider->addFormat('big', array('width' => 200, 'height' => 100, 'constraint' => true)); + $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $media = new Media(); $media->setBinaryContent($url); @@ -155,19 +155,19 @@ public function testTransformWithUrl($url) public static function getUrls() { - return array( - array('BDYAbAtaDzA'), - array('http://www.youtube.com/watch?v=BDYAbAtaDzA&feature=feedrec_grec_index'), - array('http://www.youtube.com/v/BDYAbAtaDzA?fs=1&hl=en_US&rel=0'), - array('http://www.youtube.com/watch?v=BDYAbAtaDzA#t=0m10s'), - array('http://www.youtube.com/embed/BDYAbAtaDzA?rel=0'), - array('http://www.youtube.com/watch?v=BDYAbAtaDzA'), - array('http://www.m.youtube.com/watch?v=BDYAbAtaDzA'), - array('http://m.youtube.com/watch?v=BDYAbAtaDzA'), - array('https://www.m.youtube.com/watch?v=BDYAbAtaDzA'), - array('https://m.youtube.com/watch?v=BDYAbAtaDzA'), - array('http://youtu.be/BDYAbAtaDzA'), - ); + return [ + ['BDYAbAtaDzA'], + ['http://www.youtube.com/watch?v=BDYAbAtaDzA&feature=feedrec_grec_index'], + ['http://www.youtube.com/v/BDYAbAtaDzA?fs=1&hl=en_US&rel=0'], + ['http://www.youtube.com/watch?v=BDYAbAtaDzA#t=0m10s'], + ['http://www.youtube.com/embed/BDYAbAtaDzA?rel=0'], + ['http://www.youtube.com/watch?v=BDYAbAtaDzA'], + ['http://www.m.youtube.com/watch?v=BDYAbAtaDzA'], + ['http://m.youtube.com/watch?v=BDYAbAtaDzA'], + ['https://www.m.youtube.com/watch?v=BDYAbAtaDzA'], + ['https://m.youtube.com/watch?v=BDYAbAtaDzA'], + ['http://youtu.be/BDYAbAtaDzA'], + ]; } public function testForm() @@ -180,7 +180,7 @@ public function testForm() ->will($this->returnValue('message')); $formMapper = $this->getMockBuilder('Sonata\AdminBundle\Form\FormMapper') - ->setMethods(array('add', 'getAdmin')) + ->setMethods(['add', 'getAdmin']) ->disableOriginalConstructor() ->getMock(); $formMapper->expects($this->exactly(8)) @@ -196,7 +196,7 @@ public function testHelperProperties() { $provider = $this->getProvider(); - $provider->addFormat('admin', array('width' => 100)); + $provider->addFormat('admin', ['width' => 100]); $media = new Media(); $media->setName('Les tests'); $media->setProviderReference('ASDASDAS.png'); diff --git a/Tests/Resizer/SimpleResizerTest.php b/Tests/Resizer/SimpleResizerTest.php index ed8505146f..63d221df75 100644 --- a/Tests/Resizer/SimpleResizerTest.php +++ b/Tests/Resizer/SimpleResizerTest.php @@ -31,7 +31,7 @@ public function testResizeWithNoWidth() $file = $this->getMockBuilder('Gaufrette\File')->disableOriginalConstructor()->getMock(); $resizer = new SimpleResizer($adapter, 'foo', $metadata); - $resizer->resize($media, $file, $file, 'bar', array()); + $resizer->resize($media, $file, $file, 'bar', []); } public function testResize() @@ -53,10 +53,10 @@ public function testResize() $out = $filesystem->get('out', true); $metadata = $this->createMock('Sonata\MediaBundle\Metadata\MetadataBuilderInterface'); - $metadata->expects($this->once())->method('get')->will($this->returnValue(array())); + $metadata->expects($this->once())->method('get')->will($this->returnValue([])); $resizer = new SimpleResizer($adapter, 'outbound', $metadata); - $resizer->resize($media, $in, $out, 'bar', array('height' => null, 'width' => 90, 'quality' => 100)); + $resizer->resize($media, $in, $out, 'bar', ['height' => null, 'width' => 90, 'quality' => 100]); } /** @@ -83,17 +83,17 @@ public function testGetBox($mode, $settings, Box $mediaSize, Box $result) public static function getBoxSettings() { - return array( - array('inset', array('width' => 90, 'height' => 90), new Box(100, 120), new Box(75, 90)), - array('inset', array('width' => 90, 'height' => 90), new Box(50, 50), new Box(90, 90)), - array('inset', array('width' => 90, 'height' => null), new Box(50, 50), new Box(90, 90)), - array('inset', array('width' => 90, 'height' => null), new Box(567, 200), new Box(88, 31)), - array('inset', array('width' => 100, 'height' => 100), new Box(567, 200), new Box(100, 35)), - - array('outbound', array('width' => 90, 'height' => 90), new Box(100, 120), new Box(90, 108)), - array('outbound', array('width' => 90, 'height' => 90), new Box(50, 50), new Box(90, 90)), - array('outbound', array('width' => 90, 'height' => null), new Box(50, 50), new Box(90, 90)), - array('outbound', array('width' => 90, 'height' => null), new Box(567, 50), new Box(90, 8)), - ); + return [ + ['inset', ['width' => 90, 'height' => 90], new Box(100, 120), new Box(75, 90)], + ['inset', ['width' => 90, 'height' => 90], new Box(50, 50), new Box(90, 90)], + ['inset', ['width' => 90, 'height' => null], new Box(50, 50), new Box(90, 90)], + ['inset', ['width' => 90, 'height' => null], new Box(567, 200), new Box(88, 31)], + ['inset', ['width' => 100, 'height' => 100], new Box(567, 200), new Box(100, 35)], + + ['outbound', ['width' => 90, 'height' => 90], new Box(100, 120), new Box(90, 108)], + ['outbound', ['width' => 90, 'height' => 90], new Box(50, 50), new Box(90, 90)], + ['outbound', ['width' => 90, 'height' => null], new Box(50, 50), new Box(90, 90)], + ['outbound', ['width' => 90, 'height' => null], new Box(567, 50), new Box(90, 8)], + ]; } } diff --git a/Tests/Resizer/SquareResizerTest.php b/Tests/Resizer/SquareResizerTest.php index 03f9e3d14a..1586d3a6d9 100644 --- a/Tests/Resizer/SquareResizerTest.php +++ b/Tests/Resizer/SquareResizerTest.php @@ -29,7 +29,7 @@ public function testResizeWithNoWidth() $metadata = $this->createMock('Sonata\MediaBundle\Metadata\MetadataBuilderInterface'); $resizer = new SquareResizer($adapter, 'foo', $metadata); - $resizer->resize($media, $file, $file, 'bar', array()); + $resizer->resize($media, $file, $file, 'bar', []); } /** @@ -56,11 +56,11 @@ public function testGetBox($settings, Box $mediaSize, Box $expected) public static function getBoxSettings() { - return array( - array(array('width' => 90, 'height' => 90), new Box(100, 120), new Box(100, 100)), - array(array('width' => 90, 'height' => 90), new Box(50, 50), new Box(50, 50)), - array(array('width' => 90, 'height' => null), new Box(50, 50), new Box(50, 50)), - array(array('width' => 90, 'height' => null), new Box(567, 50), new Box(90, 7)), - ); + return [ + [['width' => 90, 'height' => 90], new Box(100, 120), new Box(100, 100)], + [['width' => 90, 'height' => 90], new Box(50, 50), new Box(50, 50)], + [['width' => 90, 'height' => null], new Box(50, 50), new Box(50, 50)], + [['width' => 90, 'height' => null], new Box(567, 50), new Box(90, 7)], + ]; } } diff --git a/Tests/Security/RolesDownloadStrategyTest.php b/Tests/Security/RolesDownloadStrategyTest.php index 53aac9a44a..3f9c971ef6 100644 --- a/Tests/Security/RolesDownloadStrategyTest.php +++ b/Tests/Security/RolesDownloadStrategyTest.php @@ -29,7 +29,7 @@ public function testIsGrantedTrue() return in_array('ROLE_ADMIN', $roles); })); - $strategy = new RolesDownloadStrategy($translator, $security, array('ROLE_ADMIN')); + $strategy = new RolesDownloadStrategy($translator, $security, ['ROLE_ADMIN']); $this->assertTrue($strategy->isGranted($media, $request)); } @@ -46,7 +46,7 @@ public function testIsGrantedFalse() return in_array('FOO', $roles); })); - $strategy = new RolesDownloadStrategy($translator, $security, array('ROLE_ADMIN')); + $strategy = new RolesDownloadStrategy($translator, $security, ['ROLE_ADMIN']); $this->assertFalse($strategy->isGranted($media, $request)); } } diff --git a/Tests/Thumbnail/FormatThumbnailTest.php b/Tests/Thumbnail/FormatThumbnailTest.php index ac79014cfa..5188726e0f 100644 --- a/Tests/Thumbnail/FormatThumbnailTest.php +++ b/Tests/Thumbnail/FormatThumbnailTest.php @@ -23,14 +23,14 @@ public function testGenerate() { $thumbnail = new FormatThumbnail('foo'); - $filesystem = new Filesystem(new InMemory(array('myfile' => 'content'))); + $filesystem = new Filesystem(new InMemory(['myfile' => 'content'])); $referenceFile = new File('myfile', $filesystem); - $formats = array( - 'admin' => array('height' => 50, 'width' => 50, 'quality' => 100), - 'mycontext_medium' => array('height' => 500, 'width' => 500, 'quality' => 100), - 'anothercontext_large' => array('height' => 500, 'width' => 500, 'quality' => 100), - ); + $formats = [ + 'admin' => ['height' => 50, 'width' => 50, 'quality' => 100], + 'mycontext_medium' => ['height' => 500, 'width' => 500, 'quality' => 100], + 'anothercontext_large' => ['height' => 500, 'width' => 500, 'quality' => 100], + ]; $resizer = $this->createMock('Sonata\MediaBundle\Resizer\ResizerInterface'); $resizer->expects($this->exactly(2))->method('resize')->will($this->returnValue(true)); diff --git a/Tests/Twig/Extension/MediaExtensionTest.php b/Tests/Twig/Extension/MediaExtensionTest.php index d3722a55a2..9b699510d3 100644 --- a/Tests/Twig/Extension/MediaExtensionTest.php +++ b/Tests/Twig/Extension/MediaExtensionTest.php @@ -45,10 +45,10 @@ public function testThumbnailHasAllNecessaryAttributes() $media = $this->getMedia(); $format = 'png'; - $options = array( + $options = [ 'title' => 'Test title', 'alt' => 'Test title', - ); + ]; $provider = $this->getProvider(); $provider->expects($this->once())->method('generatePublicUrl')->with($media, $format) @@ -59,14 +59,14 @@ public function testThumbnailHasAllNecessaryAttributes() ->method('render') ->with( $this->equalTo( - array( + [ 'media' => $media, - 'options' => array( + 'options' => [ 'title' => 'Test title', 'alt' => 'Test title', 'src' => 'http://some.url.com', - ), - ) + ], + ] ) ); @@ -103,7 +103,7 @@ public function getTemplate() if (is_null($this->template)) { $this->template = $this->getMockBuilder('Twig_Template') ->disableOriginalConstructor() - ->setMethods(array('render')) + ->setMethods(['render']) ->getMockForAbstractClass(); } diff --git a/Tests/Validator/FormatValidatorTest.php b/Tests/Validator/FormatValidatorTest.php index 5daa5243fe..19f2918e01 100644 --- a/Tests/Validator/FormatValidatorTest.php +++ b/Tests/Validator/FormatValidatorTest.php @@ -21,7 +21,7 @@ class FormatValidatorTest extends PHPUnit_Framework_TestCase public function testValidate() { $pool = new Pool('defaultContext'); - $pool->addContext('test', array(), array('format1' => array())); + $pool->addContext('test', [], ['format1' => []]); $gallery = $this->createMock('Sonata\MediaBundle\Model\GalleryInterface'); $gallery->expects($this->once())->method('getDefaultFormat')->will($this->returnValue('format1')); @@ -48,7 +48,7 @@ public function testValidate() public function testValidateNotValidDefaultFormat() { $pool = new Pool('defaultContext'); - $pool->addContext('test', array(), array('format1' => array())); + $pool->addContext('test', [], ['format1' => []]); $gallery = $this->createMock('Sonata\MediaBundle\Model\GalleryInterface'); $gallery->expects($this->once())->method('getDefaultFormat')->will($this->returnValue('non_existing_format')); diff --git a/Tests/tests/bootstrap.php b/Tests/tests/bootstrap.php index 629e27bd33..a77352874a 100644 --- a/Tests/tests/bootstrap.php +++ b/Tests/tests/bootstrap.php @@ -16,12 +16,12 @@ } // try to get Symfony's PHPunit Bridge -$files = array_filter(array( +$files = array_filter([ __DIR__.'/../../vendor/symfony/symfony/src/Symfony/Bridge/PhpUnit/bootstrap.php', __DIR__.'/../../vendor/symfony/phpunit-bridge/bootstrap.php', __DIR__.'/../../../../../vendor/symfony/symfony/src/Symfony/Bridge/PhpUnit/bootstrap.php', __DIR__.'/../../../../../vendor/symfony/phpunit-bridge/bootstrap.php', -), 'file_exists'); +], 'file_exists'); if ($files) { require_once current($files); } diff --git a/Thumbnail/ConsumerThumbnail.php b/Thumbnail/ConsumerThumbnail.php index 7218e43842..8d01507d01 100644 --- a/Thumbnail/ConsumerThumbnail.php +++ b/Thumbnail/ConsumerThumbnail.php @@ -90,14 +90,14 @@ public function generate(MediaProviderInterface $provider, MediaInterface $media $id = $this->id; $publish = function () use ($backend, $media, $id) { - $backend->createAndPublish('sonata.media.create_thumbnail', array( + $backend->createAndPublish('sonata.media.create_thumbnail', [ 'thumbnailId' => $id, 'mediaId' => $media->getId(), // force this value as the message is sent inside a transaction, // so we have a race condition 'providerReference' => $media->getProviderReference(), - )); + ]); }; /* diff --git a/Thumbnail/FormatThumbnail.php b/Thumbnail/FormatThumbnail.php index c02c9d0516..17c677e33e 100644 --- a/Thumbnail/FormatThumbnail.php +++ b/Thumbnail/FormatThumbnail.php @@ -98,7 +98,7 @@ public function delete(MediaProviderInterface $provider, MediaInterface $media, if (is_null($formats)) { $formats = array_keys($provider->getFormats()); } elseif (is_string($formats)) { - $formats = array($formats); + $formats = [$formats]; } if (!is_array($formats)) { diff --git a/Thumbnail/LiipImagineThumbnail.php b/Thumbnail/LiipImagineThumbnail.php index 63cb61813c..94e6091b37 100644 --- a/Thumbnail/LiipImagineThumbnail.php +++ b/Thumbnail/LiipImagineThumbnail.php @@ -40,7 +40,7 @@ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterfa } else { $path = $this->router->generate( sprintf('_imagine_%s', $format), - array('path' => sprintf('%s/%s_%s.jpg', $provider->generatePath($media), $media->getId(), $format)) + ['path' => sprintf('%s/%s_%s.jpg', $provider->generatePath($media), $media->getId(), $format)] ); } diff --git a/Twig/Extension/FormatterMediaExtension.php b/Twig/Extension/FormatterMediaExtension.php index 4d64d7efeb..312f6f324e 100644 --- a/Twig/Extension/FormatterMediaExtension.php +++ b/Twig/Extension/FormatterMediaExtension.php @@ -36,11 +36,11 @@ public function __construct(\Twig_Extension $twigExtension) */ public function getAllowedTags() { - return array( + return [ 'media', 'path', 'thumbnail', - ); + ]; } /** @@ -48,11 +48,11 @@ public function getAllowedTags() */ public function getAllowedMethods() { - return array( - 'Sonata\MediaBundle\Model\MediaInterface' => array( + return [ + 'Sonata\MediaBundle\Model\MediaInterface' => [ 'getproviderreference', - ), - ); + ], + ]; } /** @@ -60,11 +60,11 @@ public function getAllowedMethods() */ public function getTokenParsers() { - return array( + return [ new MediaTokenParser(get_class()), new ThumbnailTokenParser(get_class()), new PathTokenParser(get_class()), - ); + ]; } /** @@ -82,7 +82,7 @@ public function getTwigExtension() * * @return string */ - public function media($media, $format, $options = array()) + public function media($media, $format, $options = []) { return $this->getTwigExtension()->media($media, $format, $options); } @@ -94,7 +94,7 @@ public function media($media, $format, $options = array()) * * @return string */ - public function thumbnail($media, $format, $options = array()) + public function thumbnail($media, $format, $options = []) { return $this->getTwigExtension()->thumbnail($media, $format, $options); } diff --git a/Twig/Extension/MediaExtension.php b/Twig/Extension/MediaExtension.php index 11eeb97745..343df01335 100644 --- a/Twig/Extension/MediaExtension.php +++ b/Twig/Extension/MediaExtension.php @@ -28,7 +28,7 @@ class MediaExtension extends \Twig_Extension implements \Twig_Extension_InitRunt /** * @var array */ - protected $resources = array(); + protected $resources = []; /** * @var ManagerInterface @@ -55,11 +55,11 @@ public function __construct(Pool $mediaService, ManagerInterface $mediaManager) */ public function getTokenParsers() { - return array( + return [ new MediaTokenParser(get_called_class()), new ThumbnailTokenParser(get_called_class()), new PathTokenParser(get_called_class()), - ); + ]; } /** @@ -77,7 +77,7 @@ public function initRuntime(\Twig_Environment $environment) * * @return string */ - public function media($media, $format, $options = array()) + public function media($media, $format, $options = []) { $media = $this->getMedia($media); @@ -93,11 +93,11 @@ public function media($media, $format, $options = array()) $options = $provider->getHelperProperties($media, $format, $options); - return $this->render($provider->getTemplate('helper_view'), array( + return $this->render($provider->getTemplate('helper_view'), [ 'media' => $media, 'format' => $format, 'options' => $options, - )); + ]); } /** @@ -109,7 +109,7 @@ public function media($media, $format, $options = array()) * * @return string */ - public function thumbnail($media, $format, $options = array()) + public function thumbnail($media, $format, $options = []) { $media = $this->getMedia($media); @@ -124,10 +124,10 @@ public function thumbnail($media, $format, $options = array()) $format_definition = $provider->getFormat($format); // build option - $defaultOptions = array( + $defaultOptions = [ 'title' => $media->getName(), 'alt' => $media->getName(), - ); + ]; if ($format_definition['width']) { $defaultOptions['width'] = $format_definition['width']; @@ -140,10 +140,10 @@ public function thumbnail($media, $format, $options = array()) $options['src'] = $provider->generatePublicUrl($media, $format); - return $this->render($provider->getTemplate('helper_thumbnail'), array( + return $this->render($provider->getTemplate('helper_thumbnail'), [ 'media' => $media, 'options' => $options, - )); + ]); } /** @@ -152,7 +152,7 @@ public function thumbnail($media, $format, $options = array()) * * @return mixed */ - public function render($template, array $parameters = array()) + public function render($template, array $parameters = []) { if (!isset($this->resources[$template])) { $this->resources[$template] = $this->environment->loadTemplate($template); @@ -199,9 +199,9 @@ public function getMediaService() private function getMedia($media) { if (!$media instanceof MediaInterface && strlen($media) > 0) { - $media = $this->mediaManager->findOneBy(array( + $media = $this->mediaManager->findOneBy([ 'id' => $media, - )); + ]); } if (!$media instanceof MediaInterface) { diff --git a/Twig/Node/MediaNode.php b/Twig/Node/MediaNode.php index 553d9017ee..f61bd26b7b 100644 --- a/Twig/Node/MediaNode.php +++ b/Twig/Node/MediaNode.php @@ -30,7 +30,7 @@ public function __construct($extensionName, \Twig_Node_Expression $media, \Twig_ { $this->extensionName = $extensionName; - parent::__construct(array('media' => $media, 'format' => $format, 'attributes' => $attributes), array(), $lineno, $tag); + parent::__construct(['media' => $media, 'format' => $format, 'attributes' => $attributes], [], $lineno, $tag); } /** diff --git a/Twig/Node/PathNode.php b/Twig/Node/PathNode.php index f59ec05729..94159613eb 100644 --- a/Twig/Node/PathNode.php +++ b/Twig/Node/PathNode.php @@ -29,7 +29,7 @@ public function __construct($extensionName, \Twig_Node_Expression $media, \Twig_ { $this->extensionName = $extensionName; - parent::__construct(array('media' => $media, 'format' => $format), array(), $lineno, $tag); + parent::__construct(['media' => $media, 'format' => $format], [], $lineno, $tag); } /** diff --git a/Twig/Node/ThumbnailNode.php b/Twig/Node/ThumbnailNode.php index 2b17e31724..d74bc1102a 100644 --- a/Twig/Node/ThumbnailNode.php +++ b/Twig/Node/ThumbnailNode.php @@ -30,7 +30,7 @@ public function __construct($extensionName, \Twig_Node_Expression $media, \Twig_ { $this->extensionName = $extensionName; - parent::__construct(array('media' => $media, 'format' => $format, 'attributes' => $attributes), array(), $lineno, $tag); + parent::__construct(['media' => $media, 'format' => $format, 'attributes' => $attributes], [], $lineno, $tag); } /** diff --git a/Twig/TokenParser/MediaTokenParser.php b/Twig/TokenParser/MediaTokenParser.php index b4385f9b5a..18e1445047 100644 --- a/Twig/TokenParser/MediaTokenParser.php +++ b/Twig/TokenParser/MediaTokenParser.php @@ -45,7 +45,7 @@ public function parse(\Twig_Token $token) $attributes = $this->parser->getExpressionParser()->parseExpression(); } else { - $attributes = new \Twig_Node_Expression_Array(array(), $token->getLine()); + $attributes = new \Twig_Node_Expression_Array([], $token->getLine()); } $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE); diff --git a/Twig/TokenParser/ThumbnailTokenParser.php b/Twig/TokenParser/ThumbnailTokenParser.php index f3da178623..3638d365a3 100644 --- a/Twig/TokenParser/ThumbnailTokenParser.php +++ b/Twig/TokenParser/ThumbnailTokenParser.php @@ -45,7 +45,7 @@ public function parse(\Twig_Token $token) $attributes = $this->parser->getExpressionParser()->parseExpression(); } else { - $attributes = new \Twig_Node_Expression_Array(array(), $token->getLine()); + $attributes = new \Twig_Node_Expression_Array([], $token->getLine()); } $this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE); From a45dde563e68f920e36ef9884394906438fe704a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Thu, 19 Oct 2017 15:59:43 +0200 Subject: [PATCH 28/77] Manual merge (#1311) * Drop PHPUnit 4 * Fix style --- Tests/Admin/BaseMediaAdminTest.php | 3 +- Tests/Admin/GalleryAdminTest.php | 3 +- Tests/Admin/GalleryItemAdminTest.php | 3 +- Tests/Admin/ORM/MediaAdminTest.php | 3 +- Tests/CDN/CloudFrontTest.php | 4 +- Tests/CDN/PantherPortalTest.php | 4 +- Tests/Command/CleanMediaCommandTest.php | 14 +---- Tests/Command/FixMediaContextCommandTest.php | 4 +- .../Controller/Api/GalleryControllerTest.php | 4 +- Tests/Controller/Api/MediaControllerTest.php | 4 +- .../Controller/GalleryAdminControllerTest.php | 3 +- Tests/Controller/MediaAdminControllerTest.php | 3 +- Tests/Controller/MediaControllerTest.php | 4 +- .../DependencyInjection/ConfigurationTest.php | 3 +- Tests/Document/MediaManagerTest.php | 4 +- Tests/Entity/GalleryManagerTest.php | 4 +- Tests/Entity/MediaManagerTest.php | 4 +- Tests/Entity/MediaTest.php | 4 +- Tests/Filesystem/LocalTest.php | 3 +- Tests/Filesystem/ReplicateTest.php | 4 +- .../ProviderDataTransformerTest.php | 4 +- .../ServiceProviderDataTransformerTest.php | 4 +- Tests/Generator/DefaultGeneratorTest.php | 3 +- Tests/Generator/PHPCRGeneratorTest.php | 3 +- Tests/Helpers/PHPUnit_Framework_TestCase.php | 54 ------------------- .../Listener/ORM/MediaEventSubscriberTest.php | 4 +- Tests/Metadata/AmazonMetadataBuilderTest.php | 4 +- Tests/Metadata/NoopMetadataBuilderTest.php | 4 +- Tests/Metadata/ProxyMetadataBuilderTest.php | 4 +- Tests/Model/MediaTest.php | 4 +- Tests/PHPCR/MediaManagerTest.php | 4 +- Tests/Provider/AbstractProviderTest.php | 4 +- Tests/Provider/PoolTest.php | 4 +- Tests/Resizer/SimpleResizerTest.php | 4 +- Tests/Resizer/SquareResizerTest.php | 4 +- .../ForbiddenDownloadStrategyTest.php | 4 +- Tests/Security/PublicDownloadStrategyTest.php | 4 +- Tests/Security/RolesDownloadStrategyTest.php | 4 +- .../Security/SessionDownloadStrategyTest.php | 4 +- Tests/Thumbnail/ConsumerThumbnailTest.php | 4 +- Tests/Thumbnail/FormatThumbnailTest.php | 4 +- Tests/Twig/Extension/MediaExtensionTest.php | 4 +- .../Constraints/ValidMediaFormatTest.php | 3 +- Tests/Validator/FormatValidatorTest.php | 4 +- 44 files changed, 86 insertions(+), 139 deletions(-) delete mode 100644 Tests/Helpers/PHPUnit_Framework_TestCase.php diff --git a/Tests/Admin/BaseMediaAdminTest.php b/Tests/Admin/BaseMediaAdminTest.php index e371d27d23..619d9b694e 100644 --- a/Tests/Admin/BaseMediaAdminTest.php +++ b/Tests/Admin/BaseMediaAdminTest.php @@ -11,6 +11,7 @@ namespace Sonata\MediaBundle\Tests\Admin; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Admin\BaseMediaAdmin; class TestMediaAdmin extends BaseMediaAdmin @@ -24,7 +25,7 @@ public function getId() } } -class BaseMediaAdminTest extends \PHPUnit_Framework_TestCase +class BaseMediaAdminTest extends TestCase { private $pool; private $categoryManager; diff --git a/Tests/Admin/GalleryAdminTest.php b/Tests/Admin/GalleryAdminTest.php index 9b57a5b077..62c6793cac 100644 --- a/Tests/Admin/GalleryAdminTest.php +++ b/Tests/Admin/GalleryAdminTest.php @@ -11,9 +11,10 @@ namespace Sonata\MediaBundle\Tests\Admin; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Admin\GalleryAdmin; -class GalleryAdminTest extends \PHPUnit_Framework_TestCase +class GalleryAdminTest extends TestCase { protected $pool; protected $categoryManager; diff --git a/Tests/Admin/GalleryItemAdminTest.php b/Tests/Admin/GalleryItemAdminTest.php index dfac3453e2..d801be9e76 100644 --- a/Tests/Admin/GalleryItemAdminTest.php +++ b/Tests/Admin/GalleryItemAdminTest.php @@ -11,9 +11,10 @@ namespace Sonata\MediaBundle\Tests\Admin; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Admin\GalleryItemAdmin; -class GalleryItemAdminTest extends \PHPUnit_Framework_TestCase +class GalleryItemAdminTest extends TestCase { private $mediaAdmin; diff --git a/Tests/Admin/ORM/MediaAdminTest.php b/Tests/Admin/ORM/MediaAdminTest.php index f74a02d5cb..eaac53b0ec 100644 --- a/Tests/Admin/ORM/MediaAdminTest.php +++ b/Tests/Admin/ORM/MediaAdminTest.php @@ -11,9 +11,10 @@ namespace Sonata\MediaBundle\Tests\Admin\ORM; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Admin\ORM\MediaAdmin; -class MediaAdminTest extends \PHPUnit_Framework_TestCase +class MediaAdminTest extends TestCase { private $pool; private $categoryManager; diff --git a/Tests/CDN/CloudFrontTest.php b/Tests/CDN/CloudFrontTest.php index 26d09d7de1..4081db0b83 100644 --- a/Tests/CDN/CloudFrontTest.php +++ b/Tests/CDN/CloudFrontTest.php @@ -11,12 +11,12 @@ namespace Sonata\MediaBundle\Tests\CDN; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * @author Javier Spagnoletti */ -class CloudFrontTest extends PHPUnit_Framework_TestCase +class CloudFrontTest extends TestCase { /** * @group legacy diff --git a/Tests/CDN/PantherPortalTest.php b/Tests/CDN/PantherPortalTest.php index 7c7e8d6ee1..0b0eaf4968 100644 --- a/Tests/CDN/PantherPortalTest.php +++ b/Tests/CDN/PantherPortalTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\CDN; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\CDN\PantherPortal; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class PantherPortalTest extends PHPUnit_Framework_TestCase +class PantherPortalTest extends TestCase { public function testPortal() { diff --git a/Tests/Command/CleanMediaCommandTest.php b/Tests/Command/CleanMediaCommandTest.php index b18891c6bb..af761499e1 100755 --- a/Tests/Command/CleanMediaCommandTest.php +++ b/Tests/Command/CleanMediaCommandTest.php @@ -22,22 +22,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Filesystem\Tests\FilesystemTestCase; -if (class_exists('Symfony\Component\Filesystem\Tests\FilesystemTestCase')) { - class TestCase extends FilesystemTestCase - { - } -} else { - class TestCase extends \PHPUnit_Framework_TestCase - { - } -} - /** * @author Sullivan Senechal - * - * @requires function Symfony\Component\Filesystem\Tests\FilesystemTestCase::setUpBeforeClass */ -class CleanMediaCommandTest extends TestCase +class CleanMediaCommandTest extends FilesystemTestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|ContainerInterface diff --git a/Tests/Command/FixMediaContextCommandTest.php b/Tests/Command/FixMediaContextCommandTest.php index ae63363694..fa03ca3ddc 100755 --- a/Tests/Command/FixMediaContextCommandTest.php +++ b/Tests/Command/FixMediaContextCommandTest.php @@ -11,15 +11,15 @@ namespace Sonata\MediaBundle\Tests\Command; +use PHPUnit\Framework\TestCase; use Sonata\ClassificationBundle\Model\ContextManagerInterface; use Sonata\MediaBundle\Command\FixMediaContextCommand; use Sonata\MediaBundle\Model\CategoryManagerInterface; use Sonata\MediaBundle\Provider\Pool; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Symfony\Component\Console\Application; use Symfony\Component\Console\Tester\CommandTester; -class FixMediaContextCommandTest extends PHPUnit_Framework_TestCase +class FixMediaContextCommandTest extends TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject|ContainerInterface diff --git a/Tests/Controller/Api/GalleryControllerTest.php b/Tests/Controller/Api/GalleryControllerTest.php index b8370a10e0..45c2f9b39a 100644 --- a/Tests/Controller/Api/GalleryControllerTest.php +++ b/Tests/Controller/Api/GalleryControllerTest.php @@ -12,9 +12,9 @@ namespace Sonata\MediaBundle\Tests\Controller\Api; use Doctrine\Common\Collections\ArrayCollection; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Controller\Api\GalleryController; use Sonata\MediaBundle\Model\GalleryItem; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Symfony\Component\HttpFoundation\Request; class GalleryTest extends GalleryItem @@ -36,7 +36,7 @@ public function getId() /** * @author Hugo Briand */ -class GalleryControllerTest extends PHPUnit_Framework_TestCase +class GalleryControllerTest extends TestCase { public function testGetGalleriesAction() { diff --git a/Tests/Controller/Api/MediaControllerTest.php b/Tests/Controller/Api/MediaControllerTest.php index 361873b02a..4734bffd75 100644 --- a/Tests/Controller/Api/MediaControllerTest.php +++ b/Tests/Controller/Api/MediaControllerTest.php @@ -11,14 +11,14 @@ namespace Sonata\MediaBundle\Tests\Controller\Api; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Controller\Api\MediaController; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Symfony\Component\HttpFoundation\Request; /** * @author Hugo Briand */ -class MediaControllerTest extends PHPUnit_Framework_TestCase +class MediaControllerTest extends TestCase { public function testGetMediaAction() { diff --git a/Tests/Controller/GalleryAdminControllerTest.php b/Tests/Controller/GalleryAdminControllerTest.php index 9a487a51bb..a68b69dc6c 100644 --- a/Tests/Controller/GalleryAdminControllerTest.php +++ b/Tests/Controller/GalleryAdminControllerTest.php @@ -11,10 +11,11 @@ namespace Sonata\MediaBundle\Tests\Controller; +use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Sonata\MediaBundle\Controller\GalleryAdminController; -class GalleryAdminControllerTest extends \PHPUnit_Framework_TestCase +class GalleryAdminControllerTest extends TestCase { private $container; private $admin; diff --git a/Tests/Controller/MediaAdminControllerTest.php b/Tests/Controller/MediaAdminControllerTest.php index fc779ba613..65ce51662d 100644 --- a/Tests/Controller/MediaAdminControllerTest.php +++ b/Tests/Controller/MediaAdminControllerTest.php @@ -11,6 +11,7 @@ namespace Sonata\MediaBundle\Tests\Controller; +use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Sonata\MediaBundle\Controller\MediaAdminController; @@ -21,7 +22,7 @@ public function getId() } } -class MediaAdminControllerTest extends \PHPUnit_Framework_TestCase +class MediaAdminControllerTest extends TestCase { private $container; private $admin; diff --git a/Tests/Controller/MediaControllerTest.php b/Tests/Controller/MediaControllerTest.php index c3c4f86199..0bd7a17df4 100644 --- a/Tests/Controller/MediaControllerTest.php +++ b/Tests/Controller/MediaControllerTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Controller; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Controller\MediaController; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class MediaControllerTest extends PHPUnit_Framework_TestCase +class MediaControllerTest extends TestCase { protected $container; protected $controller; diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 3ff624bf90..fb0c335a4d 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -11,10 +11,11 @@ namespace Sonata\MediaBundle\Tests\DependencyInjection; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\DependencyInjection\Configuration; use Symfony\Component\Config\Definition\Processor; -class ConfigurationTest extends \PHPUnit_Framework_TestCase +class ConfigurationTest extends TestCase { /** * @var array diff --git a/Tests/Document/MediaManagerTest.php b/Tests/Document/MediaManagerTest.php index 41dbadf7b0..4ffe26fe32 100644 --- a/Tests/Document/MediaManagerTest.php +++ b/Tests/Document/MediaManagerTest.php @@ -11,14 +11,14 @@ namespace Sonata\MediaBundle\Tests\Document; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Document\MediaManager; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; /** * @group document * @group mongo */ -class MediaManagerTest extends PHPUnit_Framework_TestCase +class MediaManagerTest extends TestCase { /** @var MediaManager */ private $manager; diff --git a/Tests/Entity/GalleryManagerTest.php b/Tests/Entity/GalleryManagerTest.php index 1c6416b5f4..dab640913a 100644 --- a/Tests/Entity/GalleryManagerTest.php +++ b/Tests/Entity/GalleryManagerTest.php @@ -11,14 +11,14 @@ namespace Sonata\MediaBundle\Test\Entity; +use PHPUnit\Framework\TestCase; use Sonata\CoreBundle\Test\EntityManagerMockFactory; use Sonata\MediaBundle\Entity\GalleryManager; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; /** * @author Benoit de Jacobet */ -class GalleryManagerTest extends PHPUnit_Framework_TestCase +class GalleryManagerTest extends TestCase { public function testGetPager() { diff --git a/Tests/Entity/MediaManagerTest.php b/Tests/Entity/MediaManagerTest.php index 0e74abb5fd..4545a72c75 100644 --- a/Tests/Entity/MediaManagerTest.php +++ b/Tests/Entity/MediaManagerTest.php @@ -11,14 +11,14 @@ namespace Sonata\MediaBundle\Test\Entity; +use PHPUnit\Framework\TestCase; use Sonata\CoreBundle\Test\EntityManagerMockFactory; use Sonata\MediaBundle\Entity\MediaManager; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; /** * @author Benoit de Jacobet */ -class MediaManagerTest extends PHPUnit_Framework_TestCase +class MediaManagerTest extends TestCase { public function testGetPager() { diff --git a/Tests/Entity/MediaTest.php b/Tests/Entity/MediaTest.php index b90033f7fb..cdc430e424 100644 --- a/Tests/Entity/MediaTest.php +++ b/Tests/Entity/MediaTest.php @@ -11,9 +11,9 @@ namespace Sonata\MediaBundle\Tests\Entity; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; -class MediaTest extends PHPUnit_Framework_TestCase +class MediaTest extends TestCase { public function testMetadata() { diff --git a/Tests/Filesystem/LocalTest.php b/Tests/Filesystem/LocalTest.php index 8a80a384c2..e0102958aa 100644 --- a/Tests/Filesystem/LocalTest.php +++ b/Tests/Filesystem/LocalTest.php @@ -11,9 +11,10 @@ namespace Sonata\MediaBundle\Tests\Filesystem; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Filesystem\Local; -class LocalTest extends \PHPUnit_Framework_TestCase +class LocalTest extends TestCase { public function testReplicate() { diff --git a/Tests/Filesystem/ReplicateTest.php b/Tests/Filesystem/ReplicateTest.php index 3e8b8e965c..52c061424d 100644 --- a/Tests/Filesystem/ReplicateTest.php +++ b/Tests/Filesystem/ReplicateTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Filesystem; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Filesystem\Replicate; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class ReplicateTest extends PHPUnit_Framework_TestCase +class ReplicateTest extends TestCase { public function testReplicate() { diff --git a/Tests/Form/DataTransformer/ProviderDataTransformerTest.php b/Tests/Form/DataTransformer/ProviderDataTransformerTest.php index 3044a8564a..37085b2669 100644 --- a/Tests/Form/DataTransformer/ProviderDataTransformerTest.php +++ b/Tests/Form/DataTransformer/ProviderDataTransformerTest.php @@ -11,13 +11,13 @@ namespace Sonata\MediaBundle\Tests\Form\DataTransformer; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Form\DataTransformer\ProviderDataTransformer; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Provider\Pool; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Symfony\Component\HttpFoundation\File\UploadedFile; -class ProviderDataTransformerTest extends PHPUnit_Framework_TestCase +class ProviderDataTransformerTest extends TestCase { public function testReverseTransformFakeValue() { diff --git a/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php b/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php index 87a531dba5..96c0ebad8a 100644 --- a/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php +++ b/Tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php @@ -11,11 +11,11 @@ namespace Sonata\MediaBundle\Tests\Form\DataTransformer; +use PHPUnit\Framework\TestCase; use Prophecy\Argument; use Sonata\MediaBundle\Form\DataTransformer\ServiceProviderDataTransformer; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class ServiceProviderDataTransformerTest extends PHPUnit_Framework_TestCase +class ServiceProviderDataTransformerTest extends TestCase { public function testTransformNoop() { diff --git a/Tests/Generator/DefaultGeneratorTest.php b/Tests/Generator/DefaultGeneratorTest.php index 72e68df453..47a4f9ce4a 100644 --- a/Tests/Generator/DefaultGeneratorTest.php +++ b/Tests/Generator/DefaultGeneratorTest.php @@ -11,10 +11,11 @@ namespace Sonata\MediaBundle\Tests\Generator; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Generator\DefaultGenerator; use Sonata\MediaBundle\Tests\Entity\Media; -class DefaultGeneratorTest extends \PHPUnit_Framework_TestCase +class DefaultGeneratorTest extends TestCase { public function testProvider() { diff --git a/Tests/Generator/PHPCRGeneratorTest.php b/Tests/Generator/PHPCRGeneratorTest.php index f6eeaaf682..73a803d3a1 100644 --- a/Tests/Generator/PHPCRGeneratorTest.php +++ b/Tests/Generator/PHPCRGeneratorTest.php @@ -11,10 +11,11 @@ namespace Sonata\MediaBundle\Tests\Generator; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Generator\PHPCRGenerator; use Sonata\MediaBundle\Tests\Entity\Media; -class PHPCRGeneratorTest extends \PHPUnit_Framework_TestCase +class PHPCRGeneratorTest extends TestCase { public function testPHPCRGenerator() { diff --git a/Tests/Helpers/PHPUnit_Framework_TestCase.php b/Tests/Helpers/PHPUnit_Framework_TestCase.php deleted file mode 100644 index 1fbaa8fa8f..0000000000 --- a/Tests/Helpers/PHPUnit_Framework_TestCase.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\MediaBundle\Tests\Helpers; - -/** - * This is helpers class for supporting old and new PHPUnit versions. - * - * @todo NEXT_MAJOR: Remove this class when dropping support for < PHPUnit 5.4. - * - * @author Oleksandr Savchenko - */ -class PHPUnit_Framework_TestCase extends \PHPUnit_Framework_TestCase -{ - /** - * {@inheritdoc} - */ - public function expectException($exception, $message = '', $code = null) - { - if (is_callable('parent::expectException')) { - parent::expectException($exception); - - if ($message !== '') { - parent::expectExceptionMessage($message); - } - - if ($code !== null) { - parent::expectExceptionCode($code); - } - } - - return parent::setExpectedException($exception, $message, $code); - } - - /** - * {@inheritdoc} - */ - protected function createMock($originalClassName) - { - if (is_callable('parent::createMock')) { - return parent::createMock($originalClassName); - } - - return parent::getMock($originalClassName); - } -} diff --git a/Tests/Listener/ORM/MediaEventSubscriberTest.php b/Tests/Listener/ORM/MediaEventSubscriberTest.php index 588de91262..fee4979b42 100644 --- a/Tests/Listener/ORM/MediaEventSubscriberTest.php +++ b/Tests/Listener/ORM/MediaEventSubscriberTest.php @@ -12,16 +12,16 @@ namespace Sonata\MediaBundle\Tests\Listener\ORM; use Doctrine\ORM\Events; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Listener\ORM\MediaEventSubscriber; use Sonata\MediaBundle\Model\Media; use Sonata\MediaBundle\Provider\Pool; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Symfony\Component\DependencyInjection\ContainerInterface; /** * @author Mathieu Lemoine */ -class MediaEventSubscriberTest extends PHPUnit_Framework_TestCase +class MediaEventSubscriberTest extends TestCase { /** * @see https://github.com/sonata-project/SonataClassificationBundle/issues/60 diff --git a/Tests/Metadata/AmazonMetadataBuilderTest.php b/Tests/Metadata/AmazonMetadataBuilderTest.php index 647eb9eae3..2f946cb8d7 100644 --- a/Tests/Metadata/AmazonMetadataBuilderTest.php +++ b/Tests/Metadata/AmazonMetadataBuilderTest.php @@ -12,10 +12,10 @@ namespace Sonata\MediaBundle\Tests\Metadata; use Aws\S3\Enum\Storage; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Metadata\AmazonMetadataBuilder; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class AmazonMetadataBuilderTest extends PHPUnit_Framework_TestCase +class AmazonMetadataBuilderTest extends TestCase { public function testAmazon() { diff --git a/Tests/Metadata/NoopMetadataBuilderTest.php b/Tests/Metadata/NoopMetadataBuilderTest.php index a21d8a0464..fc908efe71 100644 --- a/Tests/Metadata/NoopMetadataBuilderTest.php +++ b/Tests/Metadata/NoopMetadataBuilderTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Metadata; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Metadata\NoopMetadataBuilder; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class NoopMetadataBuilderTest extends PHPUnit_Framework_TestCase +class NoopMetadataBuilderTest extends TestCase { public function testNoop() { diff --git a/Tests/Metadata/ProxyMetadataBuilderTest.php b/Tests/Metadata/ProxyMetadataBuilderTest.php index 577ebd2bec..a8dd45dee5 100644 --- a/Tests/Metadata/ProxyMetadataBuilderTest.php +++ b/Tests/Metadata/ProxyMetadataBuilderTest.php @@ -13,12 +13,12 @@ use AmazonS3 as AmazonClient; use Gaufrette\Adapter\AmazonS3; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Filesystem\Local; use Sonata\MediaBundle\Filesystem\Replicate; use Sonata\MediaBundle\Metadata\ProxyMetadataBuilder; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class ProxyMetadataBuilderTest extends PHPUnit_Framework_TestCase +class ProxyMetadataBuilderTest extends TestCase { public function testProxyAmazon() { diff --git a/Tests/Model/MediaTest.php b/Tests/Model/MediaTest.php index 2a91e1a88b..6b6f2e1261 100644 --- a/Tests/Model/MediaTest.php +++ b/Tests/Model/MediaTest.php @@ -11,7 +11,9 @@ namespace Sonata\MediaBundle\Tests\Media; -class MediaTest extends \PHPUnit_Framework_TestCase +use PHPUnit\Framework\TestCase; + +class MediaTest extends TestCase { public function testSetMetadataValue() { diff --git a/Tests/PHPCR/MediaManagerTest.php b/Tests/PHPCR/MediaManagerTest.php index 66a4b8ab72..a6836ed023 100644 --- a/Tests/PHPCR/MediaManagerTest.php +++ b/Tests/PHPCR/MediaManagerTest.php @@ -11,14 +11,14 @@ namespace Sonata\MediaBundle\Tests\PHPCR; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\PHPCR\MediaManager; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; /** * @group document * @group PHPCR */ -class MediaManagerTest extends PHPUnit_Framework_TestCase +class MediaManagerTest extends TestCase { /** @var MediaManager */ private $manager; diff --git a/Tests/Provider/AbstractProviderTest.php b/Tests/Provider/AbstractProviderTest.php index a65f35540b..5f13b16b84 100644 --- a/Tests/Provider/AbstractProviderTest.php +++ b/Tests/Provider/AbstractProviderTest.php @@ -11,16 +11,16 @@ namespace Sonata\MediaBundle\Tests\Provider; +use PHPUnit\Framework\TestCase; use Sonata\AdminBundle\Form\FormMapper; use Sonata\MediaBundle\Provider\MediaProviderInterface; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Symfony\Component\Form\FormBuilder; use Symfony\Component\Form\FormTypeInterface; /** * @author Virgile Vivier */ -abstract class AbstractProviderTest extends PHPUnit_Framework_TestCase +abstract class AbstractProviderTest extends TestCase { /** * @var FormBuilder diff --git a/Tests/Provider/PoolTest.php b/Tests/Provider/PoolTest.php index 5d55341588..524de2f843 100644 --- a/Tests/Provider/PoolTest.php +++ b/Tests/Provider/PoolTest.php @@ -11,14 +11,14 @@ namespace Sonata\MediaBundle\Tests\Provider; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Provider\FileProvider; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Sonata\MediaBundle\Thumbnail\FormatThumbnail; /** * @author Javier Spagnoletti */ -class PoolTest extends PHPUnit_Framework_TestCase +class PoolTest extends TestCase { /** * @expectedException \InvalidArgumentException diff --git a/Tests/Resizer/SimpleResizerTest.php b/Tests/Resizer/SimpleResizerTest.php index 63d221df75..7389b54d57 100644 --- a/Tests/Resizer/SimpleResizerTest.php +++ b/Tests/Resizer/SimpleResizerTest.php @@ -15,10 +15,10 @@ use Gaufrette\File; use Gaufrette\Filesystem; use Imagine\Image\Box; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Resizer\SimpleResizer; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class SimpleResizerTest extends PHPUnit_Framework_TestCase +class SimpleResizerTest extends TestCase { /** * @expectedException \RuntimeException diff --git a/Tests/Resizer/SquareResizerTest.php b/Tests/Resizer/SquareResizerTest.php index 1586d3a6d9..6d362af963 100644 --- a/Tests/Resizer/SquareResizerTest.php +++ b/Tests/Resizer/SquareResizerTest.php @@ -13,10 +13,10 @@ use Gaufrette\File; use Imagine\Image\Box; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Resizer\SquareResizer; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class SquareResizerTest extends PHPUnit_Framework_TestCase +class SquareResizerTest extends TestCase { /** * @expectedException \RuntimeException diff --git a/Tests/Security/ForbiddenDownloadStrategyTest.php b/Tests/Security/ForbiddenDownloadStrategyTest.php index 4315bea73a..1aa03c255d 100644 --- a/Tests/Security/ForbiddenDownloadStrategyTest.php +++ b/Tests/Security/ForbiddenDownloadStrategyTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Security; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Security\ForbiddenDownloadStrategy; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class ForbiddenDownloadStrategyTest extends PHPUnit_Framework_TestCase +class ForbiddenDownloadStrategyTest extends TestCase { public function testIsGranted() { diff --git a/Tests/Security/PublicDownloadStrategyTest.php b/Tests/Security/PublicDownloadStrategyTest.php index 4ea6e1c0db..b343b0377b 100644 --- a/Tests/Security/PublicDownloadStrategyTest.php +++ b/Tests/Security/PublicDownloadStrategyTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Security; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Security\PublicDownloadStrategy; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class PublicDownloadStrategyTest extends PHPUnit_Framework_TestCase +class PublicDownloadStrategyTest extends TestCase { public function testIsGranted() { diff --git a/Tests/Security/RolesDownloadStrategyTest.php b/Tests/Security/RolesDownloadStrategyTest.php index 3f9c971ef6..2974c256da 100644 --- a/Tests/Security/RolesDownloadStrategyTest.php +++ b/Tests/Security/RolesDownloadStrategyTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Security; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Security\RolesDownloadStrategy; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; -class RolesDownloadStrategyTest extends PHPUnit_Framework_TestCase +class RolesDownloadStrategyTest extends TestCase { public function testIsGrantedTrue() { diff --git a/Tests/Security/SessionDownloadStrategyTest.php b/Tests/Security/SessionDownloadStrategyTest.php index 5bc6151bdf..23985e18fd 100644 --- a/Tests/Security/SessionDownloadStrategyTest.php +++ b/Tests/Security/SessionDownloadStrategyTest.php @@ -11,13 +11,13 @@ namespace Sonata\MediaBundle\Tests\Security; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Security\SessionDownloadStrategy; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; /** * @author Ahmet Akbana */ -final class SessionDownloadStrategyTest extends PHPUnit_Framework_TestCase +final class SessionDownloadStrategyTest extends TestCase { public function testIsGrantedFalse() { diff --git a/Tests/Thumbnail/ConsumerThumbnailTest.php b/Tests/Thumbnail/ConsumerThumbnailTest.php index 9a5b403465..d3e57f77e4 100644 --- a/Tests/Thumbnail/ConsumerThumbnailTest.php +++ b/Tests/Thumbnail/ConsumerThumbnailTest.php @@ -11,10 +11,10 @@ namespace Sonata\MediaBundle\Tests\Thumbnail; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Thumbnail\ConsumerThumbnail; -class ConsumerThumbnailTest extends PHPUnit_Framework_TestCase +class ConsumerThumbnailTest extends TestCase { public function testGenerateDispatchesEvents() { diff --git a/Tests/Thumbnail/FormatThumbnailTest.php b/Tests/Thumbnail/FormatThumbnailTest.php index 5188726e0f..11755ea590 100644 --- a/Tests/Thumbnail/FormatThumbnailTest.php +++ b/Tests/Thumbnail/FormatThumbnailTest.php @@ -14,10 +14,10 @@ use Gaufrette\Adapter\InMemory; use Gaufrette\File; use Gaufrette\Filesystem; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Thumbnail\FormatThumbnail; -class FormatThumbnailTest extends PHPUnit_Framework_TestCase +class FormatThumbnailTest extends TestCase { public function testGenerate() { diff --git a/Tests/Twig/Extension/MediaExtensionTest.php b/Tests/Twig/Extension/MediaExtensionTest.php index 9b699510d3..ff2a9b8517 100644 --- a/Tests/Twig/Extension/MediaExtensionTest.php +++ b/Tests/Twig/Extension/MediaExtensionTest.php @@ -9,14 +9,14 @@ * file that was distributed with this source code. */ +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Model\MediaInterface; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Sonata\MediaBundle\Twig\Extension\MediaExtension; /** * @author Geza Buza */ -class MediaExtensionTest extends PHPUnit_Framework_TestCase +class MediaExtensionTest extends TestCase { /** * @var Sonata\MediaBundle\Provider\MediaProviderInterface diff --git a/Tests/Validator/Constraints/ValidMediaFormatTest.php b/Tests/Validator/Constraints/ValidMediaFormatTest.php index 3ec5bc253b..edc926e92b 100644 --- a/Tests/Validator/Constraints/ValidMediaFormatTest.php +++ b/Tests/Validator/Constraints/ValidMediaFormatTest.php @@ -11,9 +11,10 @@ namespace Sonata\MediaBundle\Tests\Validator\Constraints; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Validator\Constraints\ValidMediaFormat; -class ValidMediaFormatTest extends \PHPUnit_Framework_TestCase +class ValidMediaFormatTest extends TestCase { public function testInstance() { diff --git a/Tests/Validator/FormatValidatorTest.php b/Tests/Validator/FormatValidatorTest.php index 19f2918e01..9cb63c421d 100644 --- a/Tests/Validator/FormatValidatorTest.php +++ b/Tests/Validator/FormatValidatorTest.php @@ -11,12 +11,12 @@ namespace Sonata\MediaBundle\Tests\Validator; +use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Provider\Pool; -use Sonata\MediaBundle\Tests\Helpers\PHPUnit_Framework_TestCase; use Sonata\MediaBundle\Validator\Constraints\ValidMediaFormat; use Sonata\MediaBundle\Validator\FormatValidator; -class FormatValidatorTest extends PHPUnit_Framework_TestCase +class FormatValidatorTest extends TestCase { public function testValidate() { From a43f39d4c063af628b003bc9ffbe7fe423df028a Mon Sep 17 00:00:00 2001 From: Christian Gripp Date: Mon, 13 Nov 2017 19:50:58 +0100 Subject: [PATCH 29/77] Apply fixes from StyleCI (#1318) --- Admin/BaseMediaAdmin.php | 2 +- Admin/ORM/MediaAdmin.php | 2 +- Block/GalleryBlockService.php | 4 ++-- CDN/PantherPortal.php | 2 +- Command/AddMassMediaCommand.php | 2 +- Command/CleanMediaCommand.php | 6 +++--- Command/MigrateToJsonTypeCommand.php | 2 +- Command/RemoveThumbsCommand.php | 4 ++-- Command/SyncThumbsCommand.php | 2 +- Entity/GalleryManager.php | 2 +- Form/DataTransformer/ProviderDataTransformer.php | 4 ++-- Metadata/AmazonMetadataBuilder.php | 6 +++--- Metadata/ProxyMetadataBuilder.php | 2 +- Model/Media.php | 2 +- Provider/BaseProvider.php | 2 +- Provider/FileProvider.php | 14 +++++++------- Provider/ImageProvider.php | 6 +++--- Provider/YouTubeProvider.php | 4 ++-- Resizer/SimpleResizer.php | 10 +++++----- Tests/Filesystem/LocalTest.php | 2 +- Tests/Provider/FakeHttpWrapper.php | 2 +- Thumbnail/LiipImagineThumbnail.php | 2 +- Twig/Extension/MediaExtension.php | 2 +- Validator/FormatValidator.php | 2 +- 24 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Admin/BaseMediaAdmin.php b/Admin/BaseMediaAdmin.php index 836dfd2e84..a8bbb03db2 100644 --- a/Admin/BaseMediaAdmin.php +++ b/Admin/BaseMediaAdmin.php @@ -80,7 +80,7 @@ public function getPersistentParameters() // if the context has only one provider, set it into the request // so the intermediate provider selection is skipped - if (count($providers) == 1 && null === $provider) { + if (1 == count($providers) && null === $provider) { $provider = array_shift($providers)->getName(); $this->getRequest()->query->set('provider', $provider); } diff --git a/Admin/ORM/MediaAdmin.php b/Admin/ORM/MediaAdmin.php index 996ca55a18..0be46654cb 100644 --- a/Admin/ORM/MediaAdmin.php +++ b/Admin/ORM/MediaAdmin.php @@ -34,7 +34,7 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) ->add('providerReference') ->add('enabled') ->add('context', null, [ - 'show_filter' => $this->getPersistentParameter('hide_context') !== true, + 'show_filter' => true !== $this->getPersistentParameter('hide_context'), ], 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', $options); if (null !== $this->categoryManager) { diff --git a/Block/GalleryBlockService.php b/Block/GalleryBlockService.php index 8a71611229..af69e9bb7e 100644 --- a/Block/GalleryBlockService.php +++ b/Block/GalleryBlockService.php @@ -253,9 +253,9 @@ private function buildElements(GalleryInterface $gallery) */ private function getMediaType(MediaInterface $media) { - if ($media->getContentType() == 'video/x-flv') { + if ('video/x-flv' == $media->getContentType()) { return 'video'; - } elseif (substr($media->getContentType(), 0, 5) == 'image') { + } elseif ('image' == substr($media->getContentType(), 0, 5)) { return 'image'; } diff --git a/CDN/PantherPortal.php b/CDN/PantherPortal.php index 29d4f3e3bf..f9b4fe2d80 100644 --- a/CDN/PantherPortal.php +++ b/CDN/PantherPortal.php @@ -107,7 +107,7 @@ public function flushPaths(array $paths) { $result = $this->getClient()->flush($this->username, $this->password, 'paths', $this->siteId, implode("\n", $paths), true, false); - if ($result != 'Flush successfully submitted.') { + if ('Flush successfully submitted.' != $result) { throw new \RuntimeException('Unable to flush : '.$result); } } diff --git a/Command/AddMassMediaCommand.php b/Command/AddMassMediaCommand.php index 4a4ef1acb3..168d28917b 100644 --- a/Command/AddMassMediaCommand.php +++ b/Command/AddMassMediaCommand.php @@ -77,7 +77,7 @@ public function execute(InputInterface $input, OutputInterface $output) */ protected function getFilePointer(InputInterface $input, OutputInterface $output) { - if (ftell(STDIN) !== false) { + if (false !== ftell(STDIN)) { return STDIN; } diff --git a/Command/CleanMediaCommand.php b/Command/CleanMediaCommand.php index 6c8e711206..a5eb8c2ed2 100755 --- a/Command/CleanMediaCommand.php +++ b/Command/CleanMediaCommand.php @@ -120,11 +120,11 @@ private function mediaExists($filename, $context = null) $fileParts = explode('_', $filename); - if (count($fileParts) > 1 && $fileParts[0] == 'thumb') { - return $mediaManager->findOneBy([ + if (count($fileParts) > 1 && 'thumb' == $fileParts[0]) { + return null != $mediaManager->findOneBy([ 'id' => $fileParts[1], 'context' => $context, - ]) != null; + ]); } return count($mediaManager->findBy([ diff --git a/Command/MigrateToJsonTypeCommand.php b/Command/MigrateToJsonTypeCommand.php index 7fc587bcfa..2706b7eca7 100644 --- a/Command/MigrateToJsonTypeCommand.php +++ b/Command/MigrateToJsonTypeCommand.php @@ -43,7 +43,7 @@ public function execute(InputInterface $input, OutputInterface $output) foreach ($medias as $media) { // if the row need to migrate - if (0 !== strpos($media[$column], '{') && $media[$column] !== '[]') { + if (0 !== strpos($media[$column], '{') && '[]' !== $media[$column]) { $media[$column] = json_encode(unserialize($media[$column])); $connection->update($table, [$column => $media[$column]], [$columnId => $media[$columnId]]); ++$count; diff --git a/Command/RemoveThumbsCommand.php b/Command/RemoveThumbsCommand.php index 30227bff24..da5274a03b 100644 --- a/Command/RemoveThumbsCommand.php +++ b/Command/RemoveThumbsCommand.php @@ -106,7 +106,7 @@ public function execute(InputInterface $input, OutputInterface $output) } $batchMediasCount = count($medias); - if ($batchMediasCount === 0) { + if (0 === $batchMediasCount) { break; } @@ -189,7 +189,7 @@ public function getFormat(MediaProviderInterface $provider, $context) $dialog = $this->getHelperSet()->get('dialog'); $formatKey = $dialog->select($this->output, 'Please select the format', $formats); $format = $formats[$formatKey]; - if ($format === '') { + if ('' === $format) { $format = $context.'_all'; } } else { diff --git a/Command/SyncThumbsCommand.php b/Command/SyncThumbsCommand.php index bc76e5e82c..027c7aa6f9 100644 --- a/Command/SyncThumbsCommand.php +++ b/Command/SyncThumbsCommand.php @@ -109,7 +109,7 @@ public function execute(InputInterface $input, OutputInterface $output) } $batchMediasCount = count($medias); - if ($batchMediasCount === 0) { + if (0 === $batchMediasCount) { break; } diff --git a/Entity/GalleryManager.php b/Entity/GalleryManager.php index 393e4a92e8..adc7f5a4ea 100644 --- a/Entity/GalleryManager.php +++ b/Entity/GalleryManager.php @@ -48,7 +48,7 @@ public function getPager(array $criteria, $page, $limit = 10, array $sort = []) throw new \RuntimeException(sprintf("Invalid sort field '%s' in '%s' class", $field, $this->class)); } } - if (count($sort) == 0) { + if (0 == count($sort)) { $sort = ['name' => 'ASC']; } foreach ($sort as $field => $direction) { diff --git a/Form/DataTransformer/ProviderDataTransformer.php b/Form/DataTransformer/ProviderDataTransformer.php index 58b39e36e4..bd6a339fc2 100644 --- a/Form/DataTransformer/ProviderDataTransformer.php +++ b/Form/DataTransformer/ProviderDataTransformer.php @@ -66,7 +66,7 @@ public function setLogger(LoggerInterface $logger) */ public function transform($value) { - if ($value === null) { + if (null === $value) { return new $this->class(); } @@ -87,7 +87,7 @@ public function reverseTransform($media) // no binary if (empty($binaryContent)) { // and no media id - if ($media->getId() === null && $this->options['empty_on_new']) { + if (null === $media->getId() && $this->options['empty_on_new']) { return; } elseif ($media->getId()) { return $media; diff --git a/Metadata/AmazonMetadataBuilder.php b/Metadata/AmazonMetadataBuilder.php index e801d38846..17bd7fc02a 100644 --- a/Metadata/AmazonMetadataBuilder.php +++ b/Metadata/AmazonMetadataBuilder.php @@ -78,9 +78,9 @@ protected function getDefaultMetadata() //merge storage if (isset($this->settings['storage'])) { - if ($this->settings['storage'] == 'standard') { + if ('standard' == $this->settings['storage']) { $output['storage'] = static::STORAGE_STANDARD; - } elseif ($this->settings['storage'] == 'reduced') { + } elseif ('reduced' == $this->settings['storage']) { $output['storage'] = static::STORAGE_REDUCED; } } @@ -97,7 +97,7 @@ protected function getDefaultMetadata() //merge encryption if (isset($this->settings['encryption']) && !empty($this->settings['encryption'])) { - if ($this->settings['encryption'] == 'aes256') { + if ('aes256' == $this->settings['encryption']) { $output['encryption'] = 'AES256'; } } diff --git a/Metadata/ProxyMetadataBuilder.php b/Metadata/ProxyMetadataBuilder.php index bdd669ce78..b9f24aeed7 100644 --- a/Metadata/ProxyMetadataBuilder.php +++ b/Metadata/ProxyMetadataBuilder.php @@ -32,7 +32,7 @@ public function __construct(ContainerInterface $container, array $map = null) { $this->container = $container; - if ($map !== null) { + if (null !== $map) { @trigger_error( 'The "map" parameter is deprecated since version 2.4 and will be removed in 4.0.', E_USER_DEPRECATED diff --git a/Model/Media.php b/Model/Media.php index 7d1697d5da..4e98714f0e 100644 --- a/Model/Media.php +++ b/Model/Media.php @@ -614,7 +614,7 @@ public function getPreviousProviderReference() */ public function isStatusErroneous(ExecutionContextInterface $context) { - if ($this->getBinaryContent() && $this->getProviderStatus() == self::STATUS_ERROR) { + if ($this->getBinaryContent() && self::STATUS_ERROR == $this->getProviderStatus()) { $context->buildViolation('invalid') ->atPath('binaryContent') ->addViolation(); diff --git a/Provider/BaseProvider.php b/Provider/BaseProvider.php index 393fde044b..64f8f8a412 100644 --- a/Provider/BaseProvider.php +++ b/Provider/BaseProvider.php @@ -134,7 +134,7 @@ public function getFormat($name) */ public function requireThumbnails() { - return $this->getResizer() !== null; + return null !== $this->getResizer(); } /** diff --git a/Provider/FileProvider.php b/Provider/FileProvider.php index 559bfa217f..7b57982c1c 100644 --- a/Provider/FileProvider.php +++ b/Provider/FileProvider.php @@ -128,7 +128,7 @@ public function buildMediaType(FormBuilder $formBuilder) { $fileType = 'Symfony\Component\Form\Extension\Core\Type\FileType'; - if ($formBuilder->getOption('context') == 'api') { + if ('api' == $formBuilder->getOption('context')) { $formBuilder->add('binaryContent', $fileType); $formBuilder->add('contentType'); } else { @@ -144,7 +144,7 @@ public function buildMediaType(FormBuilder $formBuilder) */ public function postPersist(MediaInterface $media) { - if ($media->getBinaryContent() === null) { + if (null === $media->getBinaryContent()) { return; } @@ -168,7 +168,7 @@ public function postUpdate(MediaInterface $media) $oldMedia = clone $media; // if no previous reference is provided, it prevents // Filesystem from trying to remove a directory - if ($media->getPreviousProviderReference() !== null) { + if (null !== $media->getPreviousProviderReference()) { $oldMedia->setProviderReference($media->getPreviousProviderReference()); $path = $this->getReferenceImage($oldMedia); @@ -258,7 +258,7 @@ public function getDownloadResponse(MediaInterface $media, $format, $mode, array throw new \RuntimeException('Invalid mode provided'); } - if ($mode == 'http') { + if ('http' == $mode) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { $file = $this->getReferenceFile($media); } else { @@ -326,7 +326,7 @@ public function validate(ErrorElement $errorElement, MediaInterface $media) */ protected function fixBinaryContent(MediaInterface $media) { - if ($media->getBinaryContent() === null || $media->getBinaryContent() instanceof File) { + if (null === $media->getBinaryContent() || $media->getBinaryContent() instanceof File) { return; } @@ -384,7 +384,7 @@ protected function doTransform(MediaInterface $media) // this is the name used to store the file if (!$media->getProviderReference() || - $media->getProviderReference() === MediaInterface::MISSING_BINARY_REFERENCE + MediaInterface::MISSING_BINARY_REFERENCE === $media->getProviderReference() ) { $media->setProviderReference($this->generateReferenceName($media)); } @@ -450,7 +450,7 @@ protected function generateMediaUniqId(MediaInterface $media) */ protected function generateBinaryFromRequest(MediaInterface $media) { - if (php_sapi_name() === 'cli') { + if ('cli' === php_sapi_name()) { throw new \RuntimeException('The current process cannot be executed in cli environment'); } diff --git a/Provider/ImageProvider.php b/Provider/ImageProvider.php index 2e1facaeed..2dbaf1a0a0 100644 --- a/Provider/ImageProvider.php +++ b/Provider/ImageProvider.php @@ -64,7 +64,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ $box = $media->getBox(); } else { $resizerFormat = $this->getFormat($format); - if ($resizerFormat === false) { + if (false === $resizerFormat) { throw new \RuntimeException(sprintf('The image format "%s" is not defined. Is the format registered in your ``sonata_media`` configuration?', $format)); } @@ -82,12 +82,12 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ 'height' => $box->getHeight(), ]; - if ($format !== MediaProviderInterface::FORMAT_ADMIN) { + if (MediaProviderInterface::FORMAT_ADMIN !== $format) { $srcSet = []; foreach ($this->getFormats() as $providerFormat => $settings) { // Check if format belongs to the current media's context - if (strpos($providerFormat, $media->getContext()) === 0) { + if (0 === strpos($providerFormat, $media->getContext())) { $width = $this->resizer->getBox($media, $settings)->getWidth(); $srcSet[] = sprintf('%s %dw', $this->generatePublicUrl($media, $providerFormat), $width); diff --git a/Provider/YouTubeProvider.php b/Provider/YouTubeProvider.php index 79ff76427d..1529078f4d 100644 --- a/Provider/YouTubeProvider.php +++ b/Provider/YouTubeProvider.php @@ -165,7 +165,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ // Values: 'allowfullscreen' or empty. Default is 'allowfullscreen'. Setting to empty value disables // the fullscreen button. - 'allowFullScreen' => $default_player_url_parameters['fs'] == '1' ? true : false, + 'allowFullScreen' => '1' == $default_player_url_parameters['fs'] ? true : false, // The allowScriptAccess parameter in the code is needed to allow the player SWF to call // functions on the containing HTML page, since the player is hosted on a different domain @@ -254,7 +254,7 @@ protected function fixBinaryContent(MediaInterface $media) return; } - if (strlen($media->getBinaryContent()) === 11) { + if (11 === strlen($media->getBinaryContent())) { return; } diff --git a/Resizer/SimpleResizer.php b/Resizer/SimpleResizer.php index b85d546169..b8767477e8 100644 --- a/Resizer/SimpleResizer.php +++ b/Resizer/SimpleResizer.php @@ -73,15 +73,15 @@ public function getBox(MediaInterface $media, array $settings) { $size = $media->getBox(); - if ($settings['width'] == null && $settings['height'] == null) { + if (null == $settings['width'] && null == $settings['height']) { throw new \RuntimeException(sprintf('Width/Height parameter is missing in context "%s" for provider "%s". Please add at least one parameter.', $media->getContext(), $media->getProviderName())); } - if ($settings['height'] == null) { + if (null == $settings['height']) { $settings['height'] = (int) ($settings['width'] * $size->getHeight() / $size->getWidth()); } - if ($settings['width'] == null) { + if (null == $settings['width']) { $settings['width'] = (int) ($settings['height'] * $size->getWidth() / $size->getHeight()); } @@ -98,7 +98,7 @@ public function getBox(MediaInterface $media, array $settings) */ protected function computeBox(MediaInterface $media, array $settings) { - if ($this->mode !== ImageInterface::THUMBNAIL_INSET && $this->mode !== ImageInterface::THUMBNAIL_OUTBOUND) { + if (ImageInterface::THUMBNAIL_INSET !== $this->mode && ImageInterface::THUMBNAIL_OUTBOUND !== $this->mode) { throw new InvalidArgumentException('Invalid mode specified'); } @@ -109,7 +109,7 @@ protected function computeBox(MediaInterface $media, array $settings) $settings['height'] / $size->getHeight(), ]; - if ($this->mode === ImageInterface::THUMBNAIL_INSET) { + if (ImageInterface::THUMBNAIL_INSET === $this->mode) { $ratio = min($ratios); } else { $ratio = max($ratios); diff --git a/Tests/Filesystem/LocalTest.php b/Tests/Filesystem/LocalTest.php index e0102958aa..0e33a2db2d 100644 --- a/Tests/Filesystem/LocalTest.php +++ b/Tests/Filesystem/LocalTest.php @@ -21,7 +21,7 @@ public function testReplicate() $local = new Local('/tmp'); // check if OS is Mac OS X where /tmp is a symlink to /private/tmp - $result = php_uname('s') == 'Darwin' ? '/private/tmp' : '/tmp'; + $result = 'Darwin' == php_uname('s') ? '/private/tmp' : '/tmp'; $this->assertSame($result, $local->getDirectory()); } diff --git a/Tests/Provider/FakeHttpWrapper.php b/Tests/Provider/FakeHttpWrapper.php index b2b3293cd9..86201dac8e 100644 --- a/Tests/Provider/FakeHttpWrapper.php +++ b/Tests/Provider/FakeHttpWrapper.php @@ -76,7 +76,7 @@ public function stream_close() public function stream_eof() { - return feof($this->fp) == 0; + return 0 == feof($this->fp); } public function stream_flush() diff --git a/Thumbnail/LiipImagineThumbnail.php b/Thumbnail/LiipImagineThumbnail.php index 94e6091b37..35b0515241 100644 --- a/Thumbnail/LiipImagineThumbnail.php +++ b/Thumbnail/LiipImagineThumbnail.php @@ -52,7 +52,7 @@ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterfa */ public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterface $media, $format) { - if ($format !== MediaProviderInterface::FORMAT_REFERENCE) { + if (MediaProviderInterface::FORMAT_REFERENCE !== $format) { throw new \RuntimeException('No private url for LiipImagineThumbnail'); } diff --git a/Twig/Extension/MediaExtension.php b/Twig/Extension/MediaExtension.php index 343df01335..ee463aa681 100644 --- a/Twig/Extension/MediaExtension.php +++ b/Twig/Extension/MediaExtension.php @@ -208,7 +208,7 @@ private function getMedia($media) return false; } - if ($media->getProviderStatus() !== MediaInterface::STATUS_OK) { + if (MediaInterface::STATUS_OK !== $media->getProviderStatus()) { return false; } diff --git a/Validator/FormatValidator.php b/Validator/FormatValidator.php index c462dc8ca3..b203e7453f 100644 --- a/Validator/FormatValidator.php +++ b/Validator/FormatValidator.php @@ -53,7 +53,7 @@ public function validate($value, Constraint $constraint) $galleryDefaultFormat = $value->getDefaultFormat(); - if ($galleryDefaultFormat !== MediaProviderInterface::FORMAT_REFERENCE + if (MediaProviderInterface::FORMAT_REFERENCE !== $galleryDefaultFormat && !($formats && array_key_exists($galleryDefaultFormat, $formats))) { $this->context->addViolation('invalid format'); } From 97e09b35a960a44f05fa8dbe189e61538de67170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Sat, 18 Nov 2017 10:31:59 +0100 Subject: [PATCH 30/77] Fix docs path --- .travis/install_docs.sh | 2 +- Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis/install_docs.sh b/.travis/install_docs.sh index 362f6449ff..a5522d971c 100755 --- a/.travis/install_docs.sh +++ b/.travis/install_docs.sh @@ -1,4 +1,4 @@ #!/usr/bin/env sh set -ev -pip install -r Resources/doc/requirements.txt --user +pip install -r docs/requirements.txt --user diff --git a/Makefile b/Makefile index e27d3cd38b..43e65b4e7d 100644 --- a/Makefile +++ b/Makefile @@ -19,4 +19,4 @@ test: phpunit -c phpunit.xml.dist --coverage-clover build/logs/clover.xml docs: - cd Resources/doc && sphinx-build -W -b html -d _build/doctrees . _build/html + cd docs && sphinx-build -W -b html -d _build/doctrees . _build/html From 3cd7c81452b9f8e3eac1bb7e7ecc63e24a334026 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Sun, 19 Nov 2017 08:26:48 +0100 Subject: [PATCH 31/77] DevKit updates (#1332) --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index e214d98ada..be38063500 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ branches: language: php php: - - '5.6' - - '7.0' - '7.1' - nightly @@ -41,7 +39,7 @@ matrix: env: TARGET=docs - php: '7.1' env: TARGET=lint - - php: '5.6' + - php: '7.1' env: COMPOSER_FLAGS="--prefer-lowest" - php: '7.1' env: SYMFONY=2.8.* From d5cc97a27cbac31fcf098f81e70f36e8c0669fdc Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Fri, 8 Dec 2017 00:02:23 +0100 Subject: [PATCH 32/77] Fix cs --- src/Controller/MediaController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Controller/MediaController.php b/src/Controller/MediaController.php index bd34946acf..53603aeaae 100644 --- a/src/Controller/MediaController.php +++ b/src/Controller/MediaController.php @@ -74,8 +74,8 @@ public function downloadAction(Request $request, $id, $format = MediaProviderInt /** * @param Request $request - * @param string $id - * @param string $format + * @param string $id + * @param string $format * * @throws NotFoundHttpException * From 847f63ccf2c7b5adb6d5af7e9c8e1a8883453a72 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Mon, 11 Dec 2017 02:30:11 +0100 Subject: [PATCH 33/77] DevKit updates (#1353) --- .php_cs.dist | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.php_cs.dist b/.php_cs.dist index 4d0bb00214..f2d7312626 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -36,6 +36,12 @@ $rules = [ '@PHP56Migration' => true, '@PHP56Migration:risky' => true, '@PHPUnit57Migration:risky' => true, + '@PHP70Migration' => true, + '@PHP70Migration:risky' => true, + '@PHPUnit60Migration:risky' => true, + '@PHP71Migration' => true, + '@PHP71Migration:risky' => true, + 'compact_nullable_typehint' => true, // To be tested before insertion: // 'strict_comparison' => true, // 'strict_param' => true, From cae6e58a00526be50872f26eb23ef6087ed4dffc Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Tue, 12 Dec 2017 00:45:29 +0100 Subject: [PATCH 34/77] Restore PHP 7.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 41688746ed..0083655b6d 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ } ], "require": { - "php": "^5.6 || ^7.0", + "php": "^7.1", "imagine/imagine": "^0.6", "jms/serializer-bundle": "^0.13 || ^1.0 || ^2.0", "knplabs/gaufrette": "^0.1.6 || ^0.2 || ^0.3", From 0ac09bd9c55e8d45d33a74fb53dce23d40d41591 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Tue, 12 Dec 2017 00:46:02 +0100 Subject: [PATCH 35/77] Fix cs --- src/Admin/BaseMediaAdmin.php | 8 ++- src/Admin/GalleryAdmin.php | 12 ++-- src/Admin/GalleryItemAdmin.php | 6 +- src/Admin/ODM/MediaAdmin.php | 4 +- src/Admin/ORM/MediaAdmin.php | 4 +- src/Admin/PHPCR/GalleryAdmin.php | 8 ++- src/Admin/PHPCR/MediaAdmin.php | 8 ++- .../BaseGalleryBreadcrumbBlockService.php | 2 + .../GalleryIndexBreadcrumbBlockService.php | 2 + .../GalleryViewBreadcrumbBlockService.php | 4 +- .../MediaViewBreadcrumbBlockService.php | 4 +- src/Block/FeatureMediaBlockService.php | 6 +- src/Block/GalleryBlockService.php | 12 ++-- src/Block/GalleryListBlockService.php | 6 +- src/Block/MediaBlockService.php | 12 ++-- src/CDN/CDNInterface.php | 12 ++-- src/CDN/CloudFront.php | 4 +- src/CDN/Fallback.php | 2 + src/CDN/PantherPortal.php | 12 ++-- src/CDN/Server.php | 10 +-- src/Command/AddMassMediaCommand.php | 10 +-- src/Command/AddMediaCommand.php | 6 +- src/Command/BaseCommand.php | 2 + src/Command/CleanMediaCommand.php | 6 +- src/Command/FixMediaContextCommand.php | 6 +- src/Command/MigrateToJsonTypeCommand.php | 6 +- src/Command/RefreshMetadataCommand.php | 8 ++- src/Command/RemoveThumbsCommand.php | 8 ++- src/Command/SyncThumbsCommand.php | 8 ++- src/Command/UpdateCdnStatusCommand.php | 8 ++- src/Consumer/CreateThumbnailConsumer.php | 4 +- src/Controller/Api/GalleryController.php | 2 + src/Controller/Api/MediaController.php | 2 + src/Controller/GalleryAdminController.php | 4 +- src/Controller/GalleryController.php | 2 + src/Controller/MediaAdminController.php | 4 +- src/Controller/MediaController.php | 2 + .../Compiler/AddProviderCompilerPass.php | 18 +++--- .../Compiler/GlobalVariablesCompilerPass.php | 4 +- src/DependencyInjection/Configuration.php | 22 ++++--- .../SonataMediaExtension.php | 26 ++++---- src/Document/BaseGallery.php | 6 +- src/Document/BaseGalleryItem.php | 6 +- src/Document/BaseMedia.php | 6 +- src/Document/GalleryManager.php | 6 +- src/Document/MediaManager.php | 6 +- src/Entity/BaseGallery.php | 6 +- src/Entity/BaseGalleryItem.php | 6 +- src/Entity/BaseMedia.php | 6 +- src/Entity/GalleryManager.php | 4 +- src/Entity/MediaManager.php | 4 +- src/Extra/ApiMediaFile.php | 6 +- src/Extra/Pixlr.php | 4 +- src/Filesystem/Local.php | 2 + src/Filesystem/Replicate.php | 4 +- .../ProviderDataTransformer.php | 2 + .../ServiceProviderDataTransformer.php | 2 + src/Form/Type/ApiDoctrineMediaType.php | 2 + src/Form/Type/ApiGalleryItemType.php | 2 + src/Form/Type/ApiGalleryType.php | 2 + src/Form/Type/ApiMediaType.php | 6 +- src/Form/Type/MediaType.php | 10 +-- src/Generator/DefaultGenerator.php | 2 + src/Generator/GeneratorInterface.php | 2 + src/Generator/ODMGenerator.php | 2 + src/Generator/PHPCRGenerator.php | 2 + src/Listener/BaseMediaEventSubscriber.php | 14 ++-- src/Listener/ODM/MediaEventSubscriber.php | 4 +- src/Listener/ORM/MediaEventSubscriber.php | 6 +- src/Listener/PHPCR/MediaEventSubscriber.php | 4 +- src/Metadata/AmazonMetadataBuilder.php | 22 ++++--- src/Metadata/MetadataBuilderInterface.php | 2 + src/Metadata/NoopMetadataBuilder.php | 2 + src/Metadata/ProxyMetadataBuilder.php | 2 + src/Model/CategoryManager.php | 4 +- src/Model/CategoryManagerInterface.php | 2 + src/Model/Gallery.php | 18 +++--- src/Model/GalleryInterface.php | 2 + src/Model/GalleryItem.php | 14 ++-- src/Model/GalleryItemInterface.php | 2 + src/Model/GalleryManager.php | 2 + src/Model/GalleryManagerInterface.php | 2 + src/Model/Media.php | 64 ++++++++++--------- src/Model/MediaInterface.php | 14 ++-- src/Model/MediaManagerInterface.php | 2 + src/PHPCR/BaseGallery.php | 10 +-- src/PHPCR/BaseGalleryItem.php | 8 ++- src/PHPCR/BaseGalleryItemRepository.php | 2 + src/PHPCR/BaseGalleryRepository.php | 2 + src/PHPCR/BaseMedia.php | 6 +- src/PHPCR/BaseMediaRepository.php | 2 + src/PHPCR/GalleryManager.php | 6 +- src/PHPCR/MediaManager.php | 6 +- src/Provider/BaseProvider.php | 28 ++++---- src/Provider/BaseVideoProvider.php | 18 +++--- src/Provider/DailyMotionProvider.php | 14 ++-- src/Provider/FileProvider.php | 30 +++++---- src/Provider/ImageProvider.php | 6 +- src/Provider/MediaProviderInterface.php | 6 +- src/Provider/Pool.php | 14 ++-- src/Provider/VimeoProvider.php | 14 ++-- src/Provider/YouTubeProvider.php | 14 ++-- src/Resizer/ResizerInterface.php | 2 + src/Resizer/SimpleResizer.php | 4 +- src/Resizer/SquareResizer.php | 6 +- src/Security/DownloadStrategyInterface.php | 2 + src/Security/ForbiddenDownloadStrategy.php | 2 + src/Security/PublicDownloadStrategy.php | 2 + src/Security/RolesDownloadStrategy.php | 2 + src/Security/SessionDownloadStrategy.php | 2 + src/Serializer/GallerySerializerHandler.php | 2 + src/Serializer/MediaSerializerHandler.php | 2 + src/SonataMediaBundle.php | 8 ++- src/Templating/Helper/MediaHelper.php | 2 + src/Thumbnail/ConsumerThumbnail.php | 6 +- src/Thumbnail/FormatThumbnail.php | 6 +- src/Thumbnail/LiipImagineThumbnail.php | 6 +- src/Thumbnail/ThumbnailInterface.php | 2 + .../Extension/FormatterMediaExtension.php | 2 + src/Twig/Extension/MediaExtension.php | 4 +- src/Twig/GlobalVariables.php | 2 + src/Twig/Node/MediaNode.php | 4 +- src/Twig/Node/PathNode.php | 4 +- src/Twig/Node/ThumbnailNode.php | 4 +- src/Twig/TokenParser/MediaTokenParser.php | 2 + src/Twig/TokenParser/PathTokenParser.php | 2 + src/Twig/TokenParser/ThumbnailTokenParser.php | 2 + .../Constraints/ValidMediaFormat.php | 2 + src/Validator/FormatValidator.php | 4 +- tests/Admin/BaseMediaAdminTest.php | 12 ++-- tests/Admin/GalleryAdminTest.php | 6 +- tests/Admin/GalleryItemAdminTest.php | 6 +- tests/Admin/ORM/MediaAdminTest.php | 6 +- tests/Block/Breadcrumb/BreadcrumbTest.php | 4 +- tests/Block/FeatureMediaBlockServiceTest.php | 6 +- tests/Block/GalleryBlockServiceTest.php | 8 ++- tests/Block/GalleryListBlockServiceTest.php | 8 ++- tests/Block/MediaBlockServiceTest.php | 10 +-- tests/CDN/CloudFrontTest.php | 6 +- tests/CDN/PantherPortalTest.php | 8 ++- tests/Command/CleanMediaCommandTest.php | 18 +++--- tests/Command/FixMediaContextCommandTest.php | 12 ++-- tests/Command/RemoveThumbsCommandTest.php | 6 +- .../Controller/Api/GalleryControllerTest.php | 26 ++++---- tests/Controller/Api/MediaControllerTest.php | 24 +++---- .../Controller/GalleryAdminControllerTest.php | 18 +++--- tests/Controller/MediaAdminControllerTest.php | 24 +++---- tests/Controller/MediaControllerTest.php | 24 +++---- .../DependencyInjection/ConfigurationTest.php | 6 +- .../SonataMediaExtensionTest.php | 26 ++++---- tests/Document/Media.php | 4 +- tests/Document/MediaManagerTest.php | 10 +-- tests/Entity/GalleryManagerTest.php | 22 ++++--- tests/Entity/Media.php | 4 +- tests/Entity/MediaManagerTest.php | 22 ++++--- tests/Entity/MediaTest.php | 12 ++-- tests/Filesystem/LocalTest.php | 4 +- tests/Filesystem/ReplicateTest.php | 4 +- .../ProviderDataTransformerTest.php | 18 +++--- .../ServiceProviderDataTransformerTest.php | 12 ++-- tests/Form/Type/AbstractTypeTest.php | 10 +-- tests/Form/Type/ApiMediaTypeTest.php | 4 +- tests/Form/Type/MediaTypeTest.php | 14 ++-- tests/Generator/DefaultGeneratorTest.php | 4 +- tests/Generator/PHPCRGeneratorTest.php | 4 +- .../Listener/ORM/MediaEventSubscriberTest.php | 4 +- tests/Metadata/AmazonMetadataBuilderTest.php | 4 +- tests/Metadata/NoopMetadataBuilderTest.php | 4 +- tests/Metadata/ProxyMetadataBuilderTest.php | 12 ++-- tests/Model/MediaTest.php | 4 +- tests/PHPCR/Media.php | 4 +- tests/PHPCR/MediaManagerTest.php | 10 +-- tests/Provider/AbstractProviderTest.php | 14 ++-- tests/Provider/BaseProviderTest.php | 42 ++++++------ tests/Provider/DailyMotionProviderTest.php | 16 +++-- tests/Provider/FakeHttpWrapper.php | 36 ++++++----- tests/Provider/FileProviderTest.php | 28 ++++---- tests/Provider/ImageProviderTest.php | 12 ++-- tests/Provider/PoolTest.php | 8 ++- tests/Provider/VimeoProviderTest.php | 16 +++-- tests/Provider/YouTubeProviderTest.php | 16 +++-- tests/Resizer/SimpleResizerTest.php | 8 ++- tests/Resizer/SquareResizerTest.php | 6 +- .../ForbiddenDownloadStrategyTest.php | 4 +- tests/Security/PublicDownloadStrategyTest.php | 4 +- tests/Security/RolesDownloadStrategyTest.php | 6 +- .../Security/SessionDownloadStrategyTest.php | 6 +- tests/Thumbnail/ConsumerThumbnailTest.php | 4 +- tests/Thumbnail/FormatThumbnailTest.php | 4 +- tests/Twig/Extension/MediaExtensionTest.php | 4 +- .../Constraints/ValidMediaFormatTest.php | 4 +- tests/Validator/FormatValidatorTest.php | 8 ++- tests/bootstrap.php | 2 + .../Model/CategoryInterface.php | 2 + .../Model/ContextInterface.php | 2 + .../Model/ContextManagerInterface.php | 2 + 196 files changed, 979 insertions(+), 587 deletions(-) diff --git a/src/Admin/BaseMediaAdmin.php b/src/Admin/BaseMediaAdmin.php index a2222b2984..0991703917 100644 --- a/src/Admin/BaseMediaAdmin.php +++ b/src/Admin/BaseMediaAdmin.php @@ -1,5 +1,7 @@ getPersistentParameters(); $media->setContext($parameters['context']); @@ -155,7 +157,7 @@ public function getObjectMetadata($object) /** * {@inheritdoc} */ - protected function configureListFields(ListMapper $listMapper) + protected function configureListFields(ListMapper $listMapper): void { $listMapper ->addIdentifier('name') @@ -168,7 +170,7 @@ protected function configureListFields(ListMapper $listMapper) /** * {@inheritdoc} */ - protected function configureFormFields(FormMapper $formMapper) + protected function configureFormFields(FormMapper $formMapper): void { $media = $this->getSubject(); diff --git a/src/Admin/GalleryAdmin.php b/src/Admin/GalleryAdmin.php index 44c7c2175b..bd3efa948f 100644 --- a/src/Admin/GalleryAdmin.php +++ b/src/Admin/GalleryAdmin.php @@ -1,5 +1,7 @@ getPersistentParameters(); @@ -55,7 +57,7 @@ public function prePersist($gallery) /** * {@inheritdoc} */ - public function preUpdate($gallery) + public function preUpdate($gallery): void { // fix weird bug with setter object not being call $gallery->setGalleryItems($gallery->getGalleryItems()); @@ -94,7 +96,7 @@ public function getNewInstance() /** * {@inheritdoc} */ - protected function configureFormFields(FormMapper $formMapper) + protected function configureFormFields(FormMapper $formMapper): void { // define group zoning $formMapper @@ -142,7 +144,7 @@ protected function configureFormFields(FormMapper $formMapper) /** * {@inheritdoc} */ - protected function configureListFields(ListMapper $listMapper) + protected function configureListFields(ListMapper $listMapper): void { $listMapper ->addIdentifier('name') @@ -155,7 +157,7 @@ protected function configureListFields(ListMapper $listMapper) /** * {@inheritdoc} */ - protected function configureDatagridFilters(DatagridMapper $datagridMapper) + protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { $datagridMapper ->add('name') diff --git a/src/Admin/GalleryItemAdmin.php b/src/Admin/GalleryItemAdmin.php index 9f4b2518b6..4d1c7ea3fd 100644 --- a/src/Admin/GalleryItemAdmin.php +++ b/src/Admin/GalleryItemAdmin.php @@ -1,5 +1,7 @@ add('media') diff --git a/src/Admin/ODM/MediaAdmin.php b/src/Admin/ODM/MediaAdmin.php index ea0aaca898..263fd3b0ab 100644 --- a/src/Admin/ODM/MediaAdmin.php +++ b/src/Admin/ODM/MediaAdmin.php @@ -1,5 +1,7 @@ add('name') diff --git a/src/Admin/ORM/MediaAdmin.php b/src/Admin/ORM/MediaAdmin.php index b77411383e..8bfa31bd1e 100644 --- a/src/Admin/ORM/MediaAdmin.php +++ b/src/Admin/ORM/MediaAdmin.php @@ -1,5 +1,7 @@ [], diff --git a/src/Admin/PHPCR/GalleryAdmin.php b/src/Admin/PHPCR/GalleryAdmin.php index 471888933b..4bad9c8185 100644 --- a/src/Admin/PHPCR/GalleryAdmin.php +++ b/src/Admin/PHPCR/GalleryAdmin.php @@ -1,5 +1,7 @@ root = $root; } @@ -57,7 +59,7 @@ public function id($object) /** * {@inheritdoc} */ - protected function configureDatagridFilters(DatagridMapper $datagridMapper) + protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { // TODO disabled filter due to no attached service for filter types: string, checkbox // $datagridMapper @@ -69,7 +71,7 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) /** * {@inheritdoc} */ - protected function configureRoutes(RouteCollection $collection) + protected function configureRoutes(RouteCollection $collection): void { // Allow path in id parameter $collection->add('view', $this->getRouterIdParameter().'/view', [], ['id' => '.+', '_method' => 'GET']); diff --git a/src/Admin/PHPCR/MediaAdmin.php b/src/Admin/PHPCR/MediaAdmin.php index c25b223eb7..dca53d01e3 100644 --- a/src/Admin/PHPCR/MediaAdmin.php +++ b/src/Admin/PHPCR/MediaAdmin.php @@ -1,5 +1,7 @@ root = $root; } @@ -57,7 +59,7 @@ public function id($object) /** * {@inheritdoc} */ - protected function configureDatagridFilters(DatagridMapper $datagridMapper) + protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { // TODO disabled filter due to no attached service for filter types: string, checkbox // $datagridMapper @@ -71,7 +73,7 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper) /** * {@inheritdoc} */ - protected function configureRoutes(RouteCollection $collection) + protected function configureRoutes(RouteCollection $collection): void { // Allow path in id parameter $collection->add('view', $this->getRouterIdParameter().'/view', [], ['id' => '.+', '_method' => 'GET']); diff --git a/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php b/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php index 31cf873961..1dc252cecf 100644 --- a/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php +++ b/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php @@ -1,5 +1,7 @@ setDefaults([ 'media' => false, @@ -45,7 +47,7 @@ public function configureSettings(OptionsResolver $resolver) /** * {@inheritdoc} */ - public function buildEditForm(FormMapper $formMapper, BlockInterface $block) + public function buildEditForm(FormMapper $formMapper, BlockInterface $block): void { $formatChoices = $this->getFormatChoices($block->getSetting('mediaId')); diff --git a/src/Block/GalleryBlockService.php b/src/Block/GalleryBlockService.php index c8c31aad71..9b17869b3e 100644 --- a/src/Block/GalleryBlockService.php +++ b/src/Block/GalleryBlockService.php @@ -1,5 +1,7 @@ setDefaults([ 'gallery' => false, @@ -102,7 +104,7 @@ public function configureSettings(OptionsResolver $resolver) /** * {@inheritdoc} */ - public function buildEditForm(FormMapper $formMapper, BlockInterface $block) + public function buildEditForm(FormMapper $formMapper, BlockInterface $block): void { $contextChoices = []; @@ -185,7 +187,7 @@ public function execute(BlockContextInterface $blockContext, Response $response /** * {@inheritdoc} */ - public function load(BlockInterface $block) + public function load(BlockInterface $block): void { $gallery = $block->getSetting('galleryId'); @@ -199,7 +201,7 @@ public function load(BlockInterface $block) /** * {@inheritdoc} */ - public function prePersist(BlockInterface $block) + public function prePersist(BlockInterface $block): void { $block->setSetting('galleryId', is_object($block->getSetting('galleryId')) ? $block->getSetting('galleryId')->getId() : null); } @@ -207,7 +209,7 @@ public function prePersist(BlockInterface $block) /** * {@inheritdoc} */ - public function preUpdate(BlockInterface $block) + public function preUpdate(BlockInterface $block): void { $block->setSetting('galleryId', is_object($block->getSetting('galleryId')) ? $block->getSetting('galleryId')->getId() : null); } diff --git a/src/Block/GalleryListBlockService.php b/src/Block/GalleryListBlockService.php index cd0841fb6f..906de65d73 100755 --- a/src/Block/GalleryListBlockService.php +++ b/src/Block/GalleryListBlockService.php @@ -1,5 +1,7 @@ setDefaults([ 'number' => 15, diff --git a/src/Block/MediaBlockService.php b/src/Block/MediaBlockService.php index de2a5892a5..04bbe29616 100644 --- a/src/Block/MediaBlockService.php +++ b/src/Block/MediaBlockService.php @@ -1,5 +1,7 @@ setDefaults([ 'media' => false, @@ -98,7 +100,7 @@ public function configureSettings(OptionsResolver $resolver) /** * {@inheritdoc} */ - public function buildEditForm(FormMapper $formMapper, BlockInterface $block) + public function buildEditForm(FormMapper $formMapper, BlockInterface $block): void { if (!$block->getSetting('mediaId') instanceof MediaInterface) { $this->load($block); @@ -148,7 +150,7 @@ public function execute(BlockContextInterface $blockContext, Response $response /** * {@inheritdoc} */ - public function load(BlockInterface $block) + public function load(BlockInterface $block): void { $media = $block->getSetting('mediaId', null); @@ -162,7 +164,7 @@ public function load(BlockInterface $block) /** * {@inheritdoc} */ - public function prePersist(BlockInterface $block) + public function prePersist(BlockInterface $block): void { $block->setSetting('mediaId', is_object($block->getSetting('mediaId')) ? $block->getSetting('mediaId')->getId() : null); } @@ -170,7 +172,7 @@ public function prePersist(BlockInterface $block) /** * {@inheritdoc} */ - public function preUpdate(BlockInterface $block) + public function preUpdate(BlockInterface $block): void { $block->setSetting('mediaId', is_object($block->getSetting('mediaId')) ? $block->getSetting('mediaId')->getId() : null); } diff --git a/src/CDN/CDNInterface.php b/src/CDN/CDNInterface.php index f9de7c1f79..01473d2780 100644 --- a/src/CDN/CDNInterface.php +++ b/src/CDN/CDNInterface.php @@ -1,5 +1,7 @@ client = $client; } diff --git a/src/CDN/Fallback.php b/src/CDN/Fallback.php index 4fd7817a5a..b2d0720aab 100644 --- a/src/CDN/Fallback.php +++ b/src/CDN/Fallback.php @@ -1,5 +1,7 @@ flushPaths([$string]); } @@ -95,7 +97,7 @@ public function flushByString($string) /** * {@inheritdoc} */ - public function flush($string) + public function flush($string): void { $this->flushPaths([$string]); } @@ -103,7 +105,7 @@ public function flush($string) /** * {@inheritdoc} */ - public function flushPaths(array $paths) + public function flushPaths(array $paths): void { $result = $this->getClient()->flush($this->username, $this->password, 'paths', $this->siteId, implode("\n", $paths), true, false); @@ -117,7 +119,7 @@ public function flushPaths(array $paths) * * @param $client */ - public function setClient($client) + public function setClient($client): void { $this->client = $client; } @@ -125,7 +127,7 @@ public function setClient($client) /** * {@inheritdoc} */ - public function getFlushStatus($identifier) + public function getFlushStatus($identifier): void { // nothing to do } diff --git a/src/CDN/Server.php b/src/CDN/Server.php index 12fdf9d271..00fc2a5469 100644 --- a/src/CDN/Server.php +++ b/src/CDN/Server.php @@ -1,5 +1,7 @@ setName('sonata:media:add-multiple') ->setDescription('Add medias in mass into the database') @@ -40,7 +42,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { $fp = $this->getFilePointer($input, $output); $imported = -1; @@ -92,7 +94,7 @@ protected function getFilePointer(InputInterface $input, OutputInterface $output * @param array $data * @param OutputInterface $output */ - protected function insertMedia(array $data, OutputInterface $output) + protected function insertMedia(array $data, OutputInterface $output): void { $media = $this->getMediaManager()->create(); @@ -108,7 +110,7 @@ protected function insertMedia(array $data, OutputInterface $output) } } - protected function optimize() + protected function optimize(): void { if ($this->getContainer()->has('doctrine')) { $this->getContainer()->get('doctrine')->getManager()->getUnitOfWork()->clear(); diff --git a/src/Command/AddMediaCommand.php b/src/Command/AddMediaCommand.php index 3b84ca78ea..09f865efdb 100644 --- a/src/Command/AddMediaCommand.php +++ b/src/Command/AddMediaCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:add') ->setDescription('Add a media into the database') @@ -52,7 +54,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { $provider = $input->getArgument('providerName'); $context = $input->getArgument('context'); diff --git a/src/Command/BaseCommand.php b/src/Command/BaseCommand.php index 58776bcf4e..221fd4ebf7 100644 --- a/src/Command/BaseCommand.php +++ b/src/Command/BaseCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:clean-uploads') ->setDescription('Find orphaned files in media upload directory') @@ -41,7 +43,7 @@ public function configure() /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output) + protected function execute(InputInterface $input, OutputInterface $output): void { $dryRun = (bool) $input->getOption('dry-run'); $verbose = $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE; diff --git a/src/Command/FixMediaContextCommand.php b/src/Command/FixMediaContextCommand.php index c45f910bb5..0fede188ad 100755 --- a/src/Command/FixMediaContextCommand.php +++ b/src/Command/FixMediaContextCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:fix-media-context'); $this->setDescription('Generate the default category for each media context'); @@ -30,7 +32,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { if (!$this->getContainer()->has('sonata.media.manager.category')) { throw new \LogicException('The classification feature is disabled.'); diff --git a/src/Command/MigrateToJsonTypeCommand.php b/src/Command/MigrateToJsonTypeCommand.php index 2706b7eca7..72f6a610db 100644 --- a/src/Command/MigrateToJsonTypeCommand.php +++ b/src/Command/MigrateToJsonTypeCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:migrate-json'); $this->addOption('table', null, InputOption::VALUE_OPTIONAL, 'Media table', 'media__media'); @@ -32,7 +34,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { $count = 0; $table = $input->getOption('table'); diff --git a/src/Command/RefreshMetadataCommand.php b/src/Command/RefreshMetadataCommand.php index 6b406d0207..74fa2f2916 100644 --- a/src/Command/RefreshMetadataCommand.php +++ b/src/Command/RefreshMetadataCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:refresh-metadata') ->setDescription('Refresh meta information') @@ -57,7 +59,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { $this->quiet = $input->getOption('quiet'); @@ -107,7 +109,7 @@ public function execute(InputInterface $input, OutputInterface $output) * * @param string $message */ - protected function log($message) + protected function log($message): void { if (false === $this->quiet) { $this->output->writeln($message); diff --git a/src/Command/RemoveThumbsCommand.php b/src/Command/RemoveThumbsCommand.php index 5350cba699..99a6ba47d6 100644 --- a/src/Command/RemoveThumbsCommand.php +++ b/src/Command/RemoveThumbsCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:remove-thumbnails') ->setDescription('Remove uploaded image thumbs') @@ -63,7 +65,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { $this->input = $input; $this->output = $output; @@ -233,7 +235,7 @@ protected function processMedia(MediaInterface $media, MediaProviderInterface $p * * @param string $message */ - protected function log($message) + protected function log($message): void { if (false === $this->quiet) { $this->output->writeln($message); diff --git a/src/Command/SyncThumbsCommand.php b/src/Command/SyncThumbsCommand.php index c4614067fc..6e1ecde966 100644 --- a/src/Command/SyncThumbsCommand.php +++ b/src/Command/SyncThumbsCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:sync-thumbnails') ->setDescription('Sync uploaded image thumbs with new media formats') @@ -56,7 +58,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { $helper = $this->getHelper('question'); @@ -187,7 +189,7 @@ protected function processMedia($media, $provider) * * @param string $message */ - protected function log($message) + protected function log($message): void { if (false === $this->quiet) { $this->output->writeln($message); diff --git a/src/Command/UpdateCdnStatusCommand.php b/src/Command/UpdateCdnStatusCommand.php index 3a0448008e..822cc63ff7 100644 --- a/src/Command/UpdateCdnStatusCommand.php +++ b/src/Command/UpdateCdnStatusCommand.php @@ -1,5 +1,7 @@ setName('sonata:media:update-cdn-status') ->setDescription('Refresh CDN status for medias that are in status flushing') @@ -59,7 +61,7 @@ public function configure() /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output) + public function execute(InputInterface $input, OutputInterface $output): void { $this->quiet = $input->getOption('quiet'); @@ -130,7 +132,7 @@ public function execute(InputInterface $input, OutputInterface $output) * @param string $message * @param bool|true $newLine */ - protected function log($message, $newLine = true) + protected function log($message, $newLine = true): void { if (false === $this->quiet) { if ($newLine) { diff --git a/src/Consumer/CreateThumbnailConsumer.php b/src/Consumer/CreateThumbnailConsumer.php index 098dab03c2..61d014dc96 100644 --- a/src/Consumer/CreateThumbnailConsumer.php +++ b/src/Consumer/CreateThumbnailConsumer.php @@ -1,5 +1,7 @@ mediaManager->findOneBy([ 'id' => $event->getMessage()->getValue('mediaId'), diff --git a/src/Controller/Api/GalleryController.php b/src/Controller/Api/GalleryController.php index ee40dd0d2b..dc1980a3b8 100644 --- a/src/Controller/Api/GalleryController.php +++ b/src/Controller/Api/GalleryController.php @@ -1,5 +1,7 @@ get('twig'); diff --git a/src/Controller/GalleryController.php b/src/Controller/GalleryController.php index c9265d394c..3b119f9a9d 100644 --- a/src/Controller/GalleryController.php +++ b/src/Controller/GalleryController.php @@ -1,5 +1,7 @@ get('twig'); diff --git a/src/Controller/MediaController.php b/src/Controller/MediaController.php index 53603aeaae..74d524bb84 100644 --- a/src/Controller/MediaController.php +++ b/src/Controller/MediaController.php @@ -1,5 +1,7 @@ getExtensionConfig($container); @@ -65,7 +67,7 @@ public function fixSettings(ContainerBuilder $container) /** * @param ContainerBuilder $container */ - public function attachProviders(ContainerBuilder $container) + public function attachProviders(ContainerBuilder $container): void { $pool = $container->getDefinition('sonata.media.pool'); foreach ($container->findTaggedServiceIds('sonata.media.provider') as $id => $attributes) { @@ -77,7 +79,7 @@ public function attachProviders(ContainerBuilder $container) * @param ContainerBuilder $container * @param array $settings */ - public function attachArguments(ContainerBuilder $container, array $settings) + public function attachArguments(ContainerBuilder $container, array $settings): void { foreach ($container->findTaggedServiceIds('sonata.media.provider') as $id => $attributes) { foreach ($settings['providers'] as $name => $config) { @@ -105,7 +107,7 @@ public function attachArguments(ContainerBuilder $container, array $settings) * @param ContainerBuilder $container * @param array $settings */ - public function applyFormats(ContainerBuilder $container, array $settings) + public function applyFormats(ContainerBuilder $container, array $settings): void { foreach ($settings['contexts'] as $name => $context) { // add the different related formats @@ -113,10 +115,10 @@ public function applyFormats(ContainerBuilder $container, array $settings) $definition = $container->getDefinition($id); foreach ($context['formats'] as $format => $config) { - $config['quality'] = isset($config['quality']) ? $config['quality'] : 80; - $config['format'] = isset($config['format']) ? $config['format'] : 'jpg'; - $config['height'] = isset($config['height']) ? $config['height'] : false; - $config['constraint'] = isset($config['constraint']) ? $config['constraint'] : true; + $config['quality'] = $config['quality'] ?? 80; + $config['format'] = $config['format'] ?? 'jpg'; + $config['height'] = $config['height'] ?? false; + $config['constraint'] = $config['constraint'] ?? true; $formatName = sprintf('%s_%s', $name, $format); $definition->addMethodCall('addFormat', [$formatName, $config]); diff --git a/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php b/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php index 8668a16799..53717e2b04 100644 --- a/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php +++ b/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php @@ -1,5 +1,7 @@ getDefinition('twig')->addMethodCall('addGlobal', ['sonata_media', new Reference('sonata.media.twig.global')]); } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 32db7c2692..627b5bcc56 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -1,5 +1,7 @@ children() @@ -113,7 +115,7 @@ private function addContextsSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addCdnSection(ArrayNodeDefinition $node) + private function addCdnSection(ArrayNodeDefinition $node): void { $node ->children() @@ -165,7 +167,7 @@ private function addCdnSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addFilesystemSection(ArrayNodeDefinition $node) + private function addFilesystemSection(ArrayNodeDefinition $node): void { $node ->children() @@ -289,7 +291,7 @@ private function addFilesystemSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addProvidersSection(ArrayNodeDefinition $node) + private function addProvidersSection(ArrayNodeDefinition $node): void { $node ->children() @@ -400,7 +402,7 @@ private function addProvidersSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addExtraSection(ArrayNodeDefinition $node) + private function addExtraSection(ArrayNodeDefinition $node): void { $node ->children() @@ -409,7 +411,7 @@ private function addExtraSection(ArrayNodeDefinition $node) ->addDefaultsIfNotSet() ->children() ->scalarNode('enabled')->defaultValue(false)->end() - ->scalarNode('secret')->defaultValue(sha1(uniqid(rand(1, 9999), true)))->end() + ->scalarNode('secret')->defaultValue(sha1(uniqid(random_int(1, 9999), true)))->end() ->scalarNode('referrer')->defaultValue('Sonata Media')->end() ->end() ->end() @@ -420,7 +422,7 @@ private function addExtraSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addModelSection(ArrayNodeDefinition $node) + private function addModelSection(ArrayNodeDefinition $node): void { $node ->children() @@ -441,7 +443,7 @@ private function addModelSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addBuzzSection(ArrayNodeDefinition $node) + private function addBuzzSection(ArrayNodeDefinition $node): void { $node ->children() @@ -467,7 +469,7 @@ private function addBuzzSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addResizerSection(ArrayNodeDefinition $node) + private function addResizerSection(ArrayNodeDefinition $node): void { $node ->children() @@ -501,7 +503,7 @@ private function addResizerSection(ArrayNodeDefinition $node) /** * @param ArrayNodeDefinition $node */ - private function addAdapterSection(ArrayNodeDefinition $node) + private function addAdapterSection(ArrayNodeDefinition $node): void { $node ->children() diff --git a/src/DependencyInjection/SonataMediaExtension.php b/src/DependencyInjection/SonataMediaExtension.php index a44c18ba82..5a60331d88 100644 --- a/src/DependencyInjection/SonataMediaExtension.php +++ b/src/DependencyInjection/SonataMediaExtension.php @@ -1,5 +1,7 @@ getDefinition('sonata.media.provider.image') ->replaceArgument(5, array_map('strtolower', $config['providers']['image']['allowed_extensions'])) @@ -185,7 +187,7 @@ public function configureProviders(ContainerBuilder $container, array $config) * @param ContainerBuilder $container * @param array $config */ - public function configureBuzz(ContainerBuilder $container, array $config) + public function configureBuzz(ContainerBuilder $container, array $config): void { $container->getDefinition('sonata.media.buzz.browser') ->replaceArgument(0, new Reference($config['buzz']['connector'])); @@ -207,7 +209,7 @@ public function configureBuzz(ContainerBuilder $container, array $config) * @param ContainerBuilder $container * @param array $config */ - public function configureParameterClass(ContainerBuilder $container, array $config) + public function configureParameterClass(ContainerBuilder $container, array $config): void { $container->setParameter('sonata.media.admin.media.entity', $config['class']['media']); $container->setParameter('sonata.media.admin.gallery.entity', $config['class']['gallery']); @@ -222,7 +224,7 @@ public function configureParameterClass(ContainerBuilder $container, array $conf /** * @param array $config */ - public function registerDoctrineMapping(array $config) + public function registerDoctrineMapping(array $config): void { $collector = DoctrineCollector::getInstance(); @@ -312,7 +314,7 @@ public function registerDoctrineMapping(array $config) * @param ContainerBuilder $container * @param array $config */ - public function configureCdnAdapter(ContainerBuilder $container, array $config) + public function configureCdnAdapter(ContainerBuilder $container, array $config): void { // add the default configuration for the server cdn if ($container->hasDefinition('sonata.media.cdn.server') && isset($config['cdn']['server'])) { @@ -361,7 +363,7 @@ public function configureCdnAdapter(ContainerBuilder $container, array $config) * @param ContainerBuilder $container * @param array $config */ - public function configureFilesystemAdapter(ContainerBuilder $container, array $config) + public function configureFilesystemAdapter(ContainerBuilder $container, array $config): void { // add the default configuration for the local filesystem if ($container->hasDefinition('sonata.media.adapter.filesystem.local') && isset($config['filesystem']['local'])) { @@ -484,7 +486,7 @@ public function configureFilesystemAdapter(ContainerBuilder $container, array $c * @param ContainerBuilder $container * @param array $config */ - public function configureExtra(ContainerBuilder $container, array $config) + public function configureExtra(ContainerBuilder $container, array $config): void { if ($config['pixlr']['enabled']) { $container->getDefinition('sonata.media.extra.pixlr') @@ -499,7 +501,7 @@ public function configureExtra(ContainerBuilder $container, array $config) /** * Add class to compile. */ - public function configureClassesToCompile() + public function configureClassesToCompile(): void { if (\PHP_VERSION_ID >= 70000) { return; @@ -561,7 +563,7 @@ public function configureClassesToCompile() * * @param ContainerBuilder $container */ - public function prepend(ContainerBuilder $container) + public function prepend(ContainerBuilder $container): void { $bundles = $container->getParameter('kernel.bundles'); @@ -588,7 +590,7 @@ private function isClassificationEnabled(array $config) * @param ContainerBuilder $container * @param array $config */ - private function configureAdapters(ContainerBuilder $container, array $config) + private function configureAdapters(ContainerBuilder $container, array $config): void { foreach (['gd', 'imagick', 'gmagick'] as $adapter) { if ($container->hasParameter('sonata.media.adapter.image.'.$adapter.'.class')) { @@ -602,7 +604,7 @@ private function configureAdapters(ContainerBuilder $container, array $config) * @param ContainerBuilder $container * @param array $config */ - private function configureResizers(ContainerBuilder $container, array $config) + private function configureResizers(ContainerBuilder $container, array $config): void { if ($container->hasParameter('sonata.media.resizer.simple.class')) { $class = $container->getParameter('sonata.media.resizer.simple.class'); diff --git a/src/Document/BaseGallery.php b/src/Document/BaseGallery.php index 8644f46a0b..32455ce635 100644 --- a/src/Document/BaseGallery.php +++ b/src/Document/BaseGallery.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -39,7 +41,7 @@ public function prePersist() /** * Pre Update method. */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Document/BaseGalleryItem.php b/src/Document/BaseGalleryItem.php index d527045b9e..015e5d19a6 100644 --- a/src/Document/BaseGalleryItem.php +++ b/src/Document/BaseGalleryItem.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); } - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Document/BaseMedia.php b/src/Document/BaseMedia.php index da6ba7ad99..4b86adea05 100644 --- a/src/Document/BaseMedia.php +++ b/src/Document/BaseMedia.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -27,7 +29,7 @@ public function prePersist() /** * {@inheritdoc} */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Document/GalleryManager.php b/src/Document/GalleryManager.php index 09d3234cac..3ffa5eac13 100644 --- a/src/Document/GalleryManager.php +++ b/src/Document/GalleryManager.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -39,7 +41,7 @@ public function prePersist() /** * Pre Update method. */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Entity/BaseGalleryItem.php b/src/Entity/BaseGalleryItem.php index 6fae702618..51e7032d6d 100644 --- a/src/Entity/BaseGalleryItem.php +++ b/src/Entity/BaseGalleryItem.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); } - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Entity/BaseMedia.php b/src/Entity/BaseMedia.php index fd0736edbd..ed27ecdcb2 100644 --- a/src/Entity/BaseMedia.php +++ b/src/Entity/BaseMedia.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -27,7 +29,7 @@ public function prePersist() /** * {@inheritdoc} */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/Entity/GalleryManager.php b/src/Entity/GalleryManager.php index adc7f5a4ea..a668f883ba 100644 --- a/src/Entity/GalleryManager.php +++ b/src/Entity/GalleryManager.php @@ -1,5 +1,7 @@ extension = $extension; } @@ -73,7 +75,7 @@ public function getMimetype() /** * @param string $mimetype */ - public function setMimetype($mimetype) + public function setMimetype($mimetype): void { $this->mimetype = $mimetype; } diff --git a/src/Extra/Pixlr.php b/src/Extra/Pixlr.php index 80e3141ab5..89d00601bf 100644 --- a/src/Extra/Pixlr.php +++ b/src/Extra/Pixlr.php @@ -1,5 +1,7 @@ generateHash($media)) { throw new NotFoundHttpException('Invalid hash'); diff --git a/src/Filesystem/Local.php b/src/Filesystem/Local.php index 86c826ba82..eabed27c1f 100644 --- a/src/Filesystem/Local.php +++ b/src/Filesystem/Local.php @@ -1,5 +1,7 @@ master instanceof MetadataSupporter) { $this->master->setMetadata($key, $metadata); diff --git a/src/Form/DataTransformer/ProviderDataTransformer.php b/src/Form/DataTransformer/ProviderDataTransformer.php index 6b4473f5e4..b95e6631d9 100644 --- a/src/Form/DataTransformer/ProviderDataTransformer.php +++ b/src/Form/DataTransformer/ProviderDataTransformer.php @@ -1,5 +1,7 @@ mediaPool, $this->class, [ 'empty_on_new' => false, @@ -67,7 +69,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ 'provider_name' => 'sonata.media.provider.image', diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index 5c259dc640..32be642a02 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -1,5 +1,7 @@ pool, $this->class, [ 'provider' => $options['provider'], @@ -66,7 +68,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->addModelTransformer($dataTransformer); - $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) { + $builder->addEventListener(FormEvents::SUBMIT, function (FormEvent $event): void { if ($event->getForm()->has('unlink') && $event->getForm()->get('unlink')->getData()) { $event->setData(null); } @@ -85,7 +87,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) /** * {@inheritdoc} */ - public function buildView(FormView $view, FormInterface $form, array $options) + public function buildView(FormView $view, FormInterface $form, array $options): void { $view->vars['provider'] = $options['provider']; $view->vars['context'] = $options['context']; @@ -94,7 +96,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} */ - public function configureOptions(OptionsResolver $resolver) + public function configureOptions(OptionsResolver $resolver): void { $resolver ->setDefaults([ diff --git a/src/Generator/DefaultGenerator.php b/src/Generator/DefaultGenerator.php index 8ae4af8de2..be5e398419 100644 --- a/src/Generator/DefaultGenerator.php +++ b/src/Generator/DefaultGenerator.php @@ -1,5 +1,7 @@ getProvider($args))) { return; @@ -55,7 +57,7 @@ public function postUpdate(EventArgs $args) /** * @param EventArgs $args */ - public function postRemove(EventArgs $args) + public function postRemove(EventArgs $args): void { if (!($provider = $this->getProvider($args))) { return; @@ -67,7 +69,7 @@ public function postRemove(EventArgs $args) /** * @param EventArgs $args */ - public function postPersist(EventArgs $args) + public function postPersist(EventArgs $args): void { if (!($provider = $this->getProvider($args))) { return; @@ -79,7 +81,7 @@ public function postPersist(EventArgs $args) /** * @param EventArgs $args */ - public function preUpdate(EventArgs $args) + public function preUpdate(EventArgs $args): void { if (!($provider = $this->getProvider($args))) { return; @@ -94,7 +96,7 @@ public function preUpdate(EventArgs $args) /** * @param EventArgs $args */ - public function preRemove(EventArgs $args) + public function preRemove(EventArgs $args): void { if (!($provider = $this->getProvider($args))) { return; @@ -106,7 +108,7 @@ public function preRemove(EventArgs $args) /** * @param EventArgs $args */ - public function prePersist(EventArgs $args) + public function prePersist(EventArgs $args): void { if (!($provider = $this->getProvider($args))) { return; diff --git a/src/Listener/ODM/MediaEventSubscriber.php b/src/Listener/ODM/MediaEventSubscriber.php index 7da813425b..e61db33c59 100644 --- a/src/Listener/ODM/MediaEventSubscriber.php +++ b/src/Listener/ODM/MediaEventSubscriber.php @@ -1,5 +1,7 @@ getDocumentManager(); diff --git a/src/Listener/ORM/MediaEventSubscriber.php b/src/Listener/ORM/MediaEventSubscriber.php index 386066d19f..e2de2ac9a7 100644 --- a/src/Listener/ORM/MediaEventSubscriber.php +++ b/src/Listener/ORM/MediaEventSubscriber.php @@ -1,5 +1,7 @@ rootCategories = null; } @@ -48,7 +50,7 @@ public function onClear() /** * {@inheritdoc} */ - protected function recomputeSingleEntityChangeSet(EventArgs $args) + protected function recomputeSingleEntityChangeSet(EventArgs $args): void { $em = $args->getEntityManager(); diff --git a/src/Listener/PHPCR/MediaEventSubscriber.php b/src/Listener/PHPCR/MediaEventSubscriber.php index ff2cce5e31..7c0fc63c73 100644 --- a/src/Listener/PHPCR/MediaEventSubscriber.php +++ b/src/Listener/PHPCR/MediaEventSubscriber.php @@ -1,5 +1,7 @@ categoryManager->save($category); } diff --git a/src/Model/CategoryManagerInterface.php b/src/Model/CategoryManagerInterface.php index 935eab6e8c..d2538edabf 100644 --- a/src/Model/CategoryManagerInterface.php +++ b/src/Model/CategoryManagerInterface.php @@ -1,5 +1,7 @@ name = $name; } @@ -78,7 +80,7 @@ public function getName() /** * {@inheritdoc} */ - public function setEnabled($enabled) + public function setEnabled($enabled): void { $this->enabled = $enabled; } @@ -94,7 +96,7 @@ public function getEnabled() /** * {@inheritdoc} */ - public function setUpdatedAt(\DateTime $updatedAt = null) + public function setUpdatedAt(\DateTime $updatedAt = null): void { $this->updatedAt = $updatedAt; } @@ -110,7 +112,7 @@ public function getUpdatedAt() /** * {@inheritdoc} */ - public function setCreatedAt(\DateTime $createdAt = null) + public function setCreatedAt(\DateTime $createdAt = null): void { $this->createdAt = $createdAt; } @@ -126,7 +128,7 @@ public function getCreatedAt() /** * {@inheritdoc} */ - public function setDefaultFormat($defaultFormat) + public function setDefaultFormat($defaultFormat): void { $this->defaultFormat = $defaultFormat; } @@ -142,7 +144,7 @@ public function getDefaultFormat() /** * {@inheritdoc} */ - public function setGalleryItems($galleryItems) + public function setGalleryItems($galleryItems): void { $this->galleryItems = new ArrayCollection(); @@ -162,7 +164,7 @@ public function getGalleryItems() /** * {@inheritdoc} */ - public function addGalleryItem(GalleryItemInterface $galleryItem) + public function addGalleryItem(GalleryItemInterface $galleryItem): void { $galleryItem->setGallery($this); @@ -172,7 +174,7 @@ public function addGalleryItem(GalleryItemInterface $galleryItem) /** * {@inheritdoc} */ - public function setContext($context) + public function setContext($context): void { $this->context = $context; } diff --git a/src/Model/GalleryInterface.php b/src/Model/GalleryInterface.php index 40f21cae66..fcb8dabeb7 100644 --- a/src/Model/GalleryInterface.php +++ b/src/Model/GalleryInterface.php @@ -1,5 +1,7 @@ createdAt = $createdAt; } @@ -70,7 +72,7 @@ public function getCreatedAt() /** * {@inheritdoc} */ - public function setEnabled($enabled) + public function setEnabled($enabled): void { $this->enabled = $enabled; } @@ -86,7 +88,7 @@ public function getEnabled() /** * {@inheritdoc} */ - public function setGallery(GalleryInterface $gallery = null) + public function setGallery(GalleryInterface $gallery = null): void { $this->gallery = $gallery; } @@ -102,7 +104,7 @@ public function getGallery() /** * {@inheritdoc} */ - public function setMedia(MediaInterface $media = null) + public function setMedia(MediaInterface $media = null): void { $this->media = $media; } @@ -118,7 +120,7 @@ public function getMedia() /** * {@inheritdoc} */ - public function setPosition($position) + public function setPosition($position): void { $this->position = $position; } @@ -134,7 +136,7 @@ public function getPosition() /** * {@inheritdoc} */ - public function setUpdatedAt(\DateTime $updatedAt = null) + public function setUpdatedAt(\DateTime $updatedAt = null): void { $this->updatedAt = $updatedAt; } diff --git a/src/Model/GalleryItemInterface.php b/src/Model/GalleryItemInterface.php index 75c4aae3ef..cd68c90ddb 100644 --- a/src/Model/GalleryItemInterface.php +++ b/src/Model/GalleryItemInterface.php @@ -1,5 +1,7 @@ getName() ?: 'n/a'; } - public function prePersist() + public function prePersist(): void { $this->setCreatedAt(new \DateTime()); $this->setUpdatedAt(new \DateTime()); } - public function preUpdate() + public function preUpdate(): void { $this->setUpdatedAt(new \DateTime()); } @@ -179,7 +181,7 @@ public static function getStatusList() /** * {@inheritdoc} */ - public function setBinaryContent($binaryContent) + public function setBinaryContent($binaryContent): void { $this->previousProviderReference = $this->providerReference; $this->providerReference = null; @@ -189,7 +191,7 @@ public function setBinaryContent($binaryContent) /** * {@inheritdoc} */ - public function resetBinaryContent() + public function resetBinaryContent(): void { $this->binaryContent = null; } @@ -209,13 +211,13 @@ public function getMetadataValue($name, $default = null) { $metadata = $this->getProviderMetadata(); - return isset($metadata[$name]) ? $metadata[$name] : $default; + return $metadata[$name] ?? $default; } /** * {@inheritdoc} */ - public function setMetadataValue($name, $value) + public function setMetadataValue($name, $value): void { $metadata = $this->getProviderMetadata(); $metadata[$name] = $value; @@ -225,7 +227,7 @@ public function setMetadataValue($name, $value) /** * {@inheritdoc} */ - public function unsetMetadataValue($name) + public function unsetMetadataValue($name): void { $metadata = $this->getProviderMetadata(); unset($metadata[$name]); @@ -235,7 +237,7 @@ public function unsetMetadataValue($name) /** * {@inheritdoc} */ - public function setName($name) + public function setName($name): void { $this->name = $name; } @@ -251,7 +253,7 @@ public function getName() /** * {@inheritdoc} */ - public function setDescription($description) + public function setDescription($description): void { $this->description = $description; } @@ -267,7 +269,7 @@ public function getDescription() /** * {@inheritdoc} */ - public function setEnabled($enabled) + public function setEnabled($enabled): void { $this->enabled = $enabled; } @@ -283,7 +285,7 @@ public function getEnabled() /** * {@inheritdoc} */ - public function setProviderName($providerName) + public function setProviderName($providerName): void { $this->providerName = $providerName; } @@ -299,7 +301,7 @@ public function getProviderName() /** * {@inheritdoc} */ - public function setProviderStatus($providerStatus) + public function setProviderStatus($providerStatus): void { $this->providerStatus = $providerStatus; } @@ -315,7 +317,7 @@ public function getProviderStatus() /** * {@inheritdoc} */ - public function setProviderReference($providerReference) + public function setProviderReference($providerReference): void { $this->providerReference = $providerReference; } @@ -331,7 +333,7 @@ public function getProviderReference() /** * {@inheritdoc} */ - public function setProviderMetadata(array $providerMetadata = []) + public function setProviderMetadata(array $providerMetadata = []): void { $this->providerMetadata = $providerMetadata; } @@ -347,7 +349,7 @@ public function getProviderMetadata() /** * {@inheritdoc} */ - public function setWidth($width) + public function setWidth($width): void { $this->width = $width; } @@ -363,7 +365,7 @@ public function getWidth() /** * {@inheritdoc} */ - public function setHeight($height) + public function setHeight($height): void { $this->height = $height; } @@ -379,7 +381,7 @@ public function getHeight() /** * {@inheritdoc} */ - public function setLength($length) + public function setLength($length): void { $this->length = $length; } @@ -395,7 +397,7 @@ public function getLength() /** * {@inheritdoc} */ - public function setCopyright($copyright) + public function setCopyright($copyright): void { $this->copyright = $copyright; } @@ -411,7 +413,7 @@ public function getCopyright() /** * {@inheritdoc} */ - public function setAuthorName($authorName) + public function setAuthorName($authorName): void { $this->authorName = $authorName; } @@ -427,7 +429,7 @@ public function getAuthorName() /** * {@inheritdoc} */ - public function setContext($context) + public function setContext($context): void { $this->context = $context; } @@ -443,7 +445,7 @@ public function getContext() /** * {@inheritdoc} */ - public function setCdnIsFlushable($cdnIsFlushable) + public function setCdnIsFlushable($cdnIsFlushable): void { $this->cdnIsFlushable = $cdnIsFlushable; } @@ -459,7 +461,7 @@ public function getCdnIsFlushable() /** * {@inheritdoc} */ - public function setCdnFlushIdentifier($cdnFlushIdentifier) + public function setCdnFlushIdentifier($cdnFlushIdentifier): void { $this->cdnFlushIdentifier = $cdnFlushIdentifier; } @@ -475,7 +477,7 @@ public function getCdnFlushIdentifier() /** * {@inheritdoc} */ - public function setCdnFlushAt(\DateTime $cdnFlushAt = null) + public function setCdnFlushAt(\DateTime $cdnFlushAt = null): void { $this->cdnFlushAt = $cdnFlushAt; } @@ -491,7 +493,7 @@ public function getCdnFlushAt() /** * {@inheritdoc} */ - public function setUpdatedAt(\DateTime $updatedAt = null) + public function setUpdatedAt(\DateTime $updatedAt = null): void { $this->updatedAt = $updatedAt; } @@ -507,7 +509,7 @@ public function getUpdatedAt() /** * {@inheritdoc} */ - public function setCreatedAt(\DateTime $createdAt = null) + public function setCreatedAt(\DateTime $createdAt = null): void { $this->createdAt = $createdAt; } @@ -523,7 +525,7 @@ public function getCreatedAt() /** * {@inheritdoc} */ - public function setContentType($contentType) + public function setContentType($contentType): void { $this->contentType = $contentType; } @@ -548,7 +550,7 @@ public function getExtension() /** * {@inheritdoc} */ - public function setSize($size) + public function setSize($size): void { $this->size = $size; } @@ -564,7 +566,7 @@ public function getSize() /** * {@inheritdoc} */ - public function setCdnStatus($cdnStatus) + public function setCdnStatus($cdnStatus): void { $this->cdnStatus = $cdnStatus; } @@ -588,7 +590,7 @@ public function getBox() /** * {@inheritdoc} */ - public function setGalleryItems($galleryItems) + public function setGalleryItems($galleryItems): void { $this->galleryItems = $galleryItems; } @@ -612,7 +614,7 @@ public function getPreviousProviderReference() /** * @param ExecutionContextInterface $context */ - public function isStatusErroneous(ExecutionContextInterface $context) + public function isStatusErroneous(ExecutionContextInterface $context): void { if ($this->getBinaryContent() && self::STATUS_ERROR == $this->getProviderStatus()) { $context->buildViolation('invalid')->atPath('binaryContent')->addViolation(); @@ -630,7 +632,7 @@ public function getCategory() /** * @param CategoryInterface|null $category */ - public function setCategory($category = null) + public function setCategory($category = null): void { if (null !== $category && !is_a($category, 'Sonata\ClassificationBundle\Model\CategoryInterface')) { throw new \InvalidArgumentException( diff --git a/src/Model/MediaInterface.php b/src/Model/MediaInterface.php index 36a768ecb3..c5ef6b9889 100644 --- a/src/Model/MediaInterface.php +++ b/src/Model/MediaInterface.php @@ -1,5 +1,7 @@ setGallery($this); @@ -62,7 +64,7 @@ public function addGalleryItem(GalleryItemInterface $galleryItem) /** * Pre persist method. */ - public function prePersist() + public function prePersist(): void { $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -73,7 +75,7 @@ public function prePersist() /** * Pre Update method. */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); @@ -83,7 +85,7 @@ public function preUpdate() /** * Reorders gallery items based on their position. */ - public function reorderGalleryItems() + public function reorderGalleryItems(): void { if ($this->getGalleryItems() && $this->getGalleryItems() instanceof \IteratorAggregate) { // reorder diff --git a/src/PHPCR/BaseGalleryItem.php b/src/PHPCR/BaseGalleryItem.php index a5d72f1d8c..c4bde486e2 100644 --- a/src/PHPCR/BaseGalleryItem.php +++ b/src/PHPCR/BaseGalleryItem.php @@ -1,5 +1,7 @@ nodename = $nodename; } @@ -40,13 +42,13 @@ public function getNodename() return $this->nodename; } - public function prePersist() + public function prePersist(): void { $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); } - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/PHPCR/BaseGalleryItemRepository.php b/src/PHPCR/BaseGalleryItemRepository.php index dd321fd846..6dfbf7fc10 100644 --- a/src/PHPCR/BaseGalleryItemRepository.php +++ b/src/PHPCR/BaseGalleryItemRepository.php @@ -1,5 +1,7 @@ createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); @@ -42,7 +44,7 @@ public function prePersist() /** * {@inheritdoc} */ - public function preUpdate() + public function preUpdate(): void { $this->updatedAt = new \DateTime(); } diff --git a/src/PHPCR/BaseMediaRepository.php b/src/PHPCR/BaseMediaRepository.php index 28297eaafc..00916df4e4 100644 --- a/src/PHPCR/BaseMediaRepository.php +++ b/src/PHPCR/BaseMediaRepository.php @@ -1,5 +1,7 @@ getBinaryContent()) { return; @@ -94,7 +96,7 @@ final public function transform(MediaInterface $media) /** * @param MediaInterface $media */ - public function flushCdn(MediaInterface $media) + public function flushCdn(MediaInterface $media): void { if ($media->getId() && $this->requireThumbnails() && !$media->getCdnIsFlushable()) { $flushPaths = []; @@ -116,7 +118,7 @@ public function flushCdn(MediaInterface $media) /** * {@inheritdoc} */ - public function addFormat($name, $format) + public function addFormat($name, $format): void { $this->formats[$name] = $format; } @@ -140,7 +142,7 @@ public function requireThumbnails() /** * {@inheritdoc} */ - public function generateThumbnails(MediaInterface $media) + public function generateThumbnails(MediaInterface $media): void { $this->thumbnail->generate($this, $media); } @@ -148,7 +150,7 @@ public function generateThumbnails(MediaInterface $media) /** * {@inheritdoc} */ - public function removeThumbnails(MediaInterface $media, $formats = null) + public function removeThumbnails(MediaInterface $media, $formats = null): void { $this->thumbnail->delete($this, $media, $formats); } @@ -185,14 +187,14 @@ public function getProviderMetadata() /** * {@inheritdoc} */ - public function preRemove(MediaInterface $media) + public function preRemove(MediaInterface $media): void { } /** * {@inheritdoc} */ - public function postRemove(MediaInterface $media) + public function postRemove(MediaInterface $media): void { $path = $this->getReferenceImage($media); @@ -224,7 +226,7 @@ public function getFormats() /** * {@inheritdoc} */ - public function setName($name) + public function setName($name): void { $this->name = $name; } @@ -240,7 +242,7 @@ public function getName() /** * {@inheritdoc} */ - public function setTemplates(array $templates) + public function setTemplates(array $templates): void { $this->templates = $templates; } @@ -296,7 +298,7 @@ public function getCdnPath($relativePath, $isFlushable) /** * {@inheritdoc} */ - public function setResizer(ResizerInterface $resizer) + public function setResizer(ResizerInterface $resizer): void { $this->resizer = $resizer; } @@ -304,7 +306,7 @@ public function setResizer(ResizerInterface $resizer) /** * {@inheritdoc} */ - public function prePersist(MediaInterface $media) + public function prePersist(MediaInterface $media): void { $media->setCreatedAt(new \Datetime()); $media->setUpdatedAt(new \Datetime()); @@ -313,7 +315,7 @@ public function prePersist(MediaInterface $media) /** * {@inheritdoc} */ - public function preUpdate(MediaInterface $media) + public function preUpdate(MediaInterface $media): void { $media->setUpdatedAt(new \Datetime()); } @@ -321,7 +323,7 @@ public function preUpdate(MediaInterface $media) /** * {@inheritdoc} */ - public function validate(ErrorElement $errorElement, MediaInterface $media) + public function validate(ErrorElement $errorElement, MediaInterface $media): void { } diff --git a/src/Provider/BaseVideoProvider.php b/src/Provider/BaseVideoProvider.php index 10349433ed..f8c56da1e6 100644 --- a/src/Provider/BaseVideoProvider.php +++ b/src/Provider/BaseVideoProvider.php @@ -1,5 +1,7 @@ add('name'); $formMapper->add('enabled', null, ['required' => false]); @@ -136,7 +138,7 @@ public function buildEditForm(FormMapper $formMapper) /** * {@inheritdoc} */ - public function buildCreateForm(FormMapper $formMapper) + public function buildCreateForm(FormMapper $formMapper): void { $formMapper->add('binaryContent', TextType::class, [ 'constraints' => [ @@ -149,7 +151,7 @@ public function buildCreateForm(FormMapper $formMapper) /** * {@inheritdoc} */ - public function buildMediaType(FormBuilder $formBuilder) + public function buildMediaType(FormBuilder $formBuilder): void { $formBuilder->add('binaryContent', TextType::class, [ 'label' => 'widget_label_binary_content', @@ -159,7 +161,7 @@ public function buildMediaType(FormBuilder $formBuilder) /** * {@inheritdoc} */ - public function postUpdate(MediaInterface $media) + public function postUpdate(MediaInterface $media): void { $this->postPersist($media); } @@ -167,7 +169,7 @@ public function postUpdate(MediaInterface $media) /** * {@inheritdoc} */ - public function postPersist(MediaInterface $media) + public function postPersist(MediaInterface $media): void { if (!$media->getBinaryContent()) { return; @@ -181,7 +183,7 @@ public function postPersist(MediaInterface $media) /** * {@inheritdoc} */ - public function postRemove(MediaInterface $media) + public function postRemove(MediaInterface $media): void { } @@ -235,8 +237,8 @@ protected function getBoxHelperProperties(MediaInterface $media, $format, $optio if (isset($options['width']) || isset($options['height'])) { $settings = [ - 'width' => isset($options['width']) ? $options['width'] : null, - 'height' => isset($options['height']) ? $options['height'] : null, + 'width' => $options['width'] ?? null, + 'height' => $options['height'] ?? null, ]; } else { $settings = $this->getFormat($format); diff --git a/src/Provider/DailyMotionProvider.php b/src/Provider/DailyMotionProvider.php index bcf97a6e6e..0c0b6d7384 100644 --- a/src/Provider/DailyMotionProvider.php +++ b/src/Provider/DailyMotionProvider.php @@ -1,5 +1,7 @@ null, ]; - $player_parameters = array_merge($defaults, isset($options['player_parameters']) ? $options['player_parameters'] : []); + $player_parameters = array_merge($defaults, $options['player_parameters'] ?? []); $box = $this->getBoxHelperProperties($media, $format, $options); $params = [ 'player_parameters' => http_build_query($player_parameters), - 'allowFullScreen' => isset($options['allowFullScreen']) ? $options['allowFullScreen'] : 'true', - 'allowScriptAccess' => isset($options['allowScriptAccess']) ? $options['allowScriptAccess'] : 'always', + 'allowFullScreen' => $options['allowFullScreen'] ?? 'true', + 'allowScriptAccess' => $options['allowScriptAccess'] ?? 'always', 'width' => $box->getWidth(), 'height' => $box->getHeight(), ]; @@ -96,7 +98,7 @@ public function getProviderMetadata() /** * {@inheritdoc} */ - public function updateMetadata(MediaInterface $media, $force = false) + public function updateMetadata(MediaInterface $media, $force = false): void { $url = sprintf('http://www.dailymotion.com/services/oembed?url=%s&format=json', $this->getReferenceUrl($media)); @@ -143,7 +145,7 @@ public function getReferenceUrl(MediaInterface $media) /** * @param MediaInterface $media */ - protected function fixBinaryContent(MediaInterface $media) + protected function fixBinaryContent(MediaInterface $media): void { if (!$media->getBinaryContent()) { return; @@ -157,7 +159,7 @@ protected function fixBinaryContent(MediaInterface $media) /** * {@inheritdoc} */ - protected function doTransform(MediaInterface $media) + protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); diff --git a/src/Provider/FileProvider.php b/src/Provider/FileProvider.php index 2f34615246..3ffcba37bb 100644 --- a/src/Provider/FileProvider.php +++ b/src/Provider/FileProvider.php @@ -1,5 +1,7 @@ add('name'); $formMapper->add('enabled', null, ['required' => false]); @@ -104,7 +106,7 @@ public function buildEditForm(FormMapper $formMapper) /** * {@inheritdoc} */ - public function buildCreateForm(FormMapper $formMapper) + public function buildCreateForm(FormMapper $formMapper): void { $formMapper->add('binaryContent', FileType::class, [ 'constraints' => [ @@ -117,7 +119,7 @@ public function buildCreateForm(FormMapper $formMapper) /** * {@inheritdoc} */ - public function buildMediaType(FormBuilder $formBuilder) + public function buildMediaType(FormBuilder $formBuilder): void { if ('api' == $formBuilder->getOption('context')) { $formBuilder->add('binaryContent', FileType::class); @@ -133,7 +135,7 @@ public function buildMediaType(FormBuilder $formBuilder) /** * {@inheritdoc} */ - public function postPersist(MediaInterface $media) + public function postPersist(MediaInterface $media): void { if (null === $media->getBinaryContent()) { return; @@ -149,7 +151,7 @@ public function postPersist(MediaInterface $media) /** * {@inheritdoc} */ - public function postUpdate(MediaInterface $media) + public function postUpdate(MediaInterface $media): void { if (!$media->getBinaryContent() instanceof \SplFileInfo) { return; @@ -181,7 +183,7 @@ public function postUpdate(MediaInterface $media) /** * {@inheritdoc} */ - public function updateMetadata(MediaInterface $media, $force = true) + public function updateMetadata(MediaInterface $media, $force = true): void { if (!$media->getBinaryContent() instanceof \SplFileInfo) { // this is now optimized at all!!! @@ -256,7 +258,7 @@ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $file = $this->getFilesystem()->get($this->generatePrivateUrl($media, $format)); } - return new StreamedResponse(function () use ($file) { + return new StreamedResponse(function () use ($file): void { echo $file->getContent(); }, 200, $headers); } @@ -276,7 +278,7 @@ public function getDownloadResponse(MediaInterface $media, $format, $mode, array /** * {@inheritdoc} */ - public function validate(ErrorElement $errorElement, MediaInterface $media) + public function validate(ErrorElement $errorElement, MediaInterface $media): void { if (!$media->getBinaryContent() instanceof \SplFileInfo) { return; @@ -315,7 +317,7 @@ public function validate(ErrorElement $errorElement, MediaInterface $media) /** * @param MediaInterface $media */ - protected function fixBinaryContent(MediaInterface $media) + protected function fixBinaryContent(MediaInterface $media): void { if (null === $media->getBinaryContent() || $media->getBinaryContent() instanceof File) { return; @@ -342,7 +344,7 @@ protected function fixBinaryContent(MediaInterface $media) * * @throws \RuntimeException */ - protected function fixFilename(MediaInterface $media) + protected function fixFilename(MediaInterface $media): void { if ($media->getBinaryContent() instanceof UploadedFile) { $media->setName($media->getName() ?: $media->getBinaryContent()->getClientOriginalName()); @@ -361,7 +363,7 @@ protected function fixFilename(MediaInterface $media) /** * {@inheritdoc} */ - protected function doTransform(MediaInterface $media) + protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); $this->fixFilename($media); @@ -394,7 +396,7 @@ protected function doTransform(MediaInterface $media) * @param MediaInterface $media * @param string $contents path to contents, defaults to MediaInterface BinaryContent */ - protected function setFileContents(MediaInterface $media, $contents = null) + protected function setFileContents(MediaInterface $media, $contents = null): void { $file = $this->getFilesystem()->get(sprintf('%s/%s', $this->generatePath($media), $media->getProviderReference()), true); $metadata = $this->metadata ? $this->metadata->get($media, $file->getName()) : []; @@ -431,7 +433,7 @@ protected function generateReferenceName(MediaInterface $media) */ protected function generateMediaUniqId(MediaInterface $media) { - return sha1($media->getName().uniqid().rand(11111, 99999)); + return sha1($media->getName().uniqid().random_int(11111, 99999)); } /** @@ -439,7 +441,7 @@ protected function generateMediaUniqId(MediaInterface $media) * * @param MediaInterface $media */ - protected function generateBinaryFromRequest(MediaInterface $media) + protected function generateBinaryFromRequest(MediaInterface $media): void { if (!$media->getContentType()) { throw new \RuntimeException( diff --git a/src/Provider/ImageProvider.php b/src/Provider/ImageProvider.php index 50adf8df04..66c1e1ce45 100644 --- a/src/Provider/ImageProvider.php +++ b/src/Provider/ImageProvider.php @@ -1,5 +1,7 @@ getBinaryContent() instanceof \SplFileInfo) { @@ -193,7 +195,7 @@ public function generatePrivateUrl(MediaInterface $media, $format) /** * {@inheritdoc} */ - protected function doTransform(MediaInterface $media) + protected function doTransform(MediaInterface $media): void { parent::doTransform($media); diff --git a/src/Provider/MediaProviderInterface.php b/src/Provider/MediaProviderInterface.php index c1b4e20423..0dfb391632 100644 --- a/src/Provider/MediaProviderInterface.php +++ b/src/Provider/MediaProviderInterface.php @@ -1,5 +1,7 @@ providers[$name] = $instance; } @@ -93,7 +95,7 @@ public function addProvider($name, MediaProviderInterface $instance) * @param string $name * @param DownloadStrategyInterface $security */ - public function addDownloadSecurity($name, DownloadStrategyInterface $security) + public function addDownloadSecurity($name, DownloadStrategyInterface $security): void { @trigger_error( 'The '.__METHOD__.' method is deprecated since version 3.1 and will be removed in 4.0.', @@ -109,7 +111,7 @@ public function addDownloadSecurity($name, DownloadStrategyInterface $security) * @param string $name * @param DownloadStrategyInterface $security */ - public function addDownloadStrategy($name, DownloadStrategyInterface $security) + public function addDownloadStrategy($name, DownloadStrategyInterface $security): void { $this->downloadStrategies[$name] = $security; } @@ -117,7 +119,7 @@ public function addDownloadStrategy($name, DownloadStrategyInterface $security) /** * @param array $providers */ - public function setProviders($providers) + public function setProviders($providers): void { $this->providers = $providers; } @@ -136,7 +138,7 @@ public function getProviders() * @param array $formats * @param array $download */ - public function addContext($name, array $providers = [], array $formats = [], array $download = []) + public function addContext($name, array $providers = [], array $formats = [], array $download = []): void { if (!$this->hasContext($name)) { $this->contexts[$name] = [ @@ -317,7 +319,7 @@ public function getDefaultContext() * @param ErrorElement $errorElement * @param MediaInterface $media */ - public function validate(ErrorElement $errorElement, MediaInterface $media) + public function validate(ErrorElement $errorElement, MediaInterface $media): void { if (!$media->getProviderName()) { return; diff --git a/src/Provider/VimeoProvider.php b/src/Provider/VimeoProvider.php index e9f7c43096..9469d969b9 100644 --- a/src/Provider/VimeoProvider.php +++ b/src/Provider/VimeoProvider.php @@ -1,5 +1,7 @@ uniqid('vimeo_player_'), ]; - $player_parameters = array_merge($defaults, isset($options['player_parameters']) ? $options['player_parameters'] : []); + $player_parameters = array_merge($defaults, $options['player_parameters'] ?? []); $box = $this->getBoxHelperProperties($media, $format, $options); $params = [ 'src' => http_build_query($player_parameters), 'id' => $player_parameters['js_swf_id'], - 'frameborder' => isset($options['frameborder']) ? $options['frameborder'] : 0, + 'frameborder' => $options['frameborder'] ?? 0, 'width' => $box->getWidth(), 'height' => $box->getHeight(), - 'class' => isset($options['class']) ? $options['class'] : '', + 'class' => $options['class'] ?? '', 'allow_fullscreen' => isset($options['allowfullscreen']) ? true : false, ]; @@ -84,7 +86,7 @@ public function getProviderMetadata() /** * {@inheritdoc} */ - public function updateMetadata(MediaInterface $media, $force = false) + public function updateMetadata(MediaInterface $media, $force = false): void { $url = sprintf('http://vimeo.com/api/oembed.json?url=%s', $this->getReferenceUrl($media)); @@ -136,7 +138,7 @@ public function getReferenceUrl(MediaInterface $media) /** * @param MediaInterface $media */ - protected function fixBinaryContent(MediaInterface $media) + protected function fixBinaryContent(MediaInterface $media): void { if (!$media->getBinaryContent()) { return; @@ -150,7 +152,7 @@ protected function fixBinaryContent(MediaInterface $media) /** * {@inheritdoc} */ - protected function doTransform(MediaInterface $media) + protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); diff --git a/src/Provider/YouTubeProvider.php b/src/Provider/YouTubeProvider.php index 1529078f4d..401ca75dfe 100644 --- a/src/Provider/YouTubeProvider.php +++ b/src/Provider/YouTubeProvider.php @@ -1,5 +1,7 @@ isset($options['allowScriptAccess']) ? $options['allowScriptAccess'] : 'always', + 'allowScriptAccess' => $options['allowScriptAccess'] ?? 'always', // Values: 'window' or 'opaque' or 'transparent'. // When wmode=window, the Flash movie is not rendered in the page. @@ -179,11 +181,11 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ 'wmode' => $default_player_url_parameters['wmode'], ]; - $player_url_parameters = array_merge($default_player_url_parameters, isset($options['player_url_parameters']) ? $options['player_url_parameters'] : []); + $player_url_parameters = array_merge($default_player_url_parameters, $options['player_url_parameters'] ?? []); $box = $this->getBoxHelperProperties($media, $format, $options); - $player_parameters = array_merge($default_player_parameters, isset($options['player_parameters']) ? $options['player_parameters'] : [], [ + $player_parameters = array_merge($default_player_parameters, $options['player_parameters'] ?? [], [ 'width' => $box->getWidth(), 'height' => $box->getHeight(), ]); @@ -200,7 +202,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ /** * {@inheritdoc} */ - public function updateMetadata(MediaInterface $media, $force = false) + public function updateMetadata(MediaInterface $media, $force = false): void { $url = sprintf('https://www.youtube.com/oembed?url=%s&format=json', $this->getReferenceUrl($media)); @@ -248,7 +250,7 @@ public function getReferenceUrl(MediaInterface $media) /** * @param MediaInterface $media */ - protected function fixBinaryContent(MediaInterface $media) + protected function fixBinaryContent(MediaInterface $media): void { if (!$media->getBinaryContent()) { return; @@ -266,7 +268,7 @@ protected function fixBinaryContent(MediaInterface $media) /** * {@inheritdoc} */ - protected function doTransform(MediaInterface $media) + protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); diff --git a/src/Resizer/ResizerInterface.php b/src/Resizer/ResizerInterface.php index f7eea54e32..d7be623a5f 100644 --- a/src/Resizer/ResizerInterface.php +++ b/src/Resizer/ResizerInterface.php @@ -1,5 +1,7 @@ getContext(), $media->getProviderName())); diff --git a/src/Resizer/SquareResizer.php b/src/Resizer/SquareResizer.php index 61b92a8072..811636b744 100755 --- a/src/Resizer/SquareResizer.php +++ b/src/Resizer/SquareResizer.php @@ -1,5 +1,7 @@ adapter = $adapter; } @@ -69,7 +71,7 @@ public function setAdapter(ImagineInterface $adapter) /** * {@inheritdoc} */ - public function resize(MediaInterface $media, File $in, File $out, $format, array $settings) + public function resize(MediaInterface $media, File $in, File $out, $format, array $settings): void { if (!isset($settings['width'])) { throw new \RuntimeException(sprintf('Width parameter is missing in context "%s" for provider "%s"', $media->getContext(), $media->getProviderName())); diff --git a/src/Security/DownloadStrategyInterface.php b/src/Security/DownloadStrategyInterface.php index 7681b83388..977f756e93 100644 --- a/src/Security/DownloadStrategyInterface.php +++ b/src/Security/DownloadStrategyInterface.php @@ -1,5 +1,7 @@ addCompilerPass(new AddProviderCompilerPass()); $container->addCompilerPass(new GlobalVariablesCompilerPass()); @@ -33,7 +35,7 @@ public function build(ContainerBuilder $container) /** * {@inheritdoc} */ - public function boot() + public function boot(): void { // this is required by the AWS SDK (see: https://github.com/knplabs/Gaufrette) if (!defined('AWS_CERTIFICATE_AUTHORITY')) { @@ -46,7 +48,7 @@ public function boot() /** * Register form mapping information. */ - public function registerFormMapping() + public function registerFormMapping(): void { FormHelper::registerFormTypeMapping([ 'sonata_media_type' => 'Sonata\MediaBundle\Form\Type\MediaType', diff --git a/src/Templating/Helper/MediaHelper.php b/src/Templating/Helper/MediaHelper.php index 9145ba816b..9ee72120c7 100644 --- a/src/Templating/Helper/MediaHelper.php +++ b/src/Templating/Helper/MediaHelper.php @@ -1,5 +1,7 @@ backend; $id = $this->id; - $publish = function () use ($backend, $media, $id) { + $publish = function () use ($backend, $media, $id): void { $backend->createAndPublish('sonata.media.create_thumbnail', [ 'thumbnailId' => $id, 'mediaId' => $media->getId(), diff --git a/src/Thumbnail/FormatThumbnail.php b/src/Thumbnail/FormatThumbnail.php index 512f5c8d4b..b5a8c1b5bd 100644 --- a/src/Thumbnail/FormatThumbnail.php +++ b/src/Thumbnail/FormatThumbnail.php @@ -1,5 +1,7 @@ requireThumbnails()) { return; @@ -93,7 +95,7 @@ public function generate(MediaProviderInterface $provider, MediaInterface $media /** * {@inheritdoc} */ - public function delete(MediaProviderInterface $provider, MediaInterface $media, $formats = null) + public function delete(MediaProviderInterface $provider, MediaInterface $media, $formats = null): void { if (null === $formats) { $formats = array_keys($provider->getFormats()); diff --git a/src/Thumbnail/LiipImagineThumbnail.php b/src/Thumbnail/LiipImagineThumbnail.php index f8b701f9f3..274d59da51 100644 --- a/src/Thumbnail/LiipImagineThumbnail.php +++ b/src/Thumbnail/LiipImagineThumbnail.php @@ -1,5 +1,7 @@ environment = $environment; } diff --git a/src/Twig/GlobalVariables.php b/src/Twig/GlobalVariables.php index 371a340a5f..cd356b3098 100644 --- a/src/Twig/GlobalVariables.php +++ b/src/Twig/GlobalVariables.php @@ -1,5 +1,7 @@ addDebugInfo($this) diff --git a/src/Twig/Node/PathNode.php b/src/Twig/Node/PathNode.php index 94159613eb..84dc4074e9 100644 --- a/src/Twig/Node/PathNode.php +++ b/src/Twig/Node/PathNode.php @@ -1,5 +1,7 @@ addDebugInfo($this) diff --git a/src/Twig/Node/ThumbnailNode.php b/src/Twig/Node/ThumbnailNode.php index d74bc1102a..f4dc39c485 100644 --- a/src/Twig/Node/ThumbnailNode.php +++ b/src/Twig/Node/ThumbnailNode.php @@ -1,5 +1,7 @@ addDebugInfo($this) diff --git a/src/Twig/TokenParser/MediaTokenParser.php b/src/Twig/TokenParser/MediaTokenParser.php index 18e1445047..6c314d45be 100644 --- a/src/Twig/TokenParser/MediaTokenParser.php +++ b/src/Twig/TokenParser/MediaTokenParser.php @@ -1,5 +1,7 @@ pool->getFormatNamesByContext($value->getContext()); diff --git a/tests/Admin/BaseMediaAdminTest.php b/tests/Admin/BaseMediaAdminTest.php index 3f03424336..553dcf930a 100644 --- a/tests/Admin/BaseMediaAdminTest.php +++ b/tests/Admin/BaseMediaAdminTest.php @@ -1,5 +1,7 @@ pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); $this->categoryManager = $this->prophesize('Sonata\MediaBundle\Model\CategoryManagerInterface'); @@ -52,7 +54,7 @@ protected function setUp() $this->mediaAdmin->setUniqid('uniqid'); } - public function testGetNewInstance() + public function testGetNewInstance(): void { $media = $this->prophesize('Sonata\MediaBundle\Model\Media'); $category = $this->prophesize(); @@ -77,7 +79,7 @@ public function testGetNewInstance() $this->assertSame($media->reveal(), $this->mediaAdmin->getNewInstance()); } - private function configureGetPersistentParameters() + private function configureGetPersistentParameters(): void { $provider = $this->prophesize('Sonata\MediaBundle\Provider\MediaProviderInterface'); $category = $this->prophesize(); @@ -97,7 +99,7 @@ private function configureGetPersistentParameters() $category->getId()->willReturn(1); } - private function configureGetProviderName($media) + private function configureGetProviderName($media): void { $this->request->get('uniqid')->willReturn(['providerName' => 'providerName']); $media->setProviderName('providerName')->shouldBeCalled(); diff --git a/tests/Admin/GalleryAdminTest.php b/tests/Admin/GalleryAdminTest.php index 62c6793cac..25dff0a4b0 100644 --- a/tests/Admin/GalleryAdminTest.php +++ b/tests/Admin/GalleryAdminTest.php @@ -1,5 +1,7 @@ pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); $this->categoryManager = $this->prophesize('Sonata\ClassificationBundle\Entity\CategoryManager'); @@ -34,7 +36,7 @@ protected function setUp() ); } - public function testItIsInstantiable() + public function testItIsInstantiable(): void { $this->assertNotNull($this->mediaAdmin); } diff --git a/tests/Admin/GalleryItemAdminTest.php b/tests/Admin/GalleryItemAdminTest.php index d801be9e76..91ca5f0f7a 100644 --- a/tests/Admin/GalleryItemAdminTest.php +++ b/tests/Admin/GalleryItemAdminTest.php @@ -1,5 +1,7 @@ mediaAdmin = new GalleryItemAdmin( null, @@ -27,7 +29,7 @@ protected function setUp() ); } - public function testItIsInstantiable() + public function testItIsInstantiable(): void { $this->assertNotNull($this->mediaAdmin); } diff --git a/tests/Admin/ORM/MediaAdminTest.php b/tests/Admin/ORM/MediaAdminTest.php index eaac53b0ec..a43d67f71d 100644 --- a/tests/Admin/ORM/MediaAdminTest.php +++ b/tests/Admin/ORM/MediaAdminTest.php @@ -1,5 +1,7 @@ pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); $this->categoryManager = $this->prophesize('Sonata\MediaBundle\Model\CategoryManagerInterface'); @@ -34,7 +36,7 @@ protected function setUp() ); } - public function testItIsInstantiable() + public function testItIsInstantiable(): void { $this->assertNotNull($this->mediaAdmin); } diff --git a/tests/Block/Breadcrumb/BreadcrumbTest.php b/tests/Block/Breadcrumb/BreadcrumbTest.php index a96a0e4246..cabc13ae32 100644 --- a/tests/Block/Breadcrumb/BreadcrumbTest.php +++ b/tests/Block/Breadcrumb/BreadcrumbTest.php @@ -1,5 +1,7 @@ getBlockContext($this->blockService); diff --git a/tests/Block/GalleryBlockServiceTest.php b/tests/Block/GalleryBlockServiceTest.php index 05c6e51e42..25a68f08ef 100644 --- a/tests/Block/GalleryBlockServiceTest.php +++ b/tests/Block/GalleryBlockServiceTest.php @@ -1,5 +1,7 @@ prophesize('Sonata\BlockBundle\Model\Block'); $gallery = $this->prophesize('Sonata\MediaBundle\Model\GalleryInterface'); @@ -56,7 +58,7 @@ public function testExecute() $this->assertSame($block->reveal(), $this->templating->parameters['block']); } - public function testDefaultSettings() + public function testDefaultSettings(): void { $blockContext = $this->getBlockContext($this->blockService); diff --git a/tests/Block/GalleryListBlockServiceTest.php b/tests/Block/GalleryListBlockServiceTest.php index 8a151a929a..2b046e607e 100644 --- a/tests/Block/GalleryListBlockServiceTest.php +++ b/tests/Block/GalleryListBlockServiceTest.php @@ -1,5 +1,7 @@ pool = $this->getMockBuilder('Sonata\MediaBundle\Provider\Pool')->disableOriginalConstructor()->getMock(); } - public function testExecute() + public function testExecute(): void { $pager = $this->getMockBuilder('Sonata\DatagridBundle\Pager\PagerInterface')->getMock(); $this->galleryManager->expects($this->once())->method('getPager')->will($this->returnValue($pager)); @@ -66,7 +68,7 @@ public function testExecute() $this->assertSame($pager, $this->templating->parameters['pager']); } - public function testDefaultSettings() + public function testDefaultSettings(): void { $blockService = new GalleryListBlockService('block.service', $this->templating, $this->galleryManager, $this->pool); $blockContext = $this->getBlockContext($blockService); diff --git a/tests/Block/MediaBlockServiceTest.php b/tests/Block/MediaBlockServiceTest.php index 90fd43d47b..67998dbafb 100644 --- a/tests/Block/MediaBlockServiceTest.php +++ b/tests/Block/MediaBlockServiceTest.php @@ -1,5 +1,7 @@ prophesize('Sonata\BlockBundle\Model\Block'); $media = $this->prophesize('Sonata\MediaBundle\Model\MediaInterface'); @@ -58,7 +60,7 @@ public function testExecute() $this->assertSame($block->reveal(), $this->templating->parameters['block']); } - public function testDefaultSettings() + public function testDefaultSettings(): void { $blockContext = $this->getBlockContext($this->blockService); @@ -76,7 +78,7 @@ public function testDefaultSettings() ], $blockContext); } - private function configureGetFormatChoices($media, $choices) + private function configureGetFormatChoices($media, $choices): void { $mediaAdmin = $this->prophesize('Sonata\MediaBundle\Admin\BaseMediaAdmin'); $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); diff --git a/tests/CDN/CloudFrontTest.php b/tests/CDN/CloudFrontTest.php index e39df86cba..69111dc610 100644 --- a/tests/CDN/CloudFrontTest.php +++ b/tests/CDN/CloudFrontTest.php @@ -1,5 +1,7 @@ getMockBuilder('Aws\CloudFront\CloudFrontClient') ->setMethods(['createInvalidation']) @@ -48,7 +50,7 @@ public function testLegacyCloudFront() /** * @group legacy */ - public function testLegacyException() + public function testLegacyException(): void { $this->expectException('\RuntimeException'); $this->expectExceptionMessage('Unable to flush : '); diff --git a/tests/CDN/PantherPortalTest.php b/tests/CDN/PantherPortalTest.php index 95b78f4722..3e45da8bef 100644 --- a/tests/CDN/PantherPortalTest.php +++ b/tests/CDN/PantherPortalTest.php @@ -1,5 +1,7 @@ createMock( 'Sonata\MediaBundle\Tests\CDN\ClientSpy', @@ -39,7 +41,7 @@ public function testPortal() $panther->flushPaths([$path]); } - public function testException() + public function testException(): void { $this->expectException('\RuntimeException'); $this->expectExceptionMessage('Unable to flush : Failed!!'); @@ -62,7 +64,7 @@ public function testException() class ClientSpy { - public function flush() + public function flush(): void { } } diff --git a/tests/Command/CleanMediaCommandTest.php b/tests/Command/CleanMediaCommandTest.php index 7f6cf5bfea..8f4dded1c8 100755 --- a/tests/Command/CleanMediaCommandTest.php +++ b/tests/Command/CleanMediaCommandTest.php @@ -1,5 +1,7 @@ [], @@ -117,7 +119,7 @@ public function testExecuteDirectoryNotExists() $this->assertSame(0, $output); } - public function testExecuteEmptyDirectory() + public function testExecuteEmptyDirectory(): void { $this->filesystem->mkdir($this->workspace.DIRECTORY_SEPARATOR.'foo'); @@ -136,7 +138,7 @@ public function testExecuteEmptyDirectory() $this->assertSame(0, $output); } - public function testExecuteFilesExists() + public function testExecuteFilesExists(): void { $this->filesystem->mkdir($this->workspace.DIRECTORY_SEPARATOR.'foo'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); @@ -170,7 +172,7 @@ public function testExecuteFilesExists() $this->assertSame(0, $output); } - public function testExecuteFilesExistsVerbose() + public function testExecuteFilesExistsVerbose(): void { $this->filesystem->mkdir($this->workspace.DIRECTORY_SEPARATOR.'foo'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); @@ -213,7 +215,7 @@ public function testExecuteFilesExistsVerbose() $this->assertSame(0, $output); } - public function testExecuteDryRun() + public function testExecuteDryRun(): void { $this->filesystem->mkdir($this->workspace.DIRECTORY_SEPARATOR.'foo'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); @@ -251,7 +253,7 @@ public function testExecuteDryRun() $this->assertSame(0, $output); } - public function testExecute() + public function testExecute(): void { $this->filesystem->mkdir($this->workspace.DIRECTORY_SEPARATOR.'foo'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'qwertz.ext'); @@ -296,7 +298,7 @@ public function testExecute() * @param array $expected Excerpts of text expected to be found in the output * @param string $output Searched output */ - private function assertOutputFoundInContext($extractor, $expected, $output) + private function assertOutputFoundInContext($extractor, $expected, $output): void { preg_match_all($extractor, $output, $matches); diff --git a/tests/Command/FixMediaContextCommandTest.php b/tests/Command/FixMediaContextCommandTest.php index 3644a5182f..db0d258c4c 100755 --- a/tests/Command/FixMediaContextCommandTest.php +++ b/tests/Command/FixMediaContextCommandTest.php @@ -1,5 +1,7 @@ container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock(); @@ -89,7 +91,7 @@ protected function setUp() })); } - public function testExecuteWithDisabledClassfication() + public function testExecuteWithDisabledClassfication(): void { $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) ->will($this->returnValue(false)); @@ -99,7 +101,7 @@ public function testExecuteWithDisabledClassfication() $this->tester->execute(['command' => $this->command->getName()]); } - public function testExecuteWithExisting() + public function testExecuteWithExisting(): void { $context = [ 'providers' => [], @@ -127,7 +129,7 @@ public function testExecuteWithExisting() $this->assertSame(0, $output); } - public function testExecuteWithEmptyRoot() + public function testExecuteWithEmptyRoot(): void { $context = [ 'providers' => [], @@ -157,7 +159,7 @@ public function testExecuteWithEmptyRoot() $this->assertSame(0, $output); } - public function testExecuteWithNew() + public function testExecuteWithNew(): void { $context = [ 'providers' => [], diff --git a/tests/Command/RemoveThumbsCommandTest.php b/tests/Command/RemoveThumbsCommandTest.php index 900b6b9f12..eecefa4397 100644 --- a/tests/Command/RemoveThumbsCommandTest.php +++ b/tests/Command/RemoveThumbsCommandTest.php @@ -1,5 +1,7 @@ filesystem->mkdir($this->workspace.DIRECTORY_SEPARATOR.'foo'); $this->filesystem->touch($this->workspace.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'thumb_1_foo.ext'); diff --git a/tests/Controller/Api/GalleryControllerTest.php b/tests/Controller/Api/GalleryControllerTest.php index 908ab3825a..7536c6e62b 100644 --- a/tests/Controller/Api/GalleryControllerTest.php +++ b/tests/Controller/Api/GalleryControllerTest.php @@ -1,5 +1,7 @@ id = rand(); + $this->id = random_int(0, getrandmax()); } public function getId() @@ -38,7 +40,7 @@ public function getId() */ class GalleryControllerTest extends TestCase { - public function testGetGalleriesAction() + public function testGetGalleriesAction(): void { $galleryManager = $this->createMock('Sonata\MediaBundle\Model\GalleryManagerInterface'); $mediaManager = $this->createMock('Sonata\MediaBundle\Model\MediaManagerInterface'); @@ -64,7 +66,7 @@ public function testGetGalleriesAction() $this->assertSame([], $gController->getGalleriesAction($paramFetcher)); } - public function testGetGalleryAction() + public function testGetGalleryAction(): void { $galleryManager = $this->createMock('Sonata\MediaBundle\Model\GalleryManagerInterface'); $mediaManager = $this->createMock('Sonata\MediaBundle\Model\MediaManagerInterface'); @@ -78,7 +80,7 @@ public function testGetGalleryAction() $this->assertSame($gallery, $gController->getGalleryAction(1)); } - public function testGetGalleryNotFoundAction() + public function testGetGalleryNotFoundAction(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->expectExceptionMessage('Gallery (42) not found'); @@ -94,7 +96,7 @@ public function testGetGalleryNotFoundAction() $gController->getGalleryAction(42); } - public function testGetGalleryGalleryItemsAction() + public function testGetGalleryGalleryItemsAction(): void { $galleryManager = $this->createMock('Sonata\MediaBundle\Model\GalleryManagerInterface'); $galleryItem = $this->createMock('Sonata\MediaBundle\Model\GalleryItemInterface'); @@ -112,7 +114,7 @@ public function testGetGalleryGalleryItemsAction() $this->assertSame([$galleryItem], $gController->getGalleryGalleryItemAction(1)); } - public function testGetGalleryMediaAction() + public function testGetGalleryMediaAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $formFactory = $this->createMock('Symfony\Component\Form\FormFactoryInterface'); @@ -130,7 +132,7 @@ public function testGetGalleryMediaAction() $this->assertSame([$media], $gController->getGalleryMediasAction(1)); } - public function testPostGalleryMediaGalleryItemAction() + public function testPostGalleryMediaGalleryItemAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $galleryItem = $this->createMock('Sonata\MediaBundle\Model\GalleryItemInterface'); @@ -165,7 +167,7 @@ public function testPostGalleryMediaGalleryItemAction() $this->assertSame(200, $view->getResponse()->getStatusCode(), 'Should return 200'); } - public function testPostGalleryMediaGalleryItemInvalidAction() + public function testPostGalleryMediaGalleryItemInvalidAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $galleryManager = $this->createMock('Sonata\MediaBundle\Model\GalleryManagerInterface'); @@ -193,7 +195,7 @@ public function testPostGalleryMediaGalleryItemInvalidAction() $this->assertSame(400, $view->getResponse()->getStatusCode(), 'Should return 400'); } - public function testPutGalleryMediaGalleryItemAction() + public function testPutGalleryMediaGalleryItemAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $gallery = $this->createMock('Sonata\MediaBundle\Model\GalleryInterface'); @@ -227,7 +229,7 @@ public function testPutGalleryMediaGalleryItemAction() $this->assertSame(200, $view->getResponse()->getStatusCode(), 'Should return 200'); } - public function testPutGalleryMediaGalleryItemInvalidAction() + public function testPutGalleryMediaGalleryItemInvalidAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $galleryItem = $this->createMock('Sonata\MediaBundle\Model\GalleryItemInterface'); @@ -259,7 +261,7 @@ public function testPutGalleryMediaGalleryItemInvalidAction() $this->assertInstanceOf('Symfony\Component\Form\FormInterface', $view); } - public function testDeleteGalleryMediaGalleryItemAction() + public function testDeleteGalleryMediaGalleryItemAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $galleryItem = $this->createMock('Sonata\MediaBundle\Model\GalleryItemInterface'); @@ -289,7 +291,7 @@ public function testDeleteGalleryMediaGalleryItemAction() $this->assertSame(['deleted' => true], $view); } - public function testDeleteGalleryMediaGalleryItemInvalidAction() + public function testDeleteGalleryMediaGalleryItemInvalidAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $media2 = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); diff --git a/tests/Controller/Api/MediaControllerTest.php b/tests/Controller/Api/MediaControllerTest.php index 9e88f2f3fa..41b1b3e531 100644 --- a/tests/Controller/Api/MediaControllerTest.php +++ b/tests/Controller/Api/MediaControllerTest.php @@ -1,5 +1,7 @@ createMock('Sonata\MediaBundle\Model\MediaManagerInterface'); $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -38,7 +40,7 @@ public function testGetMediaAction() $this->assertSame([$media], $mController->getMediaAction($paramFetcher)); } - public function testGetMediumAction() + public function testGetMediumAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -50,7 +52,7 @@ public function testGetMediumAction() $this->assertSame($media, $controller->getMediumAction(1)); } - public function testGetMediumNotFoundExceptionAction() + public function testGetMediumNotFoundExceptionAction(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); $this->expectExceptionMessage('Media (42) was not found'); @@ -58,7 +60,7 @@ public function testGetMediumNotFoundExceptionAction() $this->createMediaController()->getMediumAction(42); } - public function testGetMediumFormatsAction() + public function testGetMediumFormatsAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -91,7 +93,7 @@ public function testGetMediumFormatsAction() $this->assertSame($expected, $controller->getMediumFormatsAction(1)); } - public function testGetMediumBinariesAction() + public function testGetMediumBinariesAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -111,7 +113,7 @@ public function testGetMediumBinariesAction() $this->assertSame($binaryResponse, $controller->getMediumBinaryAction(1, 'format', new Request())); } - public function testDeleteMediumAction() + public function testDeleteMediumAction(): void { $manager = $this->createMock('Sonata\MediaBundle\Model\MediaManagerInterface'); $manager->expects($this->once())->method('delete'); @@ -124,7 +126,7 @@ public function testDeleteMediumAction() $this->assertSame($expected, $controller->deleteMediumAction(1)); } - public function testPutMediumAction() + public function testPutMediumAction(): void { $medium = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -150,7 +152,7 @@ public function testPutMediumAction() $this->assertInstanceOf('FOS\RestBundle\View\View', $controller->putMediumAction(1, new Request())); } - public function testPutMediumInvalidFormAction() + public function testPutMediumInvalidFormAction(): void { $medium = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -175,7 +177,7 @@ public function testPutMediumInvalidFormAction() $this->assertInstanceOf('Symfony\Component\Form\Form', $controller->putMediumAction(1, new Request())); } - public function testPostProviderMediumAction() + public function testPostProviderMediumAction(): void { $medium = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $medium->expects($this->once())->method('setProviderName'); @@ -202,7 +204,7 @@ public function testPostProviderMediumAction() $this->assertInstanceOf('FOS\RestBundle\View\View', $controller->postProviderMediumAction('providerName', new Request())); } - public function testPostProviderActionNotFound() + public function testPostProviderActionNotFound(): void { $this->expectException(\Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class); @@ -219,7 +221,7 @@ public function testPostProviderActionNotFound() $controller->postProviderMediumAction('non existing provider', new Request()); } - public function testPutMediumBinaryContentAction() + public function testPutMediumBinaryContentAction(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $media->expects($this->once())->method('setBinaryContent'); diff --git a/tests/Controller/GalleryAdminControllerTest.php b/tests/Controller/GalleryAdminControllerTest.php index 8c73daac76..c52bca4844 100644 --- a/tests/Controller/GalleryAdminControllerTest.php +++ b/tests/Controller/GalleryAdminControllerTest.php @@ -1,5 +1,7 @@ container = $this->prophesize('Symfony\Component\DependencyInjection\ContainerInterface'); $this->admin = $this->prophesize('Sonata\MediaBundle\Admin\BaseMediaAdmin'); @@ -42,12 +44,12 @@ protected function setUp() $this->controller->setContainer($this->container->reveal()); } - public function testItIsInstantiable() + public function testItIsInstantiable(): void { $this->assertNotNull($this->controller); } - public function testListAction() + public function testListAction(): void { $datagrid = $this->prophesize('Sonata\AdminBundle\Datagrid\DatagridInterface'); $form = $this->prophesize('Symfony\Component\Form\Form'); @@ -72,7 +74,7 @@ public function testListAction() $this->controller->listAction($this->request->reveal()); } - private function configureCRUDController() + private function configureCRUDController(): void { $pool = $this->prophesize('Sonata\AdminBundle\Admin\Pool'); $breadcrumbsBuilder = $this->prophesize('Sonata\AdminBundle\Admin\BreadcrumbsBuilderInterface'); @@ -90,7 +92,7 @@ private function configureCRUDController() $this->admin->setRequest($this->request->reveal())->shouldBeCalled(); } - private function configureGetCurrentRequest($request) + private function configureGetCurrentRequest($request): void { $requestStack = $this->prophesize(RequestStack::class); @@ -99,7 +101,7 @@ private function configureGetCurrentRequest($request) $requestStack->getCurrentRequest()->willReturn($request); } - private function configureSetCsrfToken($intention) + private function configureSetCsrfToken($intention): void { $tokenManager = $this->prophesize(CsrfTokenManagerInterface::class); $token = $this->prophesize(CsrfToken::class); @@ -110,7 +112,7 @@ private function configureSetCsrfToken($intention) $this->container->get('security.csrf.token_manager')->willReturn($tokenManager->reveal()); } - private function configureSetFormTheme($formView, $formTheme) + private function configureSetFormTheme($formView, $formTheme): void { $twig = $this->prophesize(\Twig_Environment::class); @@ -137,7 +139,7 @@ private function configureSetFormTheme($formView, $formTheme) $twigRenderer->setTheme($formView, $formTheme)->shouldBeCalled(); } - private function configureRender($template, $data, $rendered) + private function configureRender($template, $data, $rendered): void { $templating = $this->prophesize('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); $response = $this->prophesize('Symfony\Component\HttpFoundation\Response'); diff --git a/tests/Controller/MediaAdminControllerTest.php b/tests/Controller/MediaAdminControllerTest.php index 1a9568906c..acfee8df77 100644 --- a/tests/Controller/MediaAdminControllerTest.php +++ b/tests/Controller/MediaAdminControllerTest.php @@ -1,5 +1,7 @@ container = $this->prophesize('Symfony\Component\DependencyInjection\ContainerInterface'); $this->admin = $this->prophesize('Sonata\MediaBundle\Admin\BaseMediaAdmin'); @@ -49,7 +51,7 @@ protected function setUp() $this->controller->setContainer($this->container->reveal()); } - public function testCreateActionToSelectProvider() + public function testCreateActionToSelectProvider(): void { $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); @@ -72,7 +74,7 @@ public function testCreateActionToSelectProvider() $this->assertSame('renderResponse', $response->getContent()); } - public function testCreateAction() + public function testCreateAction(): void { $this->configureCreateAction('Sonata\MediaBundle\Tests\Entity\Media'); $this->configureRender('template', Argument::type('array'), 'renderResponse'); @@ -86,7 +88,7 @@ public function testCreateAction() $this->assertSame('renderResponse', $response->getContent()); } - public function testListAction() + public function testListAction(): void { $datagrid = $this->prophesize('Sonata\AdminBundle\Datagrid\DatagridInterface'); $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); @@ -130,7 +132,7 @@ public function testListAction() $this->assertSame('renderResponse', $response->getContent()); } - private function configureCRUDController() + private function configureCRUDController(): void { $pool = $this->prophesize('Sonata\AdminBundle\Admin\Pool'); $breadcrumbsBuilder = $this->prophesize('Sonata\AdminBundle\Admin\BreadcrumbsBuilderInterface'); @@ -148,7 +150,7 @@ private function configureCRUDController() $this->admin->setRequest($this->request->reveal())->shouldBeCalled(); } - private function configureCreateAction($class) + private function configureCreateAction($class): void { $object = $this->prophesize('Sonata\MediaBundle\Tests\Entity\Media'); $form = $this->prophesize('Symfony\Component\Form\Form'); @@ -168,7 +170,7 @@ private function configureCreateAction($class) $form->isSubmitted()->willReturn(false); } - private function configureGetCurrentRequest($request) + private function configureGetCurrentRequest($request): void { $requestStack = $this->prophesize(RequestStack::class); @@ -177,7 +179,7 @@ private function configureGetCurrentRequest($request) $requestStack->getCurrentRequest()->willReturn($request); } - private function configureSetFormTheme($formView, $formTheme) + private function configureSetFormTheme($formView, $formTheme): void { $twig = $this->prophesize(\Twig_Environment::class); @@ -206,7 +208,7 @@ private function configureSetFormTheme($formView, $formTheme) $twigRenderer->setTheme($formView, $formTheme)->shouldBeCalled(); } - private function configureSetCsrfToken($intention) + private function configureSetCsrfToken($intention): void { $tokenManager = $this->prophesize(CsrfTokenManagerInterface::class); $token = $this->prophesize(CsrfToken::class); @@ -217,7 +219,7 @@ private function configureSetCsrfToken($intention) $this->container->get('security.csrf.token_manager')->willReturn($tokenManager->reveal()); } - private function configureRender($template, $data, $rendered) + private function configureRender($template, $data, $rendered): void { $templating = $this->prophesize('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); $response = $this->prophesize('Symfony\Component\HttpFoundation\Response'); diff --git a/tests/Controller/MediaControllerTest.php b/tests/Controller/MediaControllerTest.php index 0bd7a17df4..eaa6f14848 100644 --- a/tests/Controller/MediaControllerTest.php +++ b/tests/Controller/MediaControllerTest.php @@ -1,5 +1,7 @@ container = $this->prophesize('Symfony\Component\DependencyInjection\Container'); @@ -27,7 +29,7 @@ protected function setUp() $this->controller->setContainer($this->container->reveal()); } - public function testDownloadActionWithNotFoundMedia() + public function testDownloadActionWithNotFoundMedia(): void { $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); @@ -38,7 +40,7 @@ public function testDownloadActionWithNotFoundMedia() $this->controller->downloadAction($request->reveal(), 1); } - public function testDownloadActionAccessDenied() + public function testDownloadActionAccessDenied(): void { $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); @@ -53,7 +55,7 @@ public function testDownloadActionAccessDenied() $this->controller->downloadAction($request->reveal(), 1); } - public function testDownloadActionBinaryFile() + public function testDownloadActionBinaryFile(): void { $media = $this->prophesize('Sonata\MediaBundle\Model\Media'); $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); @@ -74,7 +76,7 @@ public function testDownloadActionBinaryFile() $this->assertSame($response->reveal(), $result); } - public function testViewActionWithNotFoundMedia() + public function testViewActionWithNotFoundMedia(): void { $this->expectException('Symfony\Component\HttpKernel\Exception\NotFoundHttpException'); @@ -85,7 +87,7 @@ public function testViewActionWithNotFoundMedia() $this->controller->viewAction($request->reveal(), 1); } - public function testViewActionAccessDenied() + public function testViewActionAccessDenied(): void { $this->expectException('Symfony\Component\Security\Core\Exception\AccessDeniedException'); @@ -100,7 +102,7 @@ public function testViewActionAccessDenied() $this->controller->viewAction($request->reveal(), 1); } - public function testViewActionRendersView() + public function testViewActionRendersView(): void { $media = $this->prophesize('Sonata\MediaBundle\Model\Media'); $pool = $this->prophesize('Sonata\MediaBundle\Provider\Pool'); @@ -123,7 +125,7 @@ public function testViewActionRendersView() $this->assertSame('renderResponse', $response->getContent()); } - private function configureDownloadSecurity($pool, $media, $request, $isGranted) + private function configureDownloadSecurity($pool, $media, $request, $isGranted): void { $strategy = $this->prophesize('Sonata\MediaBundle\Security\DownloadStrategyInterface'); @@ -131,7 +133,7 @@ private function configureDownloadSecurity($pool, $media, $request, $isGranted) $strategy->isGranted($media, $request)->willReturn($isGranted); } - private function configureGetMedia($id, $media) + private function configureGetMedia($id, $media): void { $mediaManager = $this->prophesize('Sonata\CoreBundle\Model\BaseEntityManager'); @@ -139,13 +141,13 @@ private function configureGetMedia($id, $media) $mediaManager->find($id)->willReturn($media); } - private function configureGetProvider($pool, $media, $provider) + private function configureGetProvider($pool, $media, $provider): void { $pool->getProvider('provider')->willReturn($provider); $media->getProviderName()->willReturn('provider'); } - private function configureRender($template, $data, $rendered) + private function configureRender($template, $data, $rendered): void { $templating = $this->prophesize('Symfony\Bundle\FrameworkBundle\Templating\EngineInterface'); $response = $this->prophesize('Symfony\Component\HttpFoundation\Response'); diff --git a/tests/DependencyInjection/ConfigurationTest.php b/tests/DependencyInjection/ConfigurationTest.php index fb0c335a4d..13b0cbca8a 100644 --- a/tests/DependencyInjection/ConfigurationTest.php +++ b/tests/DependencyInjection/ConfigurationTest.php @@ -1,5 +1,7 @@ [ @@ -35,7 +37,7 @@ protected function setUp() $this->config = $processor->processConfiguration($configuration, $configs); } - public function testProcess() + public function testProcess(): void { $this->assertArrayHasKey('resizers', $this->config); $this->assertArrayHasKey('default', $this->config['resizers']); diff --git a/tests/DependencyInjection/SonataMediaExtensionTest.php b/tests/DependencyInjection/SonataMediaExtensionTest.php index 0e50439bab..97b4e2821d 100644 --- a/tests/DependencyInjection/SonataMediaExtensionTest.php +++ b/tests/DependencyInjection/SonataMediaExtensionTest.php @@ -1,5 +1,7 @@ container->setParameter('kernel.bundles', ['SonataAdminBundle' => true]); } - public function testLoadWithDefaultAndCustomCategoryManager() + public function testLoadWithDefaultAndCustomCategoryManager(): void { $this->load([ 'class' => [ @@ -39,7 +41,7 @@ public function testLoadWithDefaultAndCustomCategoryManager() $this->assertContainerBuilderHasAlias('sonata.media.manager.category', 'dummy.service.name'); } - public function testLoadWithForceDisableTrueAndWithCategoryManager() + public function testLoadWithForceDisableTrueAndWithCategoryManager(): void { $this->load([ 'class' => [ @@ -52,7 +54,7 @@ public function testLoadWithForceDisableTrueAndWithCategoryManager() $this->assertContainerBuilderNotHasService('sonata.media.manager.category'); } - public function testLoadWithDefaultAndClassificationBundleEnable() + public function testLoadWithDefaultAndClassificationBundleEnable(): void { $this->load(); @@ -63,7 +65,7 @@ public function testLoadWithDefaultAndClassificationBundleEnable() ); } - public function testLoadWithDefaultAndClassificationBundleEnableAndForceDisableCategory() + public function testLoadWithDefaultAndClassificationBundleEnableAndForceDisableCategory(): void { $this->load([ 'force_disable_category' => true, @@ -72,7 +74,7 @@ public function testLoadWithDefaultAndClassificationBundleEnableAndForceDisableC $this->assertContainerBuilderNotHasService('sonata.media.manager.category'); } - public function testLoadWithDefaultAndClassificationBundleEnableAndCustomCategoryManager() + public function testLoadWithDefaultAndClassificationBundleEnableAndCustomCategoryManager(): void { $this->load([ 'class' => [ @@ -84,7 +86,7 @@ public function testLoadWithDefaultAndClassificationBundleEnableAndCustomCategor $this->assertContainerBuilderHasAlias('sonata.media.manager.category', 'dummy.service.name'); } - public function testDefaultAdapter() + public function testDefaultAdapter(): void { $this->load(); @@ -98,7 +100,7 @@ public function testDefaultAdapter() * * @dataProvider dataAdapter */ - public function testAdapter($serviceId, $extension, $type) + public function testAdapter($serviceId, $extension, $type): void { $this->load(); @@ -117,7 +119,7 @@ public function dataAdapter() ]; } - public function testDefaultResizer() + public function testDefaultResizer(): void { $this->load(); @@ -136,7 +138,7 @@ public function testDefaultResizer() * * @dataProvider dataResizer */ - public function testResizer($serviceId, $type) + public function testResizer($serviceId, $type): void { $this->load(); @@ -154,7 +156,7 @@ public function dataResizer() ]; } - public function testLoadWithSonataAdminDefaults() + public function testLoadWithSonataAdminDefaults(): void { $this->load(); @@ -164,7 +166,7 @@ public function testLoadWithSonataAdminDefaults() ); } - public function testLoadWithSonataAdminCustomConfiguration() + public function testLoadWithSonataAdminCustomConfiguration(): void { $fakeContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerBuilder') ->setMethods(['getParameter', 'getExtensionConfig']) diff --git a/tests/Document/Media.php b/tests/Document/Media.php index 7a5354f81f..766c99b681 100644 --- a/tests/Document/Media.php +++ b/tests/Document/Media.php @@ -1,5 +1,7 @@ id = $id; } diff --git a/tests/Document/MediaManagerTest.php b/tests/Document/MediaManagerTest.php index a3190399f2..b06b1e1dc3 100644 --- a/tests/Document/MediaManagerTest.php +++ b/tests/Document/MediaManagerTest.php @@ -1,5 +1,7 @@ manager = new MediaManager('Sonata\MediaBundle\Model\MediaInterface', $this->createRegistryMock()); } - public function testSave() + public function testSave(): void { $media = new Media(); $this->manager->save($media, 'default', 'media.test'); @@ -43,14 +45,14 @@ public function testSave() $this->assertNull($media->getProviderName()); } - public function testSaveException() + public function testSaveException(): void { $this->expectException(\InvalidArgumentException::class); $this->manager->save(null); } - public function testDeleteException() + public function testDeleteException(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Entity/GalleryManagerTest.php b/tests/Entity/GalleryManagerTest.php index 26be26a564..e5cc2a9538 100644 --- a/tests/Entity/GalleryManagerTest.php +++ b/tests/Entity/GalleryManagerTest.php @@ -1,5 +1,7 @@ getGalleryManager(function ($qb) { + ->getGalleryManager(function ($qb): void { $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); $qb->expects($this->never())->method('andWhere'); $qb->expects($this->once())->method('orderBy')->with( @@ -35,21 +37,21 @@ public function testGetPager() ->getPager([], 1); } - public function testGetPagerWithInvalidSort() + public function testGetPagerWithInvalidSort(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Invalid sort field \'invalid\' in \'Sonata\\MediaBundle\\Entity\\BaseGallery\' class'); $this - ->getGalleryManager(function ($qb) { + ->getGalleryManager(function ($qb): void { }) ->getPager([], 1, 10, ['invalid' => 'ASC']); } - public function testGetPagerWithMultipleSort() + public function testGetPagerWithMultipleSort(): void { $this - ->getGalleryManager(function ($qb) { + ->getGalleryManager(function ($qb): void { $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); $qb->expects($this->never())->method('andWhere'); $qb->expects($this->exactly(2))->method('orderBy')->with( @@ -70,10 +72,10 @@ public function testGetPagerWithMultipleSort() ]); } - public function testGetPagerWithEnabledGalleries() + public function testGetPagerWithEnabledGalleries(): void { $this - ->getGalleryManager(function ($qb) { + ->getGalleryManager(function ($qb): void { $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); $qb->expects($this->once())->method('andWhere')->with($this->equalTo('g.enabled = :enabled')); $qb->expects($this->once())->method('setParameters')->with($this->equalTo(['enabled' => true])); @@ -81,10 +83,10 @@ public function testGetPagerWithEnabledGalleries() ->getPager(['enabled' => true], 1); } - public function testGetPagerWithNoEnabledGalleries() + public function testGetPagerWithNoEnabledGalleries(): void { $this - ->getGalleryManager(function ($qb) { + ->getGalleryManager(function ($qb): void { $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); $qb->expects($this->once())->method('andWhere')->with($this->equalTo('g.enabled = :enabled')); $qb->expects($this->once())->method('setParameters')->with($this->equalTo(['enabled' => false])); diff --git a/tests/Entity/Media.php b/tests/Entity/Media.php index 7a8ea33b30..8bf3f5dfb8 100644 --- a/tests/Entity/Media.php +++ b/tests/Entity/Media.php @@ -1,5 +1,7 @@ id = $id; } diff --git a/tests/Entity/MediaManagerTest.php b/tests/Entity/MediaManagerTest.php index 232e009049..0e9de8fcb9 100644 --- a/tests/Entity/MediaManagerTest.php +++ b/tests/Entity/MediaManagerTest.php @@ -1,5 +1,7 @@ getMediaManager(function ($qb) use ($self) { + ->getMediaManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->once())->method('setParameters')->with($self->equalTo([])); @@ -32,23 +34,23 @@ public function testGetPager() ->getPager([], 1); } - public function testGetPagerWithInvalidSort() + public function testGetPagerWithInvalidSort(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Invalid sort field \'invalid\' in \'Sonata\\MediaBundle\\Entity\\BaseMedia\' class'); $self = $this; $this - ->getMediaManager(function ($qb) use ($self) { + ->getMediaManager(function ($qb) use ($self): void { }) ->getPager([], 1, 10, ['invalid' => 'ASC']); } - public function testGetPagerWithMultipleSort() + public function testGetPagerWithMultipleSort(): void { $self = $this; $this - ->getMediaManager(function ($qb) use ($self) { + ->getMediaManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->never())->method('andWhere'); $qb->expects($self->exactly(2))->method('orderBy')->with( @@ -69,11 +71,11 @@ public function testGetPagerWithMultipleSort() ]); } - public function testGetPagerWithEnabledMedia() + public function testGetPagerWithEnabledMedia(): void { $self = $this; $this - ->getMediaManager(function ($qb) use ($self) { + ->getMediaManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('m.enabled = :enabled')); $qb->expects($self->once())->method('setParameters')->with($self->equalTo(['enabled' => true])); @@ -81,11 +83,11 @@ public function testGetPagerWithEnabledMedia() ->getPager(['enabled' => true], 1); } - public function testGetPagerWithNoEnabledMedias() + public function testGetPagerWithNoEnabledMedias(): void { $self = $this; $this - ->getMediaManager(function ($qb) use ($self) { + ->getMediaManager(function ($qb) use ($self): void { $qb->expects($self->once())->method('getRootAliases')->will($self->returnValue(['g'])); $qb->expects($self->once())->method('andWhere')->with($self->equalTo('m.enabled = :enabled')); $qb->expects($self->once())->method('setParameters')->with($self->equalTo(['enabled' => false])); diff --git a/tests/Entity/MediaTest.php b/tests/Entity/MediaTest.php index cdc430e424..e84d82831b 100644 --- a/tests/Entity/MediaTest.php +++ b/tests/Entity/MediaTest.php @@ -1,5 +1,7 @@ assertSame($media->getMetadataValue('thumbnail_url1'), null, '::getMetadataValue() return the null value'); } - public function testStatusList() + public function testStatusList(): void { $status = Media::getStatusList(); $this->assertInternalType('array', $status); } - public function testSetGet() + public function testSetGet(): void { $category = $this->prophesize(); $category->willExtend('Sonata\MediaBundle\Tests\Controller\EntityWithGetId'); @@ -73,7 +75,7 @@ public function testSetGet() $this->assertNull($media->getMetadataValue('foo')); } - public function testGetMediaFileExtension() + public function testGetMediaFileExtension(): void { $media = new Media(); @@ -87,7 +89,7 @@ public function testGetMediaFileExtension() $this->assertSame('png', $media->getExtension(), 'extension should not contain query strings or hashes'); } - public function testSetCategoryWithoutAnActualCategory() + public function testSetCategoryWithoutAnActualCategory(): void { $this->expectException('\InvalidArgumentException'); diff --git a/tests/Filesystem/LocalTest.php b/tests/Filesystem/LocalTest.php index 0e33a2db2d..bdaeb5496f 100644 --- a/tests/Filesystem/LocalTest.php +++ b/tests/Filesystem/LocalTest.php @@ -1,5 +1,7 @@ createMock('Gaufrette\Adapter'); $slave = $this->createMock('Gaufrette\Adapter'); diff --git a/tests/Form/DataTransformer/ProviderDataTransformerTest.php b/tests/Form/DataTransformer/ProviderDataTransformerTest.php index 85fc103a00..fa895d0774 100644 --- a/tests/Form/DataTransformer/ProviderDataTransformerTest.php +++ b/tests/Form/DataTransformer/ProviderDataTransformerTest.php @@ -1,5 +1,7 @@ getMockBuilder('Sonata\MediaBundle\Provider\Pool')->disableOriginalConstructor()->getMock(); @@ -27,7 +29,7 @@ public function testReverseTransformFakeValue() $this->assertSame('foo', $transformer->reverseTransform('foo')); } - public function testReverseTransformUnknownProvider() + public function testReverseTransformUnknownProvider(): void { $this->expectException(\RuntimeException::class); @@ -44,7 +46,7 @@ public function testReverseTransformUnknownProvider() $transformer->reverseTransform($media); } - public function testReverseTransformValidProvider() + public function testReverseTransformValidProvider(): void { $provider = $this->createMock('Sonata\MediaBundle\Provider\MediaProviderInterface'); $provider->expects($this->once())->method('transform'); @@ -63,7 +65,7 @@ public function testReverseTransformValidProvider() $transformer->reverseTransform($media); } - public function testReverseTransformWithNewMediaAndNoBinaryContent() + public function testReverseTransformWithNewMediaAndNoBinaryContent(): void { $provider = $this->createMock('Sonata\MediaBundle\Provider\MediaProviderInterface'); @@ -84,7 +86,7 @@ public function testReverseTransformWithNewMediaAndNoBinaryContent() $this->assertSame($media, $transformer->reverseTransform($media)); } - public function testReverseTransformWithMediaAndNoBinaryContent() + public function testReverseTransformWithMediaAndNoBinaryContent(): void { $provider = $this->createMock('Sonata\MediaBundle\Provider\MediaProviderInterface'); @@ -99,7 +101,7 @@ public function testReverseTransformWithMediaAndNoBinaryContent() $this->assertSame($media, $transformer->reverseTransform($media)); } - public function testReverseTransformWithMediaAndUploadFileInstance() + public function testReverseTransformWithMediaAndUploadFileInstance(): void { $provider = $this->createMock('Sonata\MediaBundle\Provider\MediaProviderInterface'); @@ -117,7 +119,7 @@ public function testReverseTransformWithMediaAndUploadFileInstance() $transformer->reverseTransform($media); } - public function testReverseTransformWithThrowingProviderNoThrow() + public function testReverseTransformWithThrowingProviderNoThrow(): void { $provider = $this->createMock('Sonata\MediaBundle\Provider\MediaProviderInterface'); $provider->expects($this->once())->method('transform')->will($this->throwException(new \Exception())); @@ -136,7 +138,7 @@ public function testReverseTransformWithThrowingProviderNoThrow() $transformer->reverseTransform($media); } - public function testReverseTransformWithThrowingProviderLogsException() + public function testReverseTransformWithThrowingProviderLogsException(): void { $provider = $this->createMock('Sonata\MediaBundle\Provider\MediaProviderInterface'); $provider->expects($this->once())->method('transform')->will($this->throwException(new \Exception())); diff --git a/tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php b/tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php index 96c0ebad8a..e7af5d2de7 100644 --- a/tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php +++ b/tests/Form/DataTransformer/ServiceProviderDataTransformerTest.php @@ -1,5 +1,7 @@ prophesize('Sonata\MediaBundle\Provider\MediaProviderInterface'); @@ -27,7 +29,7 @@ public function testTransformNoop() $this->assertSame($value, $transformer->transform($value)); } - public function testReverseTransformSkipsProviderIfNotMedia() + public function testReverseTransformSkipsProviderIfNotMedia(): void { $provider = $this->prophesize('Sonata\MediaBundle\Provider\MediaProviderInterface'); $provider->transform()->shouldNotBeCalled(); @@ -38,7 +40,7 @@ public function testReverseTransformSkipsProviderIfNotMedia() $this->assertSame($media, $transformer->reverseTransform($media)); } - public function testReverseTransformForwardsToProvider() + public function testReverseTransformForwardsToProvider(): void { $media = $this->prophesize('Sonata\MediaBundle\Model\MediaInterface')->reveal(); @@ -49,7 +51,7 @@ public function testReverseTransformForwardsToProvider() $this->assertSame($media, $transformer->reverseTransform($media)); } - public function testReverseTransformWithThrowingProviderNoThrow() + public function testReverseTransformWithThrowingProviderNoThrow(): void { $media = $this->prophesize('Sonata\MediaBundle\Model\MediaInterface')->reveal(); @@ -60,7 +62,7 @@ public function testReverseTransformWithThrowingProviderNoThrow() $transformer->reverseTransform($media); } - public function testReverseTransformWithThrowingProviderLogsException() + public function testReverseTransformWithThrowingProviderLogsException(): void { $media = $this->prophesize('Sonata\MediaBundle\Model\MediaInterface')->reveal(); diff --git a/tests/Form/Type/AbstractTypeTest.php b/tests/Form/Type/AbstractTypeTest.php index ac8a119f49..c79851d080 100644 --- a/tests/Form/Type/AbstractTypeTest.php +++ b/tests/Form/Type/AbstractTypeTest.php @@ -1,5 +1,7 @@ getMockBuilder('Sonata\MediaBundle\Provider\MediaProviderInterface') ->disableOriginalConstructor() @@ -49,7 +51,7 @@ protected function setUp() $this->formBuilder ->expects($this->any()) ->method('add') - ->will($this->returnCallback(function ($name, $type = null) { + ->will($this->returnCallback(function ($name, $type = null): void { if (null !== $type) { $this->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } @@ -58,7 +60,7 @@ protected function setUp() $this->formType = $this->getTestedInstance(); } - public function testBuildForm() + public function testBuildForm(): void { $this->formType->buildForm($this->formBuilder, [ 'provider_name' => 'sonata.media.provider.image', @@ -69,7 +71,7 @@ public function testBuildForm() ]); } - public function testGetParent() + public function testGetParent(): void { $parentRef = $this->formType->getParent(); $this->assertTrue(class_exists($parentRef), sprintf('Unable to ensure %s is a FQCN', $parentRef)); diff --git a/tests/Form/Type/ApiMediaTypeTest.php b/tests/Form/Type/ApiMediaTypeTest.php index 1dc01b3d87..78ce4ba5cb 100644 --- a/tests/Form/Type/ApiMediaTypeTest.php +++ b/tests/Form/Type/ApiMediaTypeTest.php @@ -1,5 +1,7 @@ getMockBuilder('Sonata\MediaBundle\Provider\MediaProviderInterface')->getMock(); diff --git a/tests/Form/Type/MediaTypeTest.php b/tests/Form/Type/MediaTypeTest.php index c1ef662678..8c4f118045 100644 --- a/tests/Form/Type/MediaTypeTest.php +++ b/tests/Form/Type/MediaTypeTest.php @@ -1,5 +1,7 @@ getFormFactory(); } - public function testMissingFormOptions() + public function testMissingFormOptions(): void { $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', @@ -62,7 +64,7 @@ public function testMissingFormOptions() $this->factory->create($this->getFormType(), null); } - public function testMissingFormContextOption() + public function testMissingFormContextOption(): void { $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', @@ -80,7 +82,7 @@ public function testMissingFormContextOption() ]); } - public function testMissingFormProviderOption() + public function testMissingFormProviderOption(): void { $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', @@ -98,7 +100,7 @@ public function testMissingFormProviderOption() ]); } - public function testInvalidFormProviderOption() + public function testInvalidFormProviderOption(): void { $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', @@ -120,7 +122,7 @@ public function testInvalidFormProviderOption() ]); } - public function testInvalidFormContextOption() + public function testInvalidFormContextOption(): void { $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ 'provider_a' => 'provider_a', diff --git a/tests/Generator/DefaultGeneratorTest.php b/tests/Generator/DefaultGeneratorTest.php index 47a4f9ce4a..5e4582c1be 100644 --- a/tests/Generator/DefaultGeneratorTest.php +++ b/tests/Generator/DefaultGeneratorTest.php @@ -1,5 +1,7 @@ createMock('Sonata\\MediaBundle\\Provider\\MediaProviderInterface'); diff --git a/tests/Metadata/AmazonMetadataBuilderTest.php b/tests/Metadata/AmazonMetadataBuilderTest.php index 2f946cb8d7..3b5c33fe88 100644 --- a/tests/Metadata/AmazonMetadataBuilderTest.php +++ b/tests/Metadata/AmazonMetadataBuilderTest.php @@ -1,5 +1,7 @@ createMock('Sonata\MediaBundle\Model\MediaInterface'); $filename = '/test/folder/testfile.png'; diff --git a/tests/Metadata/NoopMetadataBuilderTest.php b/tests/Metadata/NoopMetadataBuilderTest.php index fc908efe71..bafb771f77 100644 --- a/tests/Metadata/NoopMetadataBuilderTest.php +++ b/tests/Metadata/NoopMetadataBuilderTest.php @@ -1,5 +1,7 @@ createMock('Sonata\MediaBundle\Model\MediaInterface'); $filename = '/test/folder/testfile.png'; diff --git a/tests/Metadata/ProxyMetadataBuilderTest.php b/tests/Metadata/ProxyMetadataBuilderTest.php index a8dd45dee5..6bb959900c 100644 --- a/tests/Metadata/ProxyMetadataBuilderTest.php +++ b/tests/Metadata/ProxyMetadataBuilderTest.php @@ -1,5 +1,7 @@ getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->once()) @@ -60,7 +62,7 @@ public function testProxyAmazon() $this->assertSame(['key' => 'amazon'], $proxymetadatabuilder->get($media, $filename)); } - public function testProxyLocal() + public function testProxyLocal(): void { $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) @@ -99,7 +101,7 @@ public function testProxyLocal() $this->assertSame(['key' => 'noop'], $proxymetadatabuilder->get($media, $filename)); } - public function testProxyNoProvider() + public function testProxyNoProvider(): void { $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) @@ -138,7 +140,7 @@ public function testProxyNoProvider() $this->assertSame([], $proxymetadatabuilder->get($media, $filename)); } - public function testProxyReplicateWithAmazon() + public function testProxyReplicateWithAmazon(): void { $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->once()) @@ -180,7 +182,7 @@ public function testProxyReplicateWithAmazon() $this->assertSame(['key' => 'amazon'], $proxymetadatabuilder->get($media, $filename)); } - public function testProxyReplicateWithoutAmazon() + public function testProxyReplicateWithoutAmazon(): void { $amazon = $this->getMockBuilder('Sonata\MediaBundle\Metadata\AmazonMetadataBuilder')->disableOriginalConstructor()->getMock(); $amazon->expects($this->never()) diff --git a/tests/Model/MediaTest.php b/tests/Model/MediaTest.php index 6b6f2e1261..ef9f44e371 100644 --- a/tests/Model/MediaTest.php +++ b/tests/Model/MediaTest.php @@ -1,5 +1,7 @@ getMediaPropertyReflection('providerMetadata'); diff --git a/tests/PHPCR/Media.php b/tests/PHPCR/Media.php index 0a51d98801..0f1f40d5c3 100644 --- a/tests/PHPCR/Media.php +++ b/tests/PHPCR/Media.php @@ -1,5 +1,7 @@ id = $id; } diff --git a/tests/PHPCR/MediaManagerTest.php b/tests/PHPCR/MediaManagerTest.php index 18f583087c..d6440de972 100644 --- a/tests/PHPCR/MediaManagerTest.php +++ b/tests/PHPCR/MediaManagerTest.php @@ -1,5 +1,7 @@ manager = new MediaManager('Sonata\MediaBundle\Model\MediaInterface', $this->createRegistryMock()); } - public function testSave() + public function testSave(): void { $media = new Media(); $this->manager->save($media, 'default', 'media.test'); @@ -43,14 +45,14 @@ public function testSave() $this->assertNull($media->getProviderName()); } - public function testSaveException() + public function testSaveException(): void { $this->expectException(\InvalidArgumentException::class); $this->manager->save(null); } - public function testDeleteException() + public function testDeleteException(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Provider/AbstractProviderTest.php b/tests/Provider/AbstractProviderTest.php index 2c5c226ae5..88a7fc9c08 100644 --- a/tests/Provider/AbstractProviderTest.php +++ b/tests/Provider/AbstractProviderTest.php @@ -1,5 +1,7 @@ formMapper = $this->getMockBuilder('Sonata\AdminBundle\Form\FormMapper')->disableOriginalConstructor()->getMock(); $this->formMapper ->expects($this->any()) ->method('add') - ->will($this->returnCallback(function ($name, $type = null) { + ->will($this->returnCallback(function ($name, $type = null): void { if (null !== $type) { $this->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } @@ -58,7 +60,7 @@ protected function setUp() $this->formBuilder ->expects($this->any()) ->method('add') - ->will($this->returnCallback(function ($name, $type = null) { + ->will($this->returnCallback(function ($name, $type = null): void { if (null !== $type) { $this->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } @@ -74,17 +76,17 @@ protected function setUp() */ abstract public function getProvider(); - public function testBuildEditForm() + public function testBuildEditForm(): void { $this->provider->buildEditForm($this->formMapper); } - public function testBuildCreateForm() + public function testBuildCreateForm(): void { $this->provider->buildCreateForm($this->formMapper); } - public function testBuildMediaType() + public function testBuildMediaType(): void { $this->provider->buildMediaType($this->formBuilder); } diff --git a/tests/Provider/BaseProviderTest.php b/tests/Provider/BaseProviderTest.php index d2a3848805..f3e221ef26 100644 --- a/tests/Provider/BaseProviderTest.php +++ b/tests/Provider/BaseProviderTest.php @@ -1,5 +1,7 @@ getProvider(); $provider->setTemplates([ @@ -73,13 +75,13 @@ public function testBaseProvider() $this->assertSame('test_small', $provider->getFormatName($media, 'test_small')); } - public function testGetCdnPath() + public function testGetCdnPath(): void { $provider = $this->getProvider(); $this->assertSame('/uploads/media/my_file.txt', $provider->getCdnPath('my_file.txt', false)); } - public function testMetadata() + public function testMetadata(): void { $provider = $this->getProvider(); @@ -96,7 +98,7 @@ class TestProvider extends BaseProvider /** * {@inheritdoc} */ - public function getHelperProperties(MediaInterface $media, $format, $options = []) + public function getHelperProperties(MediaInterface $media, $format, $options = []): void { // TODO: Implement getHelperProperties() method. } @@ -104,7 +106,7 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ /** * {@inheritdoc} */ - public function postPersist(MediaInterface $media) + public function postPersist(MediaInterface $media): void { // TODO: Implement postPersist() method. } @@ -112,7 +114,7 @@ public function postPersist(MediaInterface $media) /** * {@inheritdoc} */ - public function buildEditForm(FormMapper $form) + public function buildEditForm(FormMapper $form): void { // TODO: Implement buildEditForm() method. } @@ -120,7 +122,7 @@ public function buildEditForm(FormMapper $form) /** * {@inheritdoc} */ - public function buildCreateForm(FormMapper $form) + public function buildCreateForm(FormMapper $form): void { // TODO: Implement buildCreateForm() method. } @@ -128,7 +130,7 @@ public function buildCreateForm(FormMapper $form) /** * {@inheritdoc} */ - public function postUpdate(MediaInterface $media) + public function postUpdate(MediaInterface $media): void { // TODO: Implement postUpdate() method. } @@ -136,7 +138,7 @@ public function postUpdate(MediaInterface $media) /** * {@inheritdoc} */ - public function getAbsolutePath(MediaInterface $media) + public function getAbsolutePath(MediaInterface $media): void { // TODO: Implement getAbsolutePath() method. } @@ -144,7 +146,7 @@ public function getAbsolutePath(MediaInterface $media) /** * {@inheritdoc} */ - public function getReferenceImage(MediaInterface $media) + public function getReferenceImage(MediaInterface $media): void { // TODO: Implement getReferenceImage() method. } @@ -152,7 +154,7 @@ public function getReferenceImage(MediaInterface $media) /** * {@inheritdoc} */ - public function generatePrivateUrl(MediaInterface $media, $format) + public function generatePrivateUrl(MediaInterface $media, $format): void { // TODO: Implement generatePrivateUrl() method. } @@ -160,7 +162,7 @@ public function generatePrivateUrl(MediaInterface $media, $format) /** * {@inheritdoc} */ - public function generatePublicUrl(MediaInterface $media, $format) + public function generatePublicUrl(MediaInterface $media, $format): void { // TODO: Implement generatePublicUrl() method. } @@ -168,7 +170,7 @@ public function generatePublicUrl(MediaInterface $media, $format) /** * {@inheritdoc} */ - public function getReferenceFile(MediaInterface $media) + public function getReferenceFile(MediaInterface $media): void { // TODO: Implement getReferenceFile() method. } @@ -176,7 +178,7 @@ public function getReferenceFile(MediaInterface $media) /** * {@inheritdoc} */ - public function preUpdate(MediaInterface $media) + public function preUpdate(MediaInterface $media): void { // TODO: Implement preUpdate() method. } @@ -184,7 +186,7 @@ public function preUpdate(MediaInterface $media) /** * {@inheritdoc} */ - public function postRemove(MediaInterface $media) + public function postRemove(MediaInterface $media): void { // TODO: Implement postRemove() method. } @@ -192,7 +194,7 @@ public function postRemove(MediaInterface $media) /** * {@inheritdoc} */ - public function prePersist(MediaInterface $media) + public function prePersist(MediaInterface $media): void { // TODO: Implement prePersist() method. } @@ -200,7 +202,7 @@ public function prePersist(MediaInterface $media) /** * {@inheritdoc} */ - public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) + public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []): void { // TODO: Implement getDownloadResponse() method. } @@ -208,7 +210,7 @@ public function getDownloadResponse(MediaInterface $media, $format, $mode, array /** * {@inheritdoc} */ - public function buildMediaType(FormBuilder $formBuilder) + public function buildMediaType(FormBuilder $formBuilder): void { // TODO: Implement buildMediaType() method. } @@ -216,7 +218,7 @@ public function buildMediaType(FormBuilder $formBuilder) /** * {@inheritdoc} */ - public function updateMetadata(MediaInterface $media, $force = false) + public function updateMetadata(MediaInterface $media, $force = false): void { // TODO: Implement updateMetadata() method. } @@ -224,7 +226,7 @@ public function updateMetadata(MediaInterface $media, $force = false) /** * {@inheritdoc} */ - protected function doTransform(MediaInterface $media) + protected function doTransform(MediaInterface $media): void { // TODO: Implement doTransform() method. } diff --git a/tests/Provider/DailyMotionProviderTest.php b/tests/Provider/DailyMotionProviderTest.php index 6a0c8cf953..7e0ac9a10d 100644 --- a/tests/Provider/DailyMotionProviderTest.php +++ b/tests/Provider/DailyMotionProviderTest.php @@ -1,5 +1,7 @@ getProvider(); @@ -74,7 +76,7 @@ public function testProvider() $this->assertSame('/uploads/media/default/0011/24/thumb_1023458_big.jpg', $provider->generatePublicUrl($media, 'big')); } - public function testThumbnail() + public function testThumbnail(): void { $response = $this->createMock('Buzz\Message\AbstractMessage'); $response->expects($this->once())->method('getContent')->will($this->returnValue('content')); @@ -105,7 +107,7 @@ public function testThumbnail() $this->assertSame('default/0011/24/thumb_1023458_big.jpg', $provider->generatePrivateUrl($media, 'big')); } - public function testTransformWithSig() + public function testTransformWithSig(): void { $response = new Response(); $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_dailymotion.txt')); @@ -128,7 +130,7 @@ public function testTransformWithSig() $this->assertSame('x9wjql', $media->getProviderReference(), '::getProviderReference() is set'); } - public function testTransformWithUrl() + public function testTransformWithUrl(): void { $response = new Response(); $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_dailymotion.txt')); @@ -151,7 +153,7 @@ public function testTransformWithUrl() $this->assertSame('x9wjql', $media->getProviderReference(), '::getProviderReference() is set'); } - public function testForm() + public function testForm(): void { $provider = $this->getProvider(); @@ -173,7 +175,7 @@ public function testForm() $provider->buildEditForm($formMapper); } - public function testHelperProperies() + public function testHelperProperies(): void { $provider = $this->getProvider(); @@ -192,7 +194,7 @@ public function testHelperProperies() $this->assertSame(100, $properties['width']); } - public function testGetReferenceUrl() + public function testGetReferenceUrl(): void { $media = new Media(); $media->setProviderReference('123456'); diff --git a/tests/Provider/FakeHttpWrapper.php b/tests/Provider/FakeHttpWrapper.php index 86201dac8e..5d2561ed34 100644 --- a/tests/Provider/FakeHttpWrapper.php +++ b/tests/Provider/FakeHttpWrapper.php @@ -1,5 +1,7 @@ fp); } - public function stream_flush() + public function stream_flush(): void { } - public function stream_lock($operation) + public function stream_lock($operation): void { } @@ -105,31 +107,31 @@ public function stream_read($count) return fread($this->fp, $count); } - public function stream_seek($offset, $whence = SEEK_SET) + public function stream_seek($offset, $whence = SEEK_SET): void { } - public function stream_set_option($option, $arg1, $arg2) + public function stream_set_option($option, $arg1, $arg2): void { } - public function stream_stat() + public function stream_stat(): void { } - public function stream_tell() + public function stream_tell(): void { } - public function stream_write($data) + public function stream_write($data): void { } - public function unlink($path) + public function unlink($path): void { } - public function url_stat($path, $flags) + public function url_stat($path, $flags): void { } } diff --git a/tests/Provider/FileProviderTest.php b/tests/Provider/FileProviderTest.php index 86cd8a7b14..cacdaac33a 100644 --- a/tests/Provider/FileProviderTest.php +++ b/tests/Provider/FileProviderTest.php @@ -1,5 +1,7 @@ getProvider(); @@ -68,7 +70,7 @@ public function testProvider() $this->assertSame('/uploads/media/sonatamedia/files/big/file.png', $provider->generatePublicUrl($media, 'big')); } - public function testHelperProperies() + public function testHelperProperies(): void { $provider = $this->getProvider(); @@ -85,7 +87,7 @@ public function testHelperProperies() $this->assertSame('test.png', $properties['title']); } - public function testForm() + public function testForm(): void { $provider = $this->getProvider(); @@ -106,7 +108,7 @@ public function testForm() $provider->buildEditForm($formMapper); } - public function testThumbnail() + public function testThumbnail(): void { $provider = $this->getProvider(); @@ -117,7 +119,7 @@ public function testThumbnail() $provider->generateThumbnails($media); } - public function testEvent() + public function testEvent(): void { $provider = $this->getProvider(); @@ -153,7 +155,7 @@ public function testEvent() $this->assertNotNull($provider->generatePrivateUrl($media, 'reference'), '::generatePrivateUrl() return path for reference formate'); } - public function testDownload() + public function testDownload(): void { $provider = $this->getProvider(); @@ -173,9 +175,9 @@ public function testDownload() /** * @dataProvider mediaProvider */ - public function testTransform($expected, $media) + public function testTransform($expected, $media): void { - $closure = function () use ($expected, $media) { + $closure = function () use ($expected, $media): void { $provider = $this->getProvider(); $provider->transform($media); @@ -214,7 +216,7 @@ public function mediaProvider() * * @see https://github.com/sebastianbergmann/phpunit/issues/1409 */ - public function testBinaryContentWithRealPath() + public function testBinaryContentWithRealPath(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -259,7 +261,7 @@ public function testBinaryContentWithRealPath() * * @see https://github.com/sebastianbergmann/phpunit/issues/1409 */ - public function testBinaryContentStreamWrapped() + public function testBinaryContentStreamWrapped(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -300,7 +302,7 @@ public function testBinaryContentStreamWrapped() $setFileContents->invoke($provider, $media); } - public function testValidate() + public function testValidate(): void { $errorElement = $this->getMockBuilder('Sonata\CoreBundle\Validator\ErrorElement') ->disableOriginalConstructor() @@ -312,7 +314,7 @@ public function testValidate() $provider->validate($errorElement, $media); } - public function testValidateUploadSize() + public function testValidateUploadSize(): void { $errorElement = $this->getMockBuilder('Sonata\CoreBundle\Validator\ErrorElement') ->disableOriginalConstructor() @@ -344,7 +346,7 @@ public function testValidateUploadSize() $provider->validate($errorElement, $media); } - public function testValidateUploadType() + public function testValidateUploadType(): void { $errorElement = $this->getMockBuilder('Sonata\CoreBundle\Validator\ErrorElement') ->disableOriginalConstructor() diff --git a/tests/Provider/ImageProviderTest.php b/tests/Provider/ImageProviderTest.php index 05e58f643c..13def02a67 100644 --- a/tests/Provider/ImageProviderTest.php +++ b/tests/Provider/ImageProviderTest.php @@ -1,5 +1,7 @@ getProvider(); @@ -81,7 +83,7 @@ public function testProvider() $this->assertSame('default/0011/24/thumb_1023456_big.png', $provider->generatePrivateUrl($media, 'big')); } - public function testHelperProperies() + public function testHelperProperies(): void { $adminBox = new Box(100, 100); $mediumBox = new Box(500, 250); @@ -143,7 +145,7 @@ public function testHelperProperies() $this->assertSame(150, $properties['width']); } - public function testThumbnail() + public function testThumbnail(): void { $provider = $this->getProvider(); @@ -164,7 +166,7 @@ public function testThumbnail() $this->assertSame('default/0011/24/thumb_1023456_big.png', $provider->generatePrivateUrl($media, 'big')); } - public function testEvent() + public function testEvent(): void { $provider = $this->getProvider(); @@ -189,7 +191,7 @@ public function testEvent() $provider->postRemove($media); } - public function testTransformFormatNotSupported() + public function testTransformFormatNotSupported(): void { $provider = $this->getProvider(); diff --git a/tests/Provider/PoolTest.php b/tests/Provider/PoolTest.php index 31e7683da3..8f0a0d8bab 100644 --- a/tests/Provider/PoolTest.php +++ b/tests/Provider/PoolTest.php @@ -1,5 +1,7 @@ expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Provider name cannot be empty, did you forget to call setProviderName() in your Media object?'); @@ -35,7 +37,7 @@ public function testGetEmptyProviderName() $mediaPool->getProvider(null); } - public function testGetWithEmptyProviders() + public function testGetWithEmptyProviders(): void { $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Unable to retrieve provider named "provider_a" since there are no providers configured yet.'); @@ -50,7 +52,7 @@ public function testGetWithEmptyProviders() $mediaPool->getProvider('provider_a'); } - public function testGetInvalidProviderName() + public function testGetInvalidProviderName(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Unable to retrieve the provider named "provider_c". Available providers are "provider_a", "provider_b".'); diff --git a/tests/Provider/VimeoProviderTest.php b/tests/Provider/VimeoProviderTest.php index ab3e7f373c..a67d12ab77 100644 --- a/tests/Provider/VimeoProviderTest.php +++ b/tests/Provider/VimeoProviderTest.php @@ -1,5 +1,7 @@ getProvider(); @@ -73,7 +75,7 @@ public function testProvider() $this->assertSame('/uploads/media/default/0011/24/thumb_1023457_big.jpg', $provider->generatePublicUrl($media, 'big')); } - public function testThumbnail() + public function testThumbnail(): void { $response = $this->createMock('Buzz\Message\AbstractMessage'); $response->expects($this->once())->method('getContent')->will($this->returnValue('content')); @@ -104,7 +106,7 @@ public function testThumbnail() $this->assertSame('default/0011/24/thumb_1023457_big.jpg', $provider->generatePrivateUrl($media, 'big')); } - public function testTransformWithSig() + public function testTransformWithSig(): void { $response = new Response(); $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_vimeo.txt')); @@ -131,7 +133,7 @@ public function testTransformWithSig() /** * @dataProvider getTransformWithUrlMedia */ - public function testTransformWithUrl($media) + public function testTransformWithUrl($media): void { $response = new Response(); $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_vimeo.txt')); @@ -167,7 +169,7 @@ public function getTransformWithUrlMedia() ]; } - public function testForm() + public function testForm(): void { $provider = $this->getProvider(); @@ -189,7 +191,7 @@ public function testForm() $provider->buildEditForm($formMapper); } - public function testHelperProperies() + public function testHelperProperies(): void { $provider = $this->getProvider(); @@ -208,7 +210,7 @@ public function testHelperProperies() $this->assertSame(100, $properties['width']); } - public function testGetReferenceUrl() + public function testGetReferenceUrl(): void { $media = new Media(); $media->setProviderReference('123456'); diff --git a/tests/Provider/YouTubeProviderTest.php b/tests/Provider/YouTubeProviderTest.php index 00217c1b98..e8ac026929 100644 --- a/tests/Provider/YouTubeProviderTest.php +++ b/tests/Provider/YouTubeProviderTest.php @@ -1,5 +1,7 @@ getProvider(); @@ -74,7 +76,7 @@ public function testProvider() $this->assertSame('/uploads/media/default/0011/24/thumb_1023457_big.jpg', $provider->generatePublicUrl($media, 'big')); } - public function testThumbnail() + public function testThumbnail(): void { $response = $this->createMock('Buzz\Message\AbstractMessage'); $response->expects($this->once())->method('getContent')->will($this->returnValue('content')); @@ -104,7 +106,7 @@ public function testThumbnail() $this->assertSame('default/0011/24/thumb_1023457_big.jpg', $provider->generatePrivateUrl($media, 'big')); } - public function testTransformWithSig() + public function testTransformWithSig(): void { $response = new Response(); $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_youtube.txt')); @@ -130,7 +132,7 @@ public function testTransformWithSig() /** * @dataProvider getUrls */ - public function testTransformWithUrl($url) + public function testTransformWithUrl($url): void { $response = new Response(); $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_youtube.txt')); @@ -170,7 +172,7 @@ public static function getUrls() ]; } - public function testForm() + public function testForm(): void { $provider = $this->getProvider(); @@ -192,7 +194,7 @@ public function testForm() $provider->buildEditForm($formMapper); } - public function testHelperProperties() + public function testHelperProperties(): void { $provider = $this->getProvider(); @@ -211,7 +213,7 @@ public function testHelperProperties() $this->assertSame(100, $properties['player_parameters']['width']); } - public function testGetReferenceUrl() + public function testGetReferenceUrl(): void { $media = new Media(); $media->setProviderReference('123456'); diff --git a/tests/Resizer/SimpleResizerTest.php b/tests/Resizer/SimpleResizerTest.php index 76c16deba4..66aa6499a3 100644 --- a/tests/Resizer/SimpleResizerTest.php +++ b/tests/Resizer/SimpleResizerTest.php @@ -1,5 +1,7 @@ expectException(\RuntimeException::class); @@ -33,7 +35,7 @@ public function testResizeWithNoWidth() $resizer->resize($media, $file, $file, 'bar', []); } - public function testResize() + public function testResize(): void { $image = $this->createMock('Imagine\Image\ImageInterface'); $image->expects($this->once())->method('thumbnail')->will($this->returnValue($image)); @@ -61,7 +63,7 @@ public function testResize() /** * @dataProvider getBoxSettings */ - public function testGetBox($mode, $settings, Box $mediaSize, Box $result) + public function testGetBox($mode, $settings, Box $mediaSize, Box $result): void { $adapter = $this->createMock('Imagine\Image\ImagineInterface'); diff --git a/tests/Resizer/SquareResizerTest.php b/tests/Resizer/SquareResizerTest.php index ec06d9249e..b27b14d7cb 100644 --- a/tests/Resizer/SquareResizerTest.php +++ b/tests/Resizer/SquareResizerTest.php @@ -1,5 +1,7 @@ expectException(\RuntimeException::class); @@ -34,7 +36,7 @@ public function testResizeWithNoWidth() /** * @dataProvider getBoxSettings */ - public function testGetBox($settings, Box $mediaSize, Box $expected) + public function testGetBox($settings, Box $mediaSize, Box $expected): void { $adapter = $this->createMock('Imagine\Image\ImagineInterface'); diff --git a/tests/Security/ForbiddenDownloadStrategyTest.php b/tests/Security/ForbiddenDownloadStrategyTest.php index 1aa03c255d..b39264a945 100644 --- a/tests/Security/ForbiddenDownloadStrategyTest.php +++ b/tests/Security/ForbiddenDownloadStrategyTest.php @@ -1,5 +1,7 @@ createMock('Sonata\MediaBundle\Model\MediaInterface'); $request = $this->createMock('Symfony\Component\HttpFoundation\Request'); diff --git a/tests/Security/PublicDownloadStrategyTest.php b/tests/Security/PublicDownloadStrategyTest.php index b343b0377b..6e74e48f7c 100644 --- a/tests/Security/PublicDownloadStrategyTest.php +++ b/tests/Security/PublicDownloadStrategyTest.php @@ -1,5 +1,7 @@ createMock('Sonata\MediaBundle\Model\MediaInterface'); $request = $this->createMock('Symfony\Component\HttpFoundation\Request'); diff --git a/tests/Security/RolesDownloadStrategyTest.php b/tests/Security/RolesDownloadStrategyTest.php index 4eb7acf0e6..88ad69e173 100644 --- a/tests/Security/RolesDownloadStrategyTest.php +++ b/tests/Security/RolesDownloadStrategyTest.php @@ -1,5 +1,7 @@ createMock('Sonata\MediaBundle\Model\MediaInterface'); $request = $this->createMock('Symfony\Component\HttpFoundation\Request'); @@ -34,7 +36,7 @@ public function testIsGrantedTrue() $this->assertTrue($strategy->isGranted($media, $request)); } - public function testIsGrantedFalse() + public function testIsGrantedFalse(): void { $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); $request = $this->createMock('Symfony\Component\HttpFoundation\Request'); diff --git a/tests/Security/SessionDownloadStrategyTest.php b/tests/Security/SessionDownloadStrategyTest.php index 23985e18fd..8035e986e3 100644 --- a/tests/Security/SessionDownloadStrategyTest.php +++ b/tests/Security/SessionDownloadStrategyTest.php @@ -1,5 +1,7 @@ createMock('Symfony\Component\Translation\TranslatorInterface'); $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); @@ -34,7 +36,7 @@ public function testIsGrantedFalse() $this->assertFalse($strategy->isGranted($media, $request)); } - public function testIsGrantedTrue() + public function testIsGrantedTrue(): void { $translator = $this->createMock('Symfony\Component\Translation\TranslatorInterface'); $media = $this->createMock('Sonata\MediaBundle\Model\MediaInterface'); diff --git a/tests/Thumbnail/ConsumerThumbnailTest.php b/tests/Thumbnail/ConsumerThumbnailTest.php index d3e57f77e4..ce871808b6 100644 --- a/tests/Thumbnail/ConsumerThumbnailTest.php +++ b/tests/Thumbnail/ConsumerThumbnailTest.php @@ -1,5 +1,7 @@ createMock('Sonata\MediaBundle\Thumbnail\ThumbnailInterface'); $backend = $this->createMock('Sonata\NotificationBundle\Backend\BackendInterface'); diff --git a/tests/Thumbnail/FormatThumbnailTest.php b/tests/Thumbnail/FormatThumbnailTest.php index 11755ea590..033d07c80a 100644 --- a/tests/Thumbnail/FormatThumbnailTest.php +++ b/tests/Thumbnail/FormatThumbnailTest.php @@ -1,5 +1,7 @@ getMediaService(), $this->getMediaManager()); $mediaExtension->initRuntime($this->getEnvironment()); diff --git a/tests/Validator/Constraints/ValidMediaFormatTest.php b/tests/Validator/Constraints/ValidMediaFormatTest.php index edc926e92b..8b1eba77bd 100644 --- a/tests/Validator/Constraints/ValidMediaFormatTest.php +++ b/tests/Validator/Constraints/ValidMediaFormatTest.php @@ -1,5 +1,7 @@ addContext('test', [], ['format1' => []]); @@ -37,7 +39,7 @@ public function testValidate() $validator->validate($gallery, new ValidMediaFormat()); } - public function testValidateNotValidDefaultFormat() + public function testValidateNotValidDefaultFormat(): void { $pool = new Pool('defaultContext'); $pool->addContext('test', [], ['format1' => []]); @@ -55,7 +57,7 @@ public function testValidateNotValidDefaultFormat() $validator->validate($gallery, new ValidMediaFormat()); } - public function testValidateOnlyReferenceIsAllowedIfNotFormats() + public function testValidateOnlyReferenceIsAllowedIfNotFormats(): void { $pool = new Pool('defaultContext'); $pool->addContext('test'); diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 88394ed9d7..d187173bc9 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,5 +1,7 @@ Date: Tue, 12 Dec 2017 01:03:14 +0100 Subject: [PATCH 36/77] Fix tests --- src/DependencyInjection/Configuration.php | 2 +- src/Generator/PHPCRGenerator.php | 2 +- tests/Admin/BaseMediaAdminTest.php | 5 ++++- tests/CDN/PantherPortalTest.php | 22 +++++-------------- tests/Controller/MediaAdminControllerTest.php | 5 ++++- tests/Provider/DailyMotionProviderTest.php | 2 ++ tests/Provider/FileProviderTest.php | 1 + tests/Provider/ImageProviderTest.php | 1 + tests/Provider/VimeoProviderTest.php | 3 +++ tests/Provider/YouTubeProviderTest.php | 2 ++ 10 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index 627b5bcc56..4c4ed3dbe4 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -411,7 +411,7 @@ private function addExtraSection(ArrayNodeDefinition $node): void ->addDefaultsIfNotSet() ->children() ->scalarNode('enabled')->defaultValue(false)->end() - ->scalarNode('secret')->defaultValue(sha1(uniqid(random_int(1, 9999), true)))->end() + ->scalarNode('secret')->defaultValue(sha1(uniqid((string) random_int(1, 9999), true)))->end() ->scalarNode('referrer')->defaultValue('Sonata Media')->end() ->end() ->end() diff --git a/src/Generator/PHPCRGenerator.php b/src/Generator/PHPCRGenerator.php index 40ff816923..52be2765f4 100644 --- a/src/Generator/PHPCRGenerator.php +++ b/src/Generator/PHPCRGenerator.php @@ -22,7 +22,7 @@ class PHPCRGenerator implements GeneratorInterface */ public function generatePath(MediaInterface $media) { - $segments = preg_split('#/#', $media->getId(), null, PREG_SPLIT_NO_EMPTY); + $segments = preg_split('#/#', $media->getId(), -1, PREG_SPLIT_NO_EMPTY); if (count($segments) > 1) { // remove last part from id diff --git a/tests/Admin/BaseMediaAdminTest.php b/tests/Admin/BaseMediaAdminTest.php index 553dcf930a..2af1c097be 100644 --- a/tests/Admin/BaseMediaAdminTest.php +++ b/tests/Admin/BaseMediaAdminTest.php @@ -22,8 +22,11 @@ class TestMediaAdmin extends BaseMediaAdmin class EntityWithGetId { - public function getId(): void + protected $id; + + public function getId() { + return $this->id; } } diff --git a/tests/CDN/PantherPortalTest.php b/tests/CDN/PantherPortalTest.php index 3e45da8bef..b4cfebabad 100644 --- a/tests/CDN/PantherPortalTest.php +++ b/tests/CDN/PantherPortalTest.php @@ -20,14 +20,9 @@ class PantherPortalTest extends TestCase { public function testPortal(): void { - $client = $this->createMock( - 'Sonata\MediaBundle\Tests\CDN\ClientSpy', - ['flush'], - [], - '', - false - ); - $client->expects($this->exactly(3))->method('flush')->will($this->returnValue('Flush successfully submitted.')); + $client = $this->createMock('Sonata\MediaBundle\Tests\CDN\ClientSpy'); + $client->expects($this->any())->method('flush') + ->will($this->returnValue('Flush successfully submitted.')); $panther = new PantherPortal('/foo', 'login', 'pass', 42); $panther->setClient($client); @@ -46,13 +41,7 @@ public function testException(): void $this->expectException('\RuntimeException'); $this->expectExceptionMessage('Unable to flush : Failed!!'); - $client = $this->createMock( - 'Sonata\MediaBundle\Tests\CDN\ClientSpy', - ['flush'], - [], - '', - false - ); + $client = $this->createMock('Sonata\MediaBundle\Tests\CDN\ClientSpy'); $client->expects($this->exactly(1))->method('flush')->will($this->returnValue('Failed!!')); $panther = new PantherPortal('/foo', 'login', 'pass', 42); @@ -64,7 +53,8 @@ public function testException(): void class ClientSpy { - public function flush(): void + public function flush() { + return 'flushed'; } } diff --git a/tests/Controller/MediaAdminControllerTest.php b/tests/Controller/MediaAdminControllerTest.php index acfee8df77..1ceed9e9a2 100644 --- a/tests/Controller/MediaAdminControllerTest.php +++ b/tests/Controller/MediaAdminControllerTest.php @@ -27,8 +27,11 @@ class EntityWithGetId { - public function getId(): void + protected $id; + + public function getId() { + return $this->id; } } diff --git a/tests/Provider/DailyMotionProviderTest.php b/tests/Provider/DailyMotionProviderTest.php index 7e0ac9a10d..eb9c880058 100644 --- a/tests/Provider/DailyMotionProviderTest.php +++ b/tests/Provider/DailyMotionProviderTest.php @@ -120,6 +120,7 @@ public function testTransformWithSig(): void $provider->addFormat('big', ['width' => 200, 'height' => null, 'constraint' => true]); $media = new Media(); + $media->setContext('default'); $media->setBinaryContent('x9wjql'); $media->setId(1023456); @@ -143,6 +144,7 @@ public function testTransformWithUrl(): void $provider->addFormat('big', ['width' => 200, 'height' => null, 'constraint' => true]); $media = new Media(); + $media->setContext('default'); $media->setBinaryContent('http://www.dailymotion.com/video/x9wjql_asdasdasdsa_asdsds'); $media->setId(1023456); diff --git a/tests/Provider/FileProviderTest.php b/tests/Provider/FileProviderTest.php index cacdaac33a..1c499a753a 100644 --- a/tests/Provider/FileProviderTest.php +++ b/tests/Provider/FileProviderTest.php @@ -142,6 +142,7 @@ public function testEvent(): void $file = new \Symfony\Component\HttpFoundation\File\File(realpath(__DIR__.'/../fixtures/file.txt')); $media = new Media(); + $media->setContext('default'); $media->setBinaryContent($file); $media->setId(1023456); diff --git a/tests/Provider/ImageProviderTest.php b/tests/Provider/ImageProviderTest.php index 13def02a67..4842b4c983 100644 --- a/tests/Provider/ImageProviderTest.php +++ b/tests/Provider/ImageProviderTest.php @@ -175,6 +175,7 @@ public function testEvent(): void $file = new \Symfony\Component\HttpFoundation\File\File(realpath(__DIR__.'/../fixtures/logo.png')); $media = new Media(); + $media->setContext('default'); $media->setBinaryContent($file); $media->setId(1023456); diff --git a/tests/Provider/VimeoProviderTest.php b/tests/Provider/VimeoProviderTest.php index a67d12ab77..dc9e52b1b9 100644 --- a/tests/Provider/VimeoProviderTest.php +++ b/tests/Provider/VimeoProviderTest.php @@ -119,6 +119,7 @@ public function testTransformWithSig(): void $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $media = new Media(); + $media->setContext('default'); $media->setBinaryContent('BDYAbAtaDzA'); $media->setId(1023456); @@ -156,10 +157,12 @@ public function testTransformWithUrl($media): void public function getTransformWithUrlMedia() { $mediaWebsite = new Media(); + $mediaWebsite->setContext('default'); $mediaWebsite->setBinaryContent('http://vimeo.com/012341231'); $mediaWebsite->setId(1023456); $mediaPlayer = new Media(); + $mediaPlayer->setContext('default'); $mediaPlayer->setBinaryContent('http://player.vimeo.com/video/012341231'); $mediaPlayer->setId(1023456); diff --git a/tests/Provider/YouTubeProviderTest.php b/tests/Provider/YouTubeProviderTest.php index e8ac026929..4163688f54 100644 --- a/tests/Provider/YouTubeProviderTest.php +++ b/tests/Provider/YouTubeProviderTest.php @@ -119,6 +119,7 @@ public function testTransformWithSig(): void $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $media = new Media(); + $media->setContext('default'); $media->setBinaryContent('BDYAbAtaDzA'); $media->setId(1023456); @@ -145,6 +146,7 @@ public function testTransformWithUrl($url): void $provider->addFormat('big', ['width' => 200, 'height' => 100, 'constraint' => true]); $media = new Media(); + $media->setContext('default'); $media->setBinaryContent($url); $media->setId(1023456); From effc7e583f82ace2f21a83bb813f7b896cee3f6e Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Mon, 26 Feb 2018 02:00:29 +0100 Subject: [PATCH 37/77] Applied fixes from FlintCI --- tests/Thumbnail/LiipImagineThumbnailTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/Thumbnail/LiipImagineThumbnailTest.php b/tests/Thumbnail/LiipImagineThumbnailTest.php index 617df5beb8..6b4d970501 100644 --- a/tests/Thumbnail/LiipImagineThumbnailTest.php +++ b/tests/Thumbnail/LiipImagineThumbnailTest.php @@ -1,5 +1,7 @@ prophesize(CacheManager::class); $cacheManager->getBrowserPath()->willReturn('cache/media/default/0011/24/ASDASDAS.png'); @@ -81,7 +83,7 @@ public function testGenerate() * @group legacy * @expectedDeprecation Using an instance of Symfony\Component\Routing\RouterInterface is deprecated since version 3.3 and will be removed in 4.0. Use Liip\ImagineBundle\Imagine\Cache\CacheManager. */ - public function testLegacyGenerate() + public function testLegacyGenerate(): void { $router = $this->prophesize(RouterInterface::class); $router->generate( From ae2d463547129cfb830b6518859c8b5b71d8bf26 Mon Sep 17 00:00:00 2001 From: SonataCI Date: Tue, 20 Mar 2018 02:06:20 +0100 Subject: [PATCH 38/77] DevKit updates --- .travis.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index b698094809..b37c352d30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -46,10 +46,6 @@ matrix: env: TARGET=lint - php: '7.1' env: COMPOSER_FLAGS="--prefer-lowest" - - php: '7.2' - env: SYMFONY=2.8.* - - php: '7.2' - env: SYMFONY=3.3.* - php: '7.2' env: SYMFONY=3.4.* - php: '7.2' From 17fbc9b9fe614e225d47e0b80123d1f41c814277 Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Fri, 27 Apr 2018 02:00:31 +0200 Subject: [PATCH 39/77] Applied fixes from FlintCI --- src/DependencyInjection/Configuration.php | 2 +- src/Exception/NoDriverException.php | 2 ++ src/Generator/NoDriverGenerator.php | 4 +++- src/Model/NoDriverManager.php | 22 ++++++++++++---------- tests/Generator/NoDriverGeneratorTest.php | 4 +++- tests/Model/NoDriverManagerTest.php | 4 +++- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index dfcd5d739c..36fa65063a 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -27,7 +27,7 @@ class Configuration implements ConfigurationInterface /** * NEXT_MAJOR: make constant protected/private. */ - const DB_DRIVERS = ['doctrine_orm', 'doctrine_mongodb', 'doctrine_phpcr', 'no_driver']; + public const DB_DRIVERS = ['doctrine_orm', 'doctrine_mongodb', 'doctrine_phpcr', 'no_driver']; /** * {@inheritdoc} diff --git a/src/Exception/NoDriverException.php b/src/Exception/NoDriverException.php index c0f99cf795..4f370e15d7 100644 --- a/src/Exception/NoDriverException.php +++ b/src/Exception/NoDriverException.php @@ -1,5 +1,7 @@ expectException(NoDriverException::class); diff --git a/tests/Model/NoDriverManagerTest.php b/tests/Model/NoDriverManagerTest.php index a9ca4dc2c3..40bc271d3f 100644 --- a/tests/Model/NoDriverManagerTest.php +++ b/tests/Model/NoDriverManagerTest.php @@ -1,5 +1,7 @@ expectException(NoDriverException::class); From 2897fab7e22df7a8839a437ea39cf73fd18f59a7 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 5 Jun 2018 08:24:19 +0200 Subject: [PATCH 40/77] Add missing return type hints (#1445) --- src/Twig/Extension/FormatterMediaExtension.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Twig/Extension/FormatterMediaExtension.php b/src/Twig/Extension/FormatterMediaExtension.php index fbea0de78d..6114538fc2 100644 --- a/src/Twig/Extension/FormatterMediaExtension.php +++ b/src/Twig/Extension/FormatterMediaExtension.php @@ -18,18 +18,19 @@ use Sonata\MediaBundle\Twig\TokenParser\MediaTokenParser; use Sonata\MediaBundle\Twig\TokenParser\PathTokenParser; use Sonata\MediaBundle\Twig\TokenParser\ThumbnailTokenParser; +use Twig\Extension\ExtensionInterface; class FormatterMediaExtension extends BaseProxyExtension { /** - * @var \Twig_Extension + * @var ExtensionInterface */ protected $twigExtension; /** - * @param \Twig_Extension $twigExtension + * @param ExtensionInterface $twigExtension */ - public function __construct(\Twig_Extension $twigExtension) + public function __construct(ExtensionInterface $twigExtension) { $this->twigExtension = $twigExtension; } @@ -37,7 +38,7 @@ public function __construct(\Twig_Extension $twigExtension) /** * {@inheritdoc} */ - public function getAllowedTags() + public function getAllowedTags(): array { return [ 'media', @@ -49,7 +50,7 @@ public function getAllowedTags() /** * {@inheritdoc} */ - public function getAllowedMethods() + public function getAllowedMethods(): array { return [ MediaInterface::class => [ @@ -61,7 +62,7 @@ public function getAllowedMethods() /** * {@inheritdoc} */ - public function getTokenParsers() + public function getTokenParsers(): array { return [ new MediaTokenParser(__CLASS__), @@ -71,9 +72,9 @@ public function getTokenParsers() } /** - * {@inheritdoc} + * @return ExtensionInterface */ - public function getTwigExtension() + public function getTwigExtension(): ExtensionInterface { return $this->twigExtension; } From cf6b2db5129d3cfa890ebfa27b78f73e5c8571df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 27 Nov 2018 13:07:03 +0100 Subject: [PATCH 41/77] Bump test dependency This one is compatible with phpunit 7. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0c06b48745..90a99a9963 100644 --- a/composer.json +++ b/composer.json @@ -73,7 +73,7 @@ "friendsofsymfony/rest-bundle": "^2.1", "jackalope/jackalope-doctrine-dbal": "^1.1", "liip/imagine-bundle": "^1.9", - "matthiasnoback/symfony-dependency-injection-test": "^1.0", + "matthiasnoback/symfony-dependency-injection-test": "^3.0", "nelmio/api-doc-bundle": "^2.11", "sonata-project/admin-bundle": "^3.31", "sonata-project/block-bundle": "^3.11", From c97bf196125623695ea4a9337dc1cf7d2f03f664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 27 Nov 2018 20:16:28 +0100 Subject: [PATCH 42/77] Bump test-related symfony components By test-related, I mean either the phpunit-bridge, or components that provided base classes for tests that we extend in this bundle. Make sure we have a version that is compatible with phpunit 7 See https://github.com/symfony/symfony/commit/ddd2dff9b2fea6ddb84386e25179dbb591bd8b42 --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 90a99a9963..b757211789 100644 --- a/composer.json +++ b/composer.json @@ -40,9 +40,9 @@ "symfony/console": "^2.8 || ^3.2 || ^4.0", "symfony/dependency-injection": "^2.8 || ^3.2 || ^4.0", "symfony/event-dispatcher": "^2.8 || ^3.2 || ^4.0", - "symfony/filesystem": "^2.8 || ^3.2 || ^4.0", + "symfony/filesystem": "^2.8.18 || ^3.2.5 || ^4.0", "symfony/finder": "^2.8 || ^3.2 || ^4.0", - "symfony/form": "^2.8 || ^3.2 || ^4.0", + "symfony/form": "^2.8.18 || ^3.2.5 || ^4.0", "symfony/framework-bundle": "^2.8 || ^3.2 || ^4.0", "symfony/http-foundation": "^2.8 || ^3.2 || ^4.0", "symfony/http-kernel": "^2.8 || ^3.2 || ^4.0", @@ -82,7 +82,7 @@ "sonata-project/formatter-bundle": "^3.4 || ^4.0", "sonata-project/notification-bundle": "^3.3", "sonata-project/seo-bundle": "^2.5", - "symfony/phpunit-bridge": "^4.0", + "symfony/phpunit-bridge": "^4.1.8", "symfony/security-csrf": "^2.8 || ^3.2 || ^4.0" }, "suggest": { From b9275d59b804bd7a3f52f37085e912d159a950bd Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Fri, 7 Dec 2018 04:35:11 +0100 Subject: [PATCH 43/77] DevKit updates (#1495) --- .php_cs.dist | 6 ------ .travis.yml | 3 +-- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 658e2c8bc2..3873ae58fb 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -36,12 +36,6 @@ $rules = [ '@PHP56Migration' => true, '@PHP56Migration:risky' => true, '@PHPUnit57Migration:risky' => true, - '@PHP70Migration' => true, - '@PHP70Migration:risky' => true, - '@PHPUnit60Migration:risky' => true, - '@PHP71Migration' => true, - '@PHP71Migration:risky' => true, - 'compact_nullable_typehint' => true, // To be tested before insertion: // 'strict_comparison' => true, // 'strict_param' => true, diff --git a/.travis.yml b/.travis.yml index 408ddfdf99..1ce128de4d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ branches: language: php php: - - '7.1' - '7.2' - nightly @@ -44,7 +43,7 @@ matrix: env: TARGET=docs - php: '7.2' env: TARGET=lint - - php: '7.1' + - php: '7.2' env: COMPOSER_FLAGS="--prefer-lowest" - php: '7.2' env: SYMFONY=3.4.* From d7b87b23c77d9e0cc961099bfd186bb55dd4eae5 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Wed, 12 Dec 2018 04:05:11 +0100 Subject: [PATCH 44/77] DevKit updates (#1501) --- .php_cs.dist | 6 ++++++ .travis.yml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index 3873ae58fb..658e2c8bc2 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -36,6 +36,12 @@ $rules = [ '@PHP56Migration' => true, '@PHP56Migration:risky' => true, '@PHPUnit57Migration:risky' => true, + '@PHP70Migration' => true, + '@PHP70Migration:risky' => true, + '@PHPUnit60Migration:risky' => true, + '@PHP71Migration' => true, + '@PHP71Migration:risky' => true, + 'compact_nullable_typehint' => true, // To be tested before insertion: // 'strict_comparison' => true, // 'strict_param' => true, diff --git a/.travis.yml b/.travis.yml index 78319061b1..61b77341ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,7 +35,7 @@ env: - SYMFONY_DEPRECATIONS_HELPER=weak_vendors - TARGET=test - UPSTREAM_URL=https://github.com/sonata-project/SonataMediaBundle.git - - PHPUNIT_VERSION=5.7 + - PHPUNIT_VERSION=7 matrix: fast_finish: true From aed54c76658d507714200c411456349cd1892487 Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Wed, 8 May 2019 02:01:15 +0200 Subject: [PATCH 45/77] Applied fixes from FlintCI --- tests/Block/GalleryListBlockServiceTest.php | 2 +- tests/CDN/CloudFrontTest.php | 4 +- tests/CDN/PantherPortalTest.php | 4 +- tests/Command/CleanMediaCommandTest.php | 50 +++++++------- tests/Command/FixMediaContextCommandTest.php | 36 +++++----- tests/Command/RemoveThumbsCommandTest.php | 18 ++--- .../Controller/Api/GalleryControllerTest.php | 18 ++--- tests/Controller/Api/MediaControllerTest.php | 54 +++++++-------- tests/Document/MediaManagerTest.php | 2 +- tests/Entity/GalleryManagerTest.php | 10 +-- tests/Entity/MediaManagerTest.php | 2 +- tests/Filesystem/ReplicateTest.php | 18 ++--- .../ProviderDataTransformerTest.php | 40 +++++------ tests/Form/Type/AbstractTypeTest.php | 4 +- tests/Form/Type/ApiMediaTypeTest.php | 2 +- tests/Form/Type/MediaTypeTest.php | 40 +++++------ .../Listener/ORM/MediaEventSubscriberTest.php | 8 +-- tests/Metadata/ProxyMetadataBuilderTest.php | 58 ++++++++-------- tests/Model/MediaTest.php | 2 +- tests/PHPCR/MediaManagerTest.php | 2 +- tests/Provider/AbstractProviderTest.php | 8 +-- tests/Provider/DailyMotionProviderTest.php | 18 ++--- tests/Provider/FileProviderTest.php | 66 +++++++++---------- tests/Provider/ImageProviderTest.php | 12 ++-- tests/Provider/VimeoProviderTest.php | 18 ++--- tests/Provider/YouTubeProviderTest.php | 18 ++--- tests/Resizer/SimpleResizerTest.php | 12 ++-- tests/Resizer/SquareResizerTest.php | 2 +- tests/Security/RolesDownloadStrategyTest.php | 8 +-- tests/Thumbnail/FormatThumbnailTest.php | 18 ++--- tests/Twig/Extension/MediaExtensionTest.php | 2 +- tests/Validator/FormatValidatorTest.php | 12 ++-- 32 files changed, 284 insertions(+), 284 deletions(-) diff --git a/tests/Block/GalleryListBlockServiceTest.php b/tests/Block/GalleryListBlockServiceTest.php index 417783b69c..b759589e18 100644 --- a/tests/Block/GalleryListBlockServiceTest.php +++ b/tests/Block/GalleryListBlockServiceTest.php @@ -45,7 +45,7 @@ protected function setUp(): void public function testExecute(): void { $pager = $this->createMock(PagerInterface::class); - $this->galleryManager->expects($this->once())->method('getPager')->will($this->returnValue($pager)); + $this->galleryManager->expects($this->once())->method('getPager')->willReturn($pager); $block = new Block(); diff --git a/tests/CDN/CloudFrontTest.php b/tests/CDN/CloudFrontTest.php index b80f44f2c3..87be5f93e5 100644 --- a/tests/CDN/CloudFrontTest.php +++ b/tests/CDN/CloudFrontTest.php @@ -32,7 +32,7 @@ public function testLegacyCloudFront(): void ->disableOriginalConstructor() ->getMock(); - $client->expects($this->exactly(3))->method('createInvalidation')->will($this->returnValue(new CloudFrontResultSpy())); + $client->expects($this->exactly(3))->method('createInvalidation')->willReturn(new CloudFrontResultSpy()); $cloudFront = $this->getMockBuilder(CloudFront::class) ->setConstructorArgs(['/foo', 'secret', 'key', 'xxxxxxxxxxxxxx']) @@ -62,7 +62,7 @@ public function testLegacyException(): void ->disableOriginalConstructor() ->getMock(); - $client->expects($this->exactly(1))->method('createInvalidation')->will($this->returnValue(new CloudFrontResultSpy(true))); + $client->expects($this->exactly(1))->method('createInvalidation')->willReturn(new CloudFrontResultSpy(true)); $cloudFront = $this->getMockBuilder(CloudFront::class) ->setConstructorArgs(['/foo', 'secret', 'key', 'xxxxxxxxxxxxxx']) ->setMethods(null) diff --git a/tests/CDN/PantherPortalTest.php b/tests/CDN/PantherPortalTest.php index 049a499c1b..92279f2545 100644 --- a/tests/CDN/PantherPortalTest.php +++ b/tests/CDN/PantherPortalTest.php @@ -22,7 +22,7 @@ public function testPortal(): void { $client = $this->createMock(ClientSpy::class); $client->expects($this->any())->method('flush') - ->will($this->returnValue('Flush successfully submitted.')); + ->willReturn('Flush successfully submitted.'); $panther = new PantherPortal('/foo', 'login', 'pass', 42); $panther->setClient($client); @@ -42,7 +42,7 @@ public function testException(): void $this->expectExceptionMessage('Unable to flush : Failed!!'); $client = $this->createMock(ClientSpy::class); - $client->expects($this->exactly(1))->method('flush')->will($this->returnValue('Failed!!')); + $client->expects($this->exactly(1))->method('flush')->willReturn('Failed!!'); $panther = new PantherPortal('/foo', 'login', 'pass', 42); $panther->setClient($client); diff --git a/tests/Command/CleanMediaCommandTest.php b/tests/Command/CleanMediaCommandTest.php index d2625a33f4..6b6d90f50a 100755 --- a/tests/Command/CleanMediaCommandTest.php +++ b/tests/Command/CleanMediaCommandTest.php @@ -88,11 +88,11 @@ protected function setUp(): void $this->mediaManager = $mediaManager = $this->createMock(MediaManagerInterface::class); $this->fileSystemLocal = $fileSystemLocal = $this->createMock(Local::class); - $this->fileSystemLocal->expects($this->once())->method('getDirectory')->will($this->returnValue($this->workspace)); + $this->fileSystemLocal->expects($this->once())->method('getDirectory')->willReturn($this->workspace); $this->container->expects($this->any()) ->method('get') - ->will($this->returnCallback(static function ($id) use ($pool, $mediaManager, $fileSystemLocal) { + ->willReturnCallback(static function ($id) use ($pool, $mediaManager, $fileSystemLocal) { switch ($id) { case 'sonata.media.pool': return $pool; @@ -101,7 +101,7 @@ protected function setUp(): void case 'sonata.media.adapter.filesystem.local': return $fileSystemLocal; } - })); + }); } public function testExecuteDirectoryNotExists(): void @@ -112,7 +112,7 @@ public function testExecuteDirectoryNotExists(): void 'download' => [], ]; - $this->pool->expects($this->once())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->once())->method('getContexts')->willReturn(['foo' => $context]); $output = $this->tester->execute(['command' => $this->command->getName()]); @@ -131,7 +131,7 @@ public function testExecuteEmptyDirectory(): void 'download' => [], ]; - $this->pool->expects($this->once())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->once())->method('getContexts')->willReturn(['foo' => $context]); $output = $this->tester->execute(['command' => $this->command->getName()]); @@ -153,19 +153,19 @@ public function testExecuteFilesExists(): void ]; $provider = $this->createMock(FileProvider::class); - $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); + $provider->expects($this->any())->method('getName')->willReturn('fooprovider'); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); + $this->pool->expects($this->any())->method('getContexts')->willReturn(['foo' => $context]); + $this->pool->expects($this->any())->method('getProviders')->willReturn([$provider]); $media = $this->createMock(MediaInterface::class); $this->mediaManager->expects($this->once())->method('findOneBy') ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) - ->will($this->returnValue([$media])); + ->willReturn([$media]); $this->mediaManager->expects($this->once())->method('findBy') ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) - ->will($this->returnValue([$media])); + ->willReturn([$media]); $output = $this->tester->execute(['command' => $this->command->getName()]); @@ -187,19 +187,19 @@ public function testExecuteFilesExistsVerbose(): void ]; $provider = $this->createMock(FileProvider::class); - $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); + $provider->expects($this->any())->method('getName')->willReturn('fooprovider'); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); + $this->pool->expects($this->any())->method('getContexts')->willReturn(['foo' => $context]); + $this->pool->expects($this->any())->method('getProviders')->willReturn([$provider]); $media = $this->createMock(MediaInterface::class); $this->mediaManager->expects($this->once())->method('findOneBy') ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) - ->will($this->returnValue([$media])); + ->willReturn([$media]); $this->mediaManager->expects($this->once())->method('findBy') ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) - ->will($this->returnValue([$media])); + ->willReturn([$media]); $output = $this->tester->execute( ['command' => $this->command->getName()], @@ -230,17 +230,17 @@ public function testExecuteDryRun(): void ]; $provider = $this->createMock(FileProvider::class); - $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); + $provider->expects($this->any())->method('getName')->willReturn('fooprovider'); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); + $this->pool->expects($this->any())->method('getContexts')->willReturn(['foo' => $context]); + $this->pool->expects($this->any())->method('getProviders')->willReturn([$provider]); $this->mediaManager->expects($this->once())->method('findOneBy') ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) - ->will($this->returnValue(null)); + ->willReturn(null); $this->mediaManager->expects($this->once())->method('findBy') ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) - ->will($this->returnValue([])); + ->willReturn([]); $output = $this->tester->execute(['command' => $this->command->getName(), '--dry-run' => true]); @@ -268,17 +268,17 @@ public function testExecute(): void ]; $provider = $this->createMock(FileProvider::class); - $provider->expects($this->any())->method('getName')->will($this->returnValue('fooprovider')); + $provider->expects($this->any())->method('getName')->willReturn('fooprovider'); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); - $this->pool->expects($this->any())->method('getProviders')->will($this->returnValue([$provider])); + $this->pool->expects($this->any())->method('getContexts')->willReturn(['foo' => $context]); + $this->pool->expects($this->any())->method('getProviders')->willReturn([$provider]); $this->mediaManager->expects($this->once())->method('findOneBy') ->with($this->equalTo(['id' => 1, 'context' => 'foo'])) - ->will($this->returnValue(null)); + ->willReturn(null); $this->mediaManager->expects($this->once())->method('findBy') ->with($this->equalTo(['providerReference' => 'qwertz.ext', 'providerName' => ['fooprovider']])) - ->will($this->returnValue([])); + ->willReturn([]); $output = $this->tester->execute(['command' => $this->command->getName()]); diff --git a/tests/Command/FixMediaContextCommandTest.php b/tests/Command/FixMediaContextCommandTest.php index 35c39a10c1..14ee7eadd1 100755 --- a/tests/Command/FixMediaContextCommandTest.php +++ b/tests/Command/FixMediaContextCommandTest.php @@ -84,7 +84,7 @@ protected function setUp(): void $this->container->expects($this->any()) ->method('get') - ->will($this->returnCallback(static function ($id) use ($pool, $contextManager, $categoryManager) { + ->willReturnCallback(static function ($id) use ($pool, $contextManager, $categoryManager) { switch ($id) { case 'sonata.media.pool': return $pool; @@ -93,13 +93,13 @@ protected function setUp(): void case 'sonata.media.manager.category': return $categoryManager; } - })); + }); } public function testExecuteWithDisabledClassfication(): void { $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) - ->will($this->returnValue(false)); + ->willReturn(false); $this->expectException(\LogicException::class); @@ -115,17 +115,17 @@ public function testExecuteWithExisting(): void ]; $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) - ->will($this->returnValue(true)); + ->willReturn(true); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->any())->method('getContexts')->willReturn(['foo' => $context]); $contextModel = $this->createMock(ContextInterface::class); - $this->contextManager->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->will($this->returnValue($contextModel)); + $this->contextManager->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->willReturn($contextModel); $category = $this->createMock(CategoryInterface::class); - $this->categoryManager->expects($this->once())->method('getRootCategory')->with($this->equalTo($contextModel))->will($this->returnValue($category)); + $this->categoryManager->expects($this->once())->method('getRootCategory')->with($this->equalTo($contextModel))->willReturn($category); $output = $this->tester->execute(['command' => $this->command->getName()]); @@ -143,18 +143,18 @@ public function testExecuteWithEmptyRoot(): void ]; $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) - ->will($this->returnValue(true)); + ->willReturn(true); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->any())->method('getContexts')->willReturn(['foo' => $context]); $contextModel = $this->createMock(ContextInterface::class); - $this->contextManager->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->will($this->returnValue($contextModel)); + $this->contextManager->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->willReturn($contextModel); $category = $this->createMock(CategoryInterface::class); - $this->categoryManager->expects($this->once())->method('getRootCategory')->with($this->equalTo($contextModel))->will($this->returnValue(null)); - $this->categoryManager->expects($this->once())->method('create')->will($this->returnValue($category)); + $this->categoryManager->expects($this->once())->method('getRootCategory')->with($this->equalTo($contextModel))->willReturn(null); + $this->categoryManager->expects($this->once())->method('create')->willReturn($category); $this->categoryManager->expects($this->once())->method('save')->with($this->equalTo($category)); $output = $this->tester->execute(['command' => $this->command->getName()]); @@ -173,20 +173,20 @@ public function testExecuteWithNew(): void ]; $this->container->method('has')->with($this->equalTo('sonata.media.manager.category')) - ->will($this->returnValue(true)); + ->willReturn(true); - $this->pool->expects($this->any())->method('getContexts')->will($this->returnValue(['foo' => $context])); + $this->pool->expects($this->any())->method('getContexts')->willReturn(['foo' => $context]); $contextModel = $this->createMock(ContextInterface::class); - $this->contextManager->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->will($this->returnValue(null)); - $this->contextManager->expects($this->once())->method('create')->will($this->returnValue($contextModel)); + $this->contextManager->expects($this->once())->method('findOneBy')->with($this->equalTo(['id' => 'foo']))->willReturn(null); + $this->contextManager->expects($this->once())->method('create')->willReturn($contextModel); $this->contextManager->expects($this->once())->method('save')->with($this->equalTo($contextModel)); $category = $this->createMock(CategoryInterface::class); - $this->categoryManager->expects($this->once())->method('getRootCategory')->with($this->equalTo($contextModel))->will($this->returnValue(null)); - $this->categoryManager->expects($this->once())->method('create')->will($this->returnValue($category)); + $this->categoryManager->expects($this->once())->method('getRootCategory')->with($this->equalTo($contextModel))->willReturn(null); + $this->categoryManager->expects($this->once())->method('create')->willReturn($category); $this->categoryManager->expects($this->once())->method('save')->with($this->equalTo($category)); $output = $this->tester->execute(['command' => $this->command->getName()]); diff --git a/tests/Command/RemoveThumbsCommandTest.php b/tests/Command/RemoveThumbsCommandTest.php index 56dd19ca26..80e906e1cc 100644 --- a/tests/Command/RemoveThumbsCommandTest.php +++ b/tests/Command/RemoveThumbsCommandTest.php @@ -84,14 +84,14 @@ protected function setUp(): void $this->container->expects($this->any()) ->method('get') - ->will($this->returnCallback(function ($id) { + ->willReturnCallback(function ($id) { switch ($id) { case 'sonata.media.pool': return $this->pool; case 'sonata.media.manager.media': return $this->mediaManager; } - })); + }); } public function testExecuteWithoutArguments(): void @@ -114,25 +114,25 @@ public function testExecuteWithoutArguments(): void $fileProvider->expects($this->any()) ->method('getName') - ->will($this->returnValue('fooprovider')); + ->willReturn('fooprovider'); $fileProvider->expects($this->once()) ->method('getFormats') - ->will($this->returnValue($formats)); + ->willReturn($formats); $fileProvider->expects($this->exactly(2)) ->method('removeThumbnails'); $fileProvider->expects($this->exactly(2)) ->method('getFilesystem') - ->will($this->returnValue($this->createMock(Filesystem::class))); + ->willReturn($this->createMock(Filesystem::class)); $this->pool->expects($this->once()) ->method('getContexts') - ->will($this->returnValue(['foo' => $context])); + ->willReturn(['foo' => $context]); $this->pool->expects($this->once()) ->method('getProviders') - ->will($this->returnValue(['fooprovider' => $fileProvider])); + ->willReturn(['fooprovider' => $fileProvider]); $this->pool->expects($this->once()) ->method('getProvider') - ->will($this->returnValue($fileProvider)); + ->willReturn($fileProvider); $medias = []; @@ -161,7 +161,7 @@ public function testExecuteWithoutArguments(): void $this->mediaManager->expects($this->exactly(2)) ->method('findBy') - ->will($this->returnCallback($findByReturnCallback)); + ->willReturnCallback($findByReturnCallback); $this->tester->setInputs(['fooprovider', 'foo', 'small']); diff --git a/tests/Controller/Api/GalleryControllerTest.php b/tests/Controller/Api/GalleryControllerTest.php index 3f89e9a9ae..3c9c81d6f3 100644 --- a/tests/Controller/Api/GalleryControllerTest.php +++ b/tests/Controller/Api/GalleryControllerTest.php @@ -35,7 +35,7 @@ public function testGetGalleriesAction(): void $mediaManager = $this->createMock(MediaManagerInterface::class); $formFactory = $this->createMock(FormFactoryInterface::class); - $galleryManager->expects($this->once())->method('getPager')->will($this->returnValue([])); + $galleryManager->expects($this->once())->method('getPager')->willReturn([]); $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); @@ -44,11 +44,11 @@ public function testGetGalleriesAction(): void $paramFetcher ->expects($this->once()) ->method('all') - ->will($this->returnValue([ + ->willReturn([ 'page' => 1, 'count' => 10, 'orderBy' => ['id' => 'ASC'], - ])); + ]); $this->assertSame([], $gController->getGalleriesAction($paramFetcher)); } @@ -60,7 +60,7 @@ public function testGetGalleryAction(): void $gallery = $this->createMock(GalleryInterface::class); $formFactory = $this->createMock(FormFactoryInterface::class); - $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); + $galleryManager->expects($this->once())->method('findOneBy')->willReturn($gallery); $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); @@ -91,9 +91,9 @@ public function testGetGalleryGalleryItemsAction(): void $gallery = $this->createMock(GalleryInterface::class); $formFactory = $this->createMock(FormFactoryInterface::class); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); + $gallery->expects($this->once())->method('getGalleryItems')->willReturn([$galleryItem]); - $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); + $galleryManager->expects($this->once())->method('findOneBy')->willReturn($gallery); $mediaManager = $this->createMock(MediaManagerInterface::class); @@ -111,9 +111,9 @@ public function testGetGalleryMediaAction(): void $galleryManager = $this->createMock(GalleryManagerInterface::class); $mediaManager = $this->createMock(MediaManagerInterface::class); - $galleryItem->expects($this->once())->method('getMedia')->will($this->returnValue($media)); - $gallery->expects($this->once())->method('getGalleryItems')->will($this->returnValue([$galleryItem])); - $galleryManager->expects($this->once())->method('findOneBy')->will($this->returnValue($gallery)); + $galleryItem->expects($this->once())->method('getMedia')->willReturn($media); + $gallery->expects($this->once())->method('getGalleryItems')->willReturn([$galleryItem]); + $galleryManager->expects($this->once())->method('findOneBy')->willReturn($gallery); $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); diff --git a/tests/Controller/Api/MediaControllerTest.php b/tests/Controller/Api/MediaControllerTest.php index a40626a313..25215bf169 100644 --- a/tests/Controller/Api/MediaControllerTest.php +++ b/tests/Controller/Api/MediaControllerTest.php @@ -37,13 +37,13 @@ public function testGetMediaAction(): void $mManager = $this->createMock(MediaManagerInterface::class); $media = $this->createMock(MediaInterface::class); - $mManager->expects($this->once())->method('getPager')->will($this->returnValue([$media])); + $mManager->expects($this->once())->method('getPager')->willReturn([$media]); $mController = $this->createMediaController($mManager); $paramFetcher = $this->createMock(ParamFetcher::class); $paramFetcher->expects($this->exactly(3))->method('get'); - $paramFetcher->expects($this->once())->method('all')->will($this->returnValue([])); + $paramFetcher->expects($this->once())->method('all')->willReturn([]); $this->assertSame([$media], $mController->getMediaAction($paramFetcher)); } @@ -53,7 +53,7 @@ public function testGetMediumAction(): void $media = $this->createMock(MediaInterface::class); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); + $manager->expects($this->once())->method('findOneBy')->willReturn($media); $controller = $this->createMediaController($manager); @@ -73,14 +73,14 @@ public function testGetMediumFormatsAction(): void $media = $this->createMock(MediaInterface::class); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); + $manager->expects($this->once())->method('findOneBy')->willReturn($media); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->exactly(2))->method('getHelperProperties')->will($this->returnValue(['foo' => 'bar'])); + $provider->expects($this->exactly(2))->method('getHelperProperties')->willReturn(['foo' => 'bar']); $pool = $this->createMock(Pool::class); - $pool->expects($this->any())->method('getProvider')->will($this->returnValue($provider)); - $pool->expects($this->once())->method('getFormatNamesByContext')->will($this->returnValue(['format_name1' => 'value1'])); + $pool->expects($this->any())->method('getProvider')->willReturn($provider); + $pool->expects($this->once())->method('getFormatNamesByContext')->willReturn(['format_name1' => 'value1']); $controller = $this->createMediaController($manager, $pool); @@ -108,13 +108,13 @@ public function testGetMediumBinariesAction(): void $binaryResponse = $this->createMock(BinaryFileResponse::class); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); + $manager->expects($this->once())->method('findOneBy')->willReturn($media); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->once())->method('getDownloadResponse')->will($this->returnValue($binaryResponse)); + $provider->expects($this->once())->method('getDownloadResponse')->willReturn($binaryResponse); $pool = $this->createMock(Pool::class); - $pool->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); + $pool->expects($this->once())->method('getProvider')->willReturn($provider); $controller = $this->createMediaController($manager, $pool); @@ -125,7 +125,7 @@ public function testDeleteMediumAction(): void { $manager = $this->createMock(MediaManagerInterface::class); $manager->expects($this->once())->method('delete'); - $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($this->createMock(MediaInterface::class))); + $manager->expects($this->once())->method('findOneBy')->willReturn($this->createMock(MediaInterface::class)); $controller = $this->createMediaController($manager); @@ -139,21 +139,21 @@ public function testPutMediumAction(): void $medium = $this->createMock(MediaInterface::class); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($medium)); + $manager->expects($this->once())->method('findOneBy')->willReturn($medium); $provider = $this->createMock(MediaProviderInterface::class); $provider->expects($this->once())->method('getName'); $pool = $this->createMock(Pool::class); - $pool->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); + $pool->expects($this->once())->method('getProvider')->willReturn($provider); $form = $this->createMock(Form::class); $form->expects($this->once())->method('handleRequest'); - $form->expects($this->once())->method('isValid')->will($this->returnValue(true)); - $form->expects($this->once())->method('getData')->will($this->returnValue($medium)); + $form->expects($this->once())->method('isValid')->willReturn(true); + $form->expects($this->once())->method('getData')->willReturn($medium); $factory = $this->createMock(FormFactoryInterface::class); - $factory->expects($this->once())->method('createNamed')->will($this->returnValue($form)); + $factory->expects($this->once())->method('createNamed')->willReturn($form); $controller = $this->createMediaController($manager, $pool, $factory); @@ -165,20 +165,20 @@ public function testPutMediumInvalidFormAction(): void $medium = $this->createMock(MediaInterface::class); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($medium)); + $manager->expects($this->once())->method('findOneBy')->willReturn($medium); $provider = $this->createMock(MediaProviderInterface::class); $provider->expects($this->once())->method('getName'); $pool = $this->createMock(Pool::class); - $pool->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); + $pool->expects($this->once())->method('getProvider')->willReturn($provider); $form = $this->createMock(Form::class); $form->expects($this->once())->method('handleRequest'); - $form->expects($this->once())->method('isValid')->will($this->returnValue(false)); + $form->expects($this->once())->method('isValid')->willReturn(false); $factory = $this->createMock(FormFactoryInterface::class); - $factory->expects($this->once())->method('createNamed')->will($this->returnValue($form)); + $factory->expects($this->once())->method('createNamed')->willReturn($form); $controller = $this->createMediaController($manager, $pool, $factory); @@ -191,21 +191,21 @@ public function testPostProviderMediumAction(): void $medium->expects($this->once())->method('setProviderName'); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('create')->will($this->returnValue($medium)); + $manager->expects($this->once())->method('create')->willReturn($medium); $provider = $this->createMock(MediaProviderInterface::class); $provider->expects($this->once())->method('getName'); $pool = $this->createMock(Pool::class); - $pool->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); + $pool->expects($this->once())->method('getProvider')->willReturn($provider); $form = $this->createMock(Form::class); $form->expects($this->once())->method('handleRequest'); - $form->expects($this->once())->method('isValid')->will($this->returnValue(true)); - $form->expects($this->once())->method('getData')->will($this->returnValue($medium)); + $form->expects($this->once())->method('isValid')->willReturn(true); + $form->expects($this->once())->method('getData')->willReturn($medium); $factory = $this->createMock(FormFactoryInterface::class); - $factory->expects($this->once())->method('createNamed')->will($this->returnValue($form)); + $factory->expects($this->once())->method('createNamed')->willReturn($form); $controller = $this->createMediaController($manager, $pool, $factory); @@ -220,7 +220,7 @@ public function testPostProviderActionNotFound(): void $medium->expects($this->once())->method('setProviderName'); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('create')->will($this->returnValue($medium)); + $manager->expects($this->once())->method('create')->willReturn($medium); $pool = $this->createMock(Pool::class); $pool->expects($this->once())->method('getProvider')->will($this->throwException(new \RuntimeException('exception on getProvder'))); @@ -235,7 +235,7 @@ public function testPutMediumBinaryContentAction(): void $media->expects($this->once())->method('setBinaryContent'); $manager = $this->createMock(MediaManagerInterface::class); - $manager->expects($this->once())->method('findOneBy')->will($this->returnValue($media)); + $manager->expects($this->once())->method('findOneBy')->willReturn($media); $pool = $this->createMock(Pool::class); diff --git a/tests/Document/MediaManagerTest.php b/tests/Document/MediaManagerTest.php index 6f46f2626f..abf5a31f04 100644 --- a/tests/Document/MediaManagerTest.php +++ b/tests/Document/MediaManagerTest.php @@ -77,7 +77,7 @@ protected function createRegistryMock() $dm->expects($this->any())->method('persist'); $dm->expects($this->any())->method('flush'); - $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($dm)); + $registry->expects($this->any())->method('getManagerForClass')->willReturn($dm); return $registry; } diff --git a/tests/Entity/GalleryManagerTest.php b/tests/Entity/GalleryManagerTest.php index dbca9703bb..97ba97f880 100644 --- a/tests/Entity/GalleryManagerTest.php +++ b/tests/Entity/GalleryManagerTest.php @@ -28,7 +28,7 @@ public function testGetPager(): void { $this ->getGalleryManager(function ($qb): void { - $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); + $qb->expects($this->once())->method('getRootAliases')->willReturn(['g']); $qb->expects($this->never())->method('andWhere'); $qb->expects($this->once())->method('orderBy')->with( $this->equalTo('g.name'), @@ -54,7 +54,7 @@ public function testGetPagerWithMultipleSort(): void { $this ->getGalleryManager(function ($qb): void { - $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); + $qb->expects($this->once())->method('getRootAliases')->willReturn(['g']); $qb->expects($this->never())->method('andWhere'); $qb->expects($this->exactly(2))->method('orderBy')->with( $this->logicalOr( @@ -78,7 +78,7 @@ public function testGetPagerWithEnabledGalleries(): void { $this ->getGalleryManager(function ($qb): void { - $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); + $qb->expects($this->once())->method('getRootAliases')->willReturn(['g']); $qb->expects($this->once())->method('andWhere')->with($this->equalTo('g.enabled = :enabled')); $qb->expects($this->once())->method('setParameters')->with($this->equalTo(['enabled' => true])); }) @@ -89,7 +89,7 @@ public function testGetPagerWithNoEnabledGalleries(): void { $this ->getGalleryManager(function ($qb): void { - $qb->expects($this->once())->method('getRootAliases')->will($this->returnValue(['g'])); + $qb->expects($this->once())->method('getRootAliases')->willReturn(['g']); $qb->expects($this->once())->method('andWhere')->with($this->equalTo('g.enabled = :enabled')); $qb->expects($this->once())->method('setParameters')->with($this->equalTo(['enabled' => false])); }) @@ -105,7 +105,7 @@ protected function getGalleryManager($qbCallback) ]); $registry = $this->createMock(ManagerRegistry::class); - $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($em)); + $registry->expects($this->any())->method('getManagerForClass')->willReturn($em); return new GalleryManager(BaseGallery::class, $registry); } diff --git a/tests/Entity/MediaManagerTest.php b/tests/Entity/MediaManagerTest.php index d185153f21..7dc451fcdd 100644 --- a/tests/Entity/MediaManagerTest.php +++ b/tests/Entity/MediaManagerTest.php @@ -106,7 +106,7 @@ protected function getMediaManager($qbCallback) ]); $registry = $this->createMock(ManagerRegistry::class); - $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($em)); + $registry->expects($this->any())->method('getManagerForClass')->willReturn($em); return new MediaManager(BaseMedia::class, $registry); } diff --git a/tests/Filesystem/ReplicateTest.php b/tests/Filesystem/ReplicateTest.php index 709d36df60..f1d7b95281 100644 --- a/tests/Filesystem/ReplicateTest.php +++ b/tests/Filesystem/ReplicateTest.php @@ -25,27 +25,27 @@ public function testReplicate(): void $slave = $this->createMock(Adapter::class); $replicate = new Replicate($master, $slave); - $master->expects($this->once())->method('mtime')->will($this->returnValue('master')); + $master->expects($this->once())->method('mtime')->willReturn('master'); $slave->expects($this->never())->method('mtime'); $this->assertSame('master', $replicate->mtime('foo')); - $master->expects($this->once())->method('delete')->will($this->returnValue('master')); - $slave->expects($this->once())->method('delete')->will($this->returnValue('master')); + $master->expects($this->once())->method('delete')->willReturn('master'); + $slave->expects($this->once())->method('delete')->willReturn('master'); $replicate->delete('foo'); - $master->expects($this->once())->method('keys')->will($this->returnValue([])); - $slave->expects($this->never())->method('keys')->will($this->returnValue([])); + $master->expects($this->once())->method('keys')->willReturn([]); + $slave->expects($this->never())->method('keys')->willReturn([]); $this->assertInternalType('array', $replicate->keys()); - $master->expects($this->once())->method('exists')->will($this->returnValue(true)); + $master->expects($this->once())->method('exists')->willReturn(true); $slave->expects($this->never())->method('exists'); $this->assertTrue($replicate->exists('foo')); - $master->expects($this->once())->method('write')->will($this->returnValue(123)); - $slave->expects($this->once())->method('write')->will($this->returnValue(123)); + $master->expects($this->once())->method('write')->willReturn(123); + $slave->expects($this->once())->method('write')->willReturn(123); $this->assertTrue($replicate->write('foo', 'contents')); - $master->expects($this->once())->method('read')->will($this->returnValue('master content')); + $master->expects($this->once())->method('read')->willReturn('master content'); $slave->expects($this->never())->method('read'); $this->assertSame('master content', $replicate->read('foo')); diff --git a/tests/Form/DataTransformer/ProviderDataTransformerTest.php b/tests/Form/DataTransformer/ProviderDataTransformerTest.php index 1af565d13f..b413c18fd9 100644 --- a/tests/Form/DataTransformer/ProviderDataTransformerTest.php +++ b/tests/Form/DataTransformer/ProviderDataTransformerTest.php @@ -38,9 +38,9 @@ public function testReverseTransformUnknownProvider(): void $pool = new Pool('default'); $media = $this->createMock(MediaInterface::class); - $media->expects($this->exactly(3))->method('getProviderName')->will($this->returnValue('unknown')); - $media->expects($this->any())->method('getId')->will($this->returnValue(1)); - $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue('xcs')); + $media->expects($this->exactly(3))->method('getProviderName')->willReturn('unknown'); + $media->expects($this->any())->method('getId')->willReturn(1); + $media->expects($this->any())->method('getBinaryContent')->willReturn('xcs'); $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, @@ -57,9 +57,9 @@ public function testReverseTransformValidProvider(): void $pool->addProvider('default', $provider); $media = $this->createMock(MediaInterface::class); - $media->expects($this->exactly(3))->method('getProviderName')->will($this->returnValue('default')); - $media->expects($this->any())->method('getId')->will($this->returnValue(1)); - $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue('xcs')); + $media->expects($this->exactly(3))->method('getProviderName')->willReturn('default'); + $media->expects($this->any())->method('getId')->willReturn(1); + $media->expects($this->any())->method('getBinaryContent')->willReturn('xcs'); $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, @@ -75,9 +75,9 @@ public function testReverseTransformWithNewMediaAndNoBinaryContent(): void $pool->addProvider('default', $provider); $media = $this->createMock(MediaInterface::class); - $media->expects($this->any())->method('getId')->will($this->returnValue(null)); - $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(null)); - $media->expects($this->any())->method('getProviderName')->will($this->returnValue('default')); + $media->expects($this->any())->method('getId')->willReturn(null); + $media->expects($this->any())->method('getBinaryContent')->willReturn(null); + $media->expects($this->any())->method('getProviderName')->willReturn('default'); $media->expects($this->once())->method('setProviderReference')->with(MediaInterface::MISSING_BINARY_REFERENCE); $media->expects($this->once())->method('setProviderStatus')->with(MediaInterface::STATUS_PENDING); @@ -96,8 +96,8 @@ public function testReverseTransformWithMediaAndNoBinaryContent(): void $pool->addProvider('default', $provider); $media = $this->createMock(MediaInterface::class); - $media->expects($this->any())->method('getId')->will($this->returnValue(1)); - $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(null)); + $media->expects($this->any())->method('getId')->willReturn(1); + $media->expects($this->any())->method('getBinaryContent')->willReturn(null); $transformer = new ProviderDataTransformer($pool, 'stdClass'); $this->assertSame($media, $transformer->reverseTransform($media)); @@ -114,9 +114,9 @@ public function testReverseTransformWithMediaAndUploadFileInstance(): void $pool->addProvider('default', $provider); $media = $this->createMock(MediaInterface::class); - $media->expects($this->any())->method('getProviderName')->will($this->returnValue('default')); - $media->expects($this->any())->method('getId')->will($this->returnValue(1)); - $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); + $media->expects($this->any())->method('getProviderName')->willReturn('default'); + $media->expects($this->any())->method('getId')->willReturn(1); + $media->expects($this->any())->method('getBinaryContent')->willReturn(new UploadedFile(__FILE__, 'ProviderDataTransformerTest')); $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, @@ -133,9 +133,9 @@ public function testReverseTransformWithThrowingProviderNoThrow(): void $pool->addProvider('default', $provider); $media = $this->createMock(MediaInterface::class); - $media->expects($this->exactly(3))->method('getProviderName')->will($this->returnValue('default')); - $media->expects($this->any())->method('getId')->will($this->returnValue(1)); - $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); + $media->expects($this->exactly(3))->method('getProviderName')->willReturn('default'); + $media->expects($this->any())->method('getId')->willReturn(1); + $media->expects($this->any())->method('getBinaryContent')->willReturn(new UploadedFile(__FILE__, 'ProviderDataTransformerTest')); $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, @@ -155,9 +155,9 @@ public function testReverseTransformWithThrowingProviderLogsException(): void $logger->expects($this->once())->method('error'); $media = $this->createMock(MediaInterface::class); - $media->expects($this->exactly(3))->method('getProviderName')->will($this->returnValue('default')); - $media->expects($this->any())->method('getId')->will($this->returnValue(1)); - $media->expects($this->any())->method('getBinaryContent')->will($this->returnValue(new UploadedFile(__FILE__, 'ProviderDataTransformerTest'))); + $media->expects($this->exactly(3))->method('getProviderName')->willReturn('default'); + $media->expects($this->any())->method('getId')->willReturn(1); + $media->expects($this->any())->method('getBinaryContent')->willReturn(new UploadedFile(__FILE__, 'ProviderDataTransformerTest')); $transformer = new ProviderDataTransformer($pool, 'stdClass', [ 'new_on_update' => false, diff --git a/tests/Form/Type/AbstractTypeTest.php b/tests/Form/Type/AbstractTypeTest.php index d9d3e7e44f..71713d12e7 100644 --- a/tests/Form/Type/AbstractTypeTest.php +++ b/tests/Form/Type/AbstractTypeTest.php @@ -52,11 +52,11 @@ protected function setUp(): void $this->formBuilder ->expects($this->any()) ->method('add') - ->will($this->returnCallback(function ($name, $type = null): void { + ->willReturnCallback(function ($name, $type = null): void { if (null !== $type) { $this->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } - })); + }); $this->formType = $this->getTestedInstance(); } diff --git a/tests/Form/Type/ApiMediaTypeTest.php b/tests/Form/Type/ApiMediaTypeTest.php index e695654d2d..73462d1b65 100644 --- a/tests/Form/Type/ApiMediaTypeTest.php +++ b/tests/Form/Type/ApiMediaTypeTest.php @@ -29,7 +29,7 @@ public function testBuildForm(): void $provider = $this->createMock(MediaProviderInterface::class); $mediaPool = $this->createMock(Pool::class); - $mediaPool->expects($this->once())->method('getProvider')->will($this->returnValue($provider)); + $mediaPool->expects($this->once())->method('getProvider')->willReturn($provider); $type = new ApiMediaType($mediaPool, 'testclass'); diff --git a/tests/Form/Type/MediaTypeTest.php b/tests/Form/Type/MediaTypeTest.php index 9ed05ab34d..346cdb387d 100644 --- a/tests/Form/Type/MediaTypeTest.php +++ b/tests/Form/Type/MediaTypeTest.php @@ -47,14 +47,14 @@ protected function setUp(): void public function testMissingFormOptions(): void { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ + $this->mediaPool->expects($this->any())->method('getProviderList')->willReturn([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ])); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + ]); + $this->mediaPool->expects($this->any())->method('getContexts')->willReturn([ 'video' => [], 'pic' => [], - ])); + ]); $this->expectException(MissingOptionsException::class); $this->expectExceptionMessage( @@ -66,14 +66,14 @@ public function testMissingFormOptions(): void public function testMissingFormContextOption(): void { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ + $this->mediaPool->expects($this->any())->method('getProviderList')->willReturn([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ])); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + ]); + $this->mediaPool->expects($this->any())->method('getContexts')->willReturn([ 'video' => [], 'pic' => [], - ])); + ]); $this->expectException(MissingOptionsException::class); @@ -84,14 +84,14 @@ public function testMissingFormContextOption(): void public function testMissingFormProviderOption(): void { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ + $this->mediaPool->expects($this->any())->method('getProviderList')->willReturn([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ])); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + ]); + $this->mediaPool->expects($this->any())->method('getContexts')->willReturn([ 'video' => [], 'pic' => [], - ])); + ]); $this->expectException(MissingOptionsException::class); @@ -102,14 +102,14 @@ public function testMissingFormProviderOption(): void public function testInvalidFormProviderOption(): void { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ + $this->mediaPool->expects($this->any())->method('getProviderList')->willReturn([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ])); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + ]); + $this->mediaPool->expects($this->any())->method('getContexts')->willReturn([ 'video' => [], 'pic' => [], - ])); + ]); $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage( @@ -124,14 +124,14 @@ public function testInvalidFormProviderOption(): void public function testInvalidFormContextOption(): void { - $this->mediaPool->expects($this->any())->method('getProviderList')->will($this->returnValue([ + $this->mediaPool->expects($this->any())->method('getProviderList')->willReturn([ 'provider_a' => 'provider_a', 'provider_b' => 'provider_b', - ])); - $this->mediaPool->expects($this->any())->method('getContexts')->will($this->returnValue([ + ]); + $this->mediaPool->expects($this->any())->method('getContexts')->willReturn([ 'video' => [], 'pic' => [], - ])); + ]); $this->expectException(InvalidOptionsException::class); $this->expectExceptionMessage( diff --git a/tests/Listener/ORM/MediaEventSubscriberTest.php b/tests/Listener/ORM/MediaEventSubscriberTest.php index 5d6949c11c..3ae74dcc39 100644 --- a/tests/Listener/ORM/MediaEventSubscriberTest.php +++ b/tests/Listener/ORM/MediaEventSubscriberTest.php @@ -42,20 +42,20 @@ public function testRefetchCategoriesAfterClear(): void ->setConstructorArgs(['default']) ->getMock(); - $pool->method('getProvider')->will($this->returnValueMap([['provider', $provider]])); + $pool->method('getProvider')->willReturnMap([['provider', $provider]]); $category = $this->createMock(CategoryInterface::class); $catManager = $this->createMock(CategoryManagerInterface::class); $container = $this->createMock(ContainerInterface::class); - $container->method('get')->will($this->returnValueMap([ + $container->method('get')->willReturnMap([ ['sonata.media.pool', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $pool], ['sonata.media.manager.category', ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $catManager], - ])); + ]); $container->method('has') ->with($this->equalTo('sonata.media.manager.category')) - ->will($this->returnValue(true)); + ->willReturn(true); $catManager->expects($this->exactly(2)) ->method('getRootCategories') diff --git a/tests/Metadata/ProxyMetadataBuilderTest.php b/tests/Metadata/ProxyMetadataBuilderTest.php index e1146d37df..fb477a1cab 100644 --- a/tests/Metadata/ProxyMetadataBuilderTest.php +++ b/tests/Metadata/ProxyMetadataBuilderTest.php @@ -33,12 +33,12 @@ public function testProxyAmazon(): void $amazon = $this->createMock(AmazonMetadataBuilder::class); $amazon->expects($this->once()) ->method('get') - ->will($this->returnValue(['key' => 'amazon'])); + ->willReturn(['key' => 'amazon']); $noop = $this->createMock(NoopMetadataBuilder::class); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(['key' => 'noop'])); + ->willReturn(['key' => 'noop']); //adapter cannot be mocked $amazonclient = S3Client::factory([ @@ -51,15 +51,15 @@ public function testProxyAmazon(): void $adapter = new AwsS3($amazonclient, ''); $filesystem = $this->createMock(Filesystem::class); - $filesystem->expects($this->any())->method('getAdapter')->will($this->returnValue($adapter)); + $filesystem->expects($this->any())->method('getAdapter')->willReturn($adapter); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->any())->method('getFilesystem')->will($this->returnValue($filesystem)); + $provider->expects($this->any())->method('getFilesystem')->willReturn($filesystem); $media = $this->createMock(MediaInterface::class); $media->expects($this->any()) ->method('getProviderName') - ->will($this->returnValue('sonata.media.provider.image')); + ->willReturn('sonata.media.provider.image'); $filename = '/test/folder/testfile.png'; @@ -79,26 +79,26 @@ public function testProxyLocal(): void $amazon = $this->createMock(AmazonMetadataBuilder::class); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(['key' => 'amazon'])); + ->willReturn(['key' => 'amazon']); $noop = $this->createMock(NoopMetadataBuilder::class); $noop->expects($this->once()) ->method('get') - ->will($this->returnValue(['key' => 'noop'])); + ->willReturn(['key' => 'noop']); //adapter cannot be mocked $adapter = new Local(''); $filesystem = $this->createMock(Filesystem::class); - $filesystem->expects($this->any())->method('getAdapter')->will($this->returnValue($adapter)); + $filesystem->expects($this->any())->method('getAdapter')->willReturn($adapter); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->any())->method('getFilesystem')->will($this->returnValue($filesystem)); + $provider->expects($this->any())->method('getFilesystem')->willReturn($filesystem); $media = $this->createMock(MediaInterface::class); $media->expects($this->any()) ->method('getProviderName') - ->will($this->returnValue('sonata.media.provider.image')); + ->willReturn('sonata.media.provider.image'); $filename = '/test/folder/testfile.png'; @@ -118,26 +118,26 @@ public function testProxyNoProvider(): void $amazon = $this->createMock(AmazonMetadataBuilder::class); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(['key' => 'amazon'])); + ->willReturn(['key' => 'amazon']); $noop = $this->createMock(NoopMetadataBuilder::class); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(['key' => 'noop'])); + ->willReturn(['key' => 'noop']); //adapter cannot be mocked $adapter = new Local(''); $filesystem = $this->createMock(Filesystem::class); - $filesystem->expects($this->any())->method('getAdapter')->will($this->returnValue($adapter)); + $filesystem->expects($this->any())->method('getAdapter')->willReturn($adapter); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->any())->method('getFilesystem')->will($this->returnValue($filesystem)); + $provider->expects($this->any())->method('getFilesystem')->willReturn($filesystem); $media = $this->createMock(MediaInterface::class); $media->expects($this->any()) ->method('getProviderName') - ->will($this->returnValue('wrongprovider')); + ->willReturn('wrongprovider'); $filename = '/test/folder/testfile.png'; @@ -157,12 +157,12 @@ public function testProxyReplicateWithAmazon(): void $amazon = $this->createMock(AmazonMetadataBuilder::class); $amazon->expects($this->once()) ->method('get') - ->will($this->returnValue(['key' => 'amazon'])); + ->willReturn(['key' => 'amazon']); $noop = $this->createMock(NoopMetadataBuilder::class); $noop->expects($this->never()) ->method('get') - ->will($this->returnValue(['key' => 'noop'])); + ->willReturn(['key' => 'noop']); //adapter cannot be mocked $amazonclient = S3Client::factory([ @@ -177,15 +177,15 @@ public function testProxyReplicateWithAmazon(): void $adapter = new Replicate($adapter1, $adapter2); $filesystem = $this->createMock(Filesystem::class); - $filesystem->expects($this->any())->method('getAdapter')->will($this->returnValue($adapter)); + $filesystem->expects($this->any())->method('getAdapter')->willReturn($adapter); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->any())->method('getFilesystem')->will($this->returnValue($filesystem)); + $provider->expects($this->any())->method('getFilesystem')->willReturn($filesystem); $media = $this->createMock(MediaInterface::class); $media->expects($this->any()) ->method('getProviderName') - ->will($this->returnValue('sonata.media.provider.image')); + ->willReturn('sonata.media.provider.image'); $filename = '/test/folder/testfile.png'; @@ -205,12 +205,12 @@ public function testProxyReplicateWithoutAmazon(): void $amazon = $this->createMock(AmazonMetadataBuilder::class); $amazon->expects($this->never()) ->method('get') - ->will($this->returnValue(['key' => 'amazon'])); + ->willReturn(['key' => 'amazon']); $noop = $this->createMock(NoopMetadataBuilder::class); $noop->expects($this->once()) ->method('get') - ->will($this->returnValue(['key' => 'noop'])); + ->willReturn(['key' => 'noop']); //adapter cannot be mocked $adapter1 = new Local(''); @@ -218,15 +218,15 @@ public function testProxyReplicateWithoutAmazon(): void $adapter = new Replicate($adapter1, $adapter2); $filesystem = $this->createMock(Filesystem::class); - $filesystem->expects($this->any())->method('getAdapter')->will($this->returnValue($adapter)); + $filesystem->expects($this->any())->method('getAdapter')->willReturn($adapter); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->any())->method('getFilesystem')->will($this->returnValue($filesystem)); + $provider->expects($this->any())->method('getFilesystem')->willReturn($filesystem); $media = $this->createMock(MediaInterface::class); $media->expects($this->any()) ->method('getProviderName') - ->will($this->returnValue('sonata.media.provider.image')); + ->willReturn('sonata.media.provider.image'); $filename = '/test/folder/testfile.png'; @@ -254,20 +254,20 @@ protected function getContainerMock(array $services) $container ->expects($this->any()) ->method('get') - ->will($this->returnCallback(static function ($service) use ($services) { + ->willReturnCallback(static function ($service) use ($services) { return $services[$service]; - })) + }) ; $container ->expects($this->any()) ->method('has') - ->will($this->returnCallback(static function ($service) use ($services) { + ->willReturnCallback(static function ($service) use ($services) { if (isset($services[$service])) { return true; } return false; - })) + }) ; return $container; diff --git a/tests/Model/MediaTest.php b/tests/Model/MediaTest.php index d4480fe3d1..8d82b4ab69 100644 --- a/tests/Model/MediaTest.php +++ b/tests/Model/MediaTest.php @@ -79,7 +79,7 @@ protected function getMedia($id) $media = $this->getMockForAbstractClass(Media::class); $media->expects($this->any()) ->method('getId') - ->will($this->returnValue($id)); + ->willReturn($id); return $media; } diff --git a/tests/PHPCR/MediaManagerTest.php b/tests/PHPCR/MediaManagerTest.php index 4fef42671c..7a0cf26b5f 100644 --- a/tests/PHPCR/MediaManagerTest.php +++ b/tests/PHPCR/MediaManagerTest.php @@ -77,7 +77,7 @@ protected function createRegistryMock() $dm->expects($this->any())->method('persist'); $dm->expects($this->any())->method('flush'); - $registry->expects($this->any())->method('getManagerForClass')->will($this->returnValue($dm)); + $registry->expects($this->any())->method('getManagerForClass')->willReturn($dm); return $registry; } diff --git a/tests/Provider/AbstractProviderTest.php b/tests/Provider/AbstractProviderTest.php index 69c22b5b7a..17011834a0 100644 --- a/tests/Provider/AbstractProviderTest.php +++ b/tests/Provider/AbstractProviderTest.php @@ -50,21 +50,21 @@ protected function setUp(): void $this->formMapper ->expects($this->any()) ->method('add') - ->will($this->returnCallback(function ($name, $type = null): void { + ->willReturnCallback(function ($name, $type = null): void { if (null !== $type) { $this->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } - })); + }); $this->formBuilder = $this->createMock(FormBuilder::class); $this->formBuilder ->expects($this->any()) ->method('add') - ->will($this->returnCallback(function ($name, $type = null): void { + ->willReturnCallback(function ($name, $type = null): void { if (null !== $type) { $this->assertTrue(class_exists($type), sprintf('Unable to ensure %s is a FQCN', $type)); } - })); + }); $this->formBuilder->expects($this->any())->method('getOption')->willReturn('api'); diff --git a/tests/Provider/DailyMotionProviderTest.php b/tests/Provider/DailyMotionProviderTest.php index bad668eb90..7b8d264185 100644 --- a/tests/Provider/DailyMotionProviderTest.php +++ b/tests/Provider/DailyMotionProviderTest.php @@ -39,8 +39,8 @@ public function getProvider(Browser $browser = null) } $resizer = $this->createMock(ResizerInterface::class); - $resizer->expects($this->any())->method('resize')->will($this->returnValue(true)); - $resizer->expects($this->any())->method('getBox')->will($this->returnValue(new Box(100, 100))); + $resizer->expects($this->any())->method('resize')->willReturn(true); + $resizer->expects($this->any())->method('getBox')->willReturn(new Box(100, 100)); $adapter = $this->createMock(Adapter::class); @@ -51,7 +51,7 @@ public function getProvider(Browser $browser = null) $file = $this->getMockBuilder(File::class) ->setConstructorArgs(['foo', $filesystem]) ->getMock(); - $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); + $filesystem->expects($this->any())->method('get')->willReturn($file); $cdn = new Server('/uploads/media'); @@ -89,11 +89,11 @@ public function testProvider(): void public function testThumbnail(): void { $response = $this->createMock(AbstractMessage::class); - $response->expects($this->once())->method('getContent')->will($this->returnValue('content')); + $response->expects($this->once())->method('getContent')->willReturn('content'); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -123,7 +123,7 @@ public function testTransformWithSig(): void $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_dailymotion.txt')); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -150,7 +150,7 @@ public function testTransformWithUrl(string $url): void $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_dailymotion.txt')); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -186,7 +186,7 @@ public function testForm(): void $admin = $this->createMock(AdminInterface::class); $admin->expects($this->any()) ->method('trans') - ->will($this->returnValue('message')); + ->willReturn('message'); $formMapper = $this->getMockBuilder(FormMapper::class) ->setMethods(['add', 'getAdmin']) @@ -194,7 +194,7 @@ public function testForm(): void ->getMock(); $formMapper->expects($this->exactly(8)) ->method('add') - ->will($this->returnValue(null)); + ->willReturn(null); $provider->buildCreateForm($formMapper); diff --git a/tests/Provider/FileProviderTest.php b/tests/Provider/FileProviderTest.php index 797a7560bf..26cb6b2f07 100644 --- a/tests/Provider/FileProviderTest.php +++ b/tests/Provider/FileProviderTest.php @@ -37,10 +37,10 @@ class FileProviderTest extends AbstractProviderTest public function getProvider() { $resizer = $this->createMock(ResizerInterface::class); - $resizer->expects($this->any())->method('resize')->will($this->returnValue(true)); + $resizer->expects($this->any())->method('resize')->willReturn(true); $adapter = $this->createMock(Local::class); - $adapter->expects($this->any())->method('getDirectory')->will($this->returnValue(realpath(__DIR__).'/../fixtures')); + $adapter->expects($this->any())->method('getDirectory')->willReturn(realpath(__DIR__).'/../fixtures'); $filesystem = $this->getMockBuilder(Filesystem::class) ->setMethods(['get']) @@ -49,7 +49,7 @@ public function getProvider() $file = $this->getMockBuilder(GaufretteFile::class) ->setConstructorArgs(['foo', $filesystem]) ->getMock(); - $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); + $filesystem->expects($this->any())->method('get')->willReturn($file); $cdn = new Server('/uploads/media'); @@ -107,7 +107,7 @@ public function testForm(): void $admin = $this->createMock(AdminInterface::class); $admin->expects($this->any()) ->method('trans') - ->will($this->returnValue('message')); + ->willReturn('message'); $formMapper = $this->getMockBuilder(FormMapper::class) ->setMethods(['add', 'getAdmin']) @@ -115,7 +115,7 @@ public function testForm(): void ->getMock(); $formMapper->expects($this->exactly(8)) ->method('add') - ->will($this->returnValue(null)); + ->willReturn(null); $provider->buildCreateForm($formMapper); $provider->buildEditForm($formMapper); @@ -340,24 +340,24 @@ public function testValidateUploadSize(): void ->disableOriginalConstructor() ->getMock(); $errorElement->expects($this->once())->method('with') - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->once())->method('addViolation') ->with($this->stringContains('The file is too big, max size:')) - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->once())->method('end') - ->will($this->returnSelf()); + ->willReturnSelf(); $upload = $this->getMockBuilder(UploadedFile::class) ->setConstructorArgs([tempnam(sys_get_temp_dir(), ''), 'dummy']) ->getMock(); $upload->expects($this->any())->method('getClientSize') - ->will($this->returnValue(0)); + ->willReturn(0); $upload->expects($this->any())->method('getFilename') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getClientOriginalName') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getMimeType') - ->will($this->returnValue('foo/bar')); + ->willReturn('foo/bar'); $media = new Media(); $media->setBinaryContent($upload); @@ -370,24 +370,24 @@ public function testValidateUploadNullSize(): void { $errorElement = $this->createMock(ErrorElement::class); $errorElement->expects($this->once())->method('with') - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->once())->method('addViolation') ->with($this->stringContains('The file is too big, max size:')) - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->once())->method('end') - ->will($this->returnSelf()); + ->willReturnSelf(); $upload = $this->getMockBuilder(UploadedFile::class) ->setConstructorArgs([tempnam(sys_get_temp_dir(), ''), 'dummy']) ->getMock(); $upload->expects($this->any())->method('getClientSize') - ->will($this->returnValue(null)); + ->willReturn(null); $upload->expects($this->any())->method('getFilename') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getClientOriginalName') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getMimeType') - ->will($this->returnValue('foo/bar')); + ->willReturn('foo/bar'); $media = new Media(); $media->setBinaryContent($upload); @@ -400,24 +400,24 @@ public function testValidateUploadSizeOK(): void { $errorElement = $this->createMock(ErrorElement::class); $errorElement->expects($this->never())->method('with') - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->never())->method('addViolation') ->with($this->stringContains('The file is too big, max size:')) - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->never())->method('end') - ->will($this->returnSelf()); + ->willReturnSelf(); $upload = $this->getMockBuilder(UploadedFile::class) ->setConstructorArgs([tempnam(sys_get_temp_dir(), ''), 'dummy']) ->getMock(); $upload->expects($this->any())->method('getClientSize') - ->will($this->returnValue(1)); + ->willReturn(1); $upload->expects($this->any())->method('getFilename') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getClientOriginalName') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getMimeType') - ->will($this->returnValue('foo/bar')); + ->willReturn('foo/bar'); $media = new Media(); $media->setBinaryContent($upload); @@ -432,24 +432,24 @@ public function testValidateUploadType(): void ->disableOriginalConstructor() ->getMock(); $errorElement->expects($this->once())->method('with') - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->once())->method('addViolation') ->with('Invalid mime type : %type%', ['%type%' => 'bar/baz']) - ->will($this->returnSelf()); + ->willReturnSelf(); $errorElement->expects($this->once())->method('end') - ->will($this->returnSelf()); + ->willReturnSelf(); $upload = $this->getMockBuilder(UploadedFile::class) ->setConstructorArgs([tempnam(sys_get_temp_dir(), ''), 'dummy']) ->getMock(); $upload->expects($this->any())->method('getClientSize') - ->will($this->returnValue(23)); + ->willReturn(23); $upload->expects($this->any())->method('getFilename') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getClientOriginalName') - ->will($this->returnValue('test.txt')); + ->willReturn('test.txt'); $upload->expects($this->any())->method('getMimeType') - ->will($this->returnValue('bar/baz')); + ->willReturn('bar/baz'); $media = new Media(); $media->setBinaryContent($upload); diff --git a/tests/Provider/ImageProviderTest.php b/tests/Provider/ImageProviderTest.php index e6fe6c57fb..9548efb07b 100644 --- a/tests/Provider/ImageProviderTest.php +++ b/tests/Provider/ImageProviderTest.php @@ -33,7 +33,7 @@ class ImageProviderTest extends AbstractProviderTest public function getProvider($allowedExtensions = [], $allowedMimeTypes = [], $box = false) { $resizer = $this->createMock(ResizerInterface::class); - $resizer->expects($this->any())->method('resize')->will($this->returnValue(true)); + $resizer->expects($this->any())->method('resize')->willReturn(true); if ($box) { $resizer->expects($this->any())->method('getBox')->will($box); } @@ -47,7 +47,7 @@ public function getProvider($allowedExtensions = [], $allowedMimeTypes = [], $bo $file = $this->getMockBuilder(File::class) ->setConstructorArgs(['foo', $filesystem]) ->getMock(); - $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); + $filesystem->expects($this->any())->method('get')->willReturn($file); $cdn = new Server('/uploads/media'); @@ -56,14 +56,14 @@ public function getProvider($allowedExtensions = [], $allowedMimeTypes = [], $bo $thumbnail = new FormatThumbnail('jpg'); $size = $this->createMock(BoxInterface::class); - $size->expects($this->any())->method('getWidth')->will($this->returnValue(100)); - $size->expects($this->any())->method('getHeight')->will($this->returnValue(100)); + $size->expects($this->any())->method('getWidth')->willReturn(100); + $size->expects($this->any())->method('getHeight')->willReturn(100); $image = $this->createMock(ImageInterface::class); - $image->expects($this->any())->method('getSize')->will($this->returnValue($size)); + $image->expects($this->any())->method('getSize')->willReturn($size); $adapter = $this->createMock(ImagineInterface::class); - $adapter->expects($this->any())->method('open')->will($this->returnValue($image)); + $adapter->expects($this->any())->method('open')->willReturn($image); $metadata = $this->createMock(MetadataBuilderInterface::class); diff --git a/tests/Provider/VimeoProviderTest.php b/tests/Provider/VimeoProviderTest.php index 787d11b334..cb6c925751 100644 --- a/tests/Provider/VimeoProviderTest.php +++ b/tests/Provider/VimeoProviderTest.php @@ -39,8 +39,8 @@ public function getProvider(Browser $browser = null) } $resizer = $this->createMock(ResizerInterface::class); - $resizer->expects($this->any())->method('resize')->will($this->returnValue(true)); - $resizer->expects($this->any())->method('getBox')->will($this->returnValue(new Box(100, 100))); + $resizer->expects($this->any())->method('resize')->willReturn(true); + $resizer->expects($this->any())->method('getBox')->willReturn(new Box(100, 100)); $adapter = $this->createMock(Adapter::class); @@ -51,7 +51,7 @@ public function getProvider(Browser $browser = null) $file = $this->getMockBuilder(File::class) ->setConstructorArgs(['foo', $filesystem]) ->getMock(); - $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); + $filesystem->expects($this->any())->method('get')->willReturn($file); $cdn = new Server('/uploads/media'); @@ -88,11 +88,11 @@ public function testProvider(): void public function testThumbnail(): void { $response = $this->createMock(AbstractMessage::class); - $response->expects($this->once())->method('getContent')->will($this->returnValue('content')); + $response->expects($this->once())->method('getContent')->willReturn('content'); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -122,7 +122,7 @@ public function testTransformWithSig(): void $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_vimeo.txt')); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -150,7 +150,7 @@ public function testTransformWithUrl($media): void $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_vimeo.txt')); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -189,7 +189,7 @@ public function testForm(): void $admin = $this->createMock(AdminInterface::class); $admin->expects($this->any()) ->method('trans') - ->will($this->returnValue('message')); + ->willReturn('message'); $formMapper = $this->getMockBuilder(FormMapper::class) ->setMethods(['add', 'getAdmin']) @@ -197,7 +197,7 @@ public function testForm(): void ->getMock(); $formMapper->expects($this->exactly(8)) ->method('add') - ->will($this->returnValue(null)); + ->willReturn(null); $provider->buildCreateForm($formMapper); diff --git a/tests/Provider/YouTubeProviderTest.php b/tests/Provider/YouTubeProviderTest.php index 8b657126f1..f0c151cfc6 100644 --- a/tests/Provider/YouTubeProviderTest.php +++ b/tests/Provider/YouTubeProviderTest.php @@ -39,8 +39,8 @@ public function getProvider(Browser $browser = null) } $resizer = $this->createMock(ResizerInterface::class); - $resizer->expects($this->any())->method('resize')->will($this->returnValue(true)); - $resizer->expects($this->any())->method('getBox')->will($this->returnValue(new Box(100, 100))); + $resizer->expects($this->any())->method('resize')->willReturn(true); + $resizer->expects($this->any())->method('getBox')->willReturn(new Box(100, 100)); $adapter = $this->createMock(Adapter::class); @@ -51,7 +51,7 @@ public function getProvider(Browser $browser = null) $file = $this->getMockBuilder(File::class) ->setConstructorArgs(['foo', $filesystem]) ->getMock(); - $filesystem->expects($this->any())->method('get')->will($this->returnValue($file)); + $filesystem->expects($this->any())->method('get')->willReturn($file); $cdn = new Server('/uploads/media'); @@ -89,11 +89,11 @@ public function testProvider(): void public function testThumbnail(): void { $response = $this->createMock(AbstractMessage::class); - $response->expects($this->once())->method('getContent')->will($this->returnValue('content')); + $response->expects($this->once())->method('getContent')->willReturn('content'); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -122,7 +122,7 @@ public function testTransformWithSig(): void $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_youtube.txt')); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -149,7 +149,7 @@ public function testTransformWithUrl($url): void $response->setContent(file_get_contents(__DIR__.'/../fixtures/valid_youtube.txt')); $browser = $this->createMock(Browser::class); - $browser->expects($this->once())->method('get')->will($this->returnValue($response)); + $browser->expects($this->once())->method('get')->willReturn($response); $provider = $this->getProvider($browser); @@ -191,7 +191,7 @@ public function testForm(): void $admin = $this->createMock(AdminInterface::class); $admin->expects($this->any()) ->method('trans') - ->will($this->returnValue('message')); + ->willReturn('message'); $formMapper = $this->getMockBuilder(FormMapper::class) ->setMethods(['add', 'getAdmin']) @@ -199,7 +199,7 @@ public function testForm(): void ->getMock(); $formMapper->expects($this->exactly(8)) ->method('add') - ->will($this->returnValue(null)); + ->willReturn(null); $provider->buildCreateForm($formMapper); diff --git a/tests/Resizer/SimpleResizerTest.php b/tests/Resizer/SimpleResizerTest.php index be8b76d655..03de90b856 100644 --- a/tests/Resizer/SimpleResizerTest.php +++ b/tests/Resizer/SimpleResizerTest.php @@ -42,14 +42,14 @@ public function testResizeWithNoWidth(): void public function testResize(): void { $image = $this->createMock(ImageInterface::class); - $image->expects($this->once())->method('thumbnail')->will($this->returnValue($image)); - $image->expects($this->once())->method('get')->will($this->returnValue(file_get_contents(__DIR__.'/../fixtures/logo.png'))); + $image->expects($this->once())->method('thumbnail')->willReturn($image); + $image->expects($this->once())->method('get')->willReturn(file_get_contents(__DIR__.'/../fixtures/logo.png')); $adapter = $this->createMock(ImagineInterface::class); - $adapter->expects($this->any())->method('load')->will($this->returnValue($image)); + $adapter->expects($this->any())->method('load')->willReturn($image); $media = $this->createMock(MediaInterface::class); - $media->expects($this->exactly(2))->method('getBox')->will($this->returnValue(new Box(535, 132))); + $media->expects($this->exactly(2))->method('getBox')->willReturn(new Box(535, 132)); $filesystem = new Filesystem(new InMemory()); $in = $filesystem->get('in', true); @@ -58,7 +58,7 @@ public function testResize(): void $out = $filesystem->get('out', true); $metadata = $this->createMock(MetadataBuilderInterface::class); - $metadata->expects($this->once())->method('get')->will($this->returnValue([])); + $metadata->expects($this->once())->method('get')->willReturn([]); $resizer = new SimpleResizer($adapter, 'outbound', $metadata); $resizer->resize($media, $in, $out, 'bar', ['height' => null, 'width' => 90, 'quality' => 100]); @@ -72,7 +72,7 @@ public function testGetBox($mode, $settings, Box $mediaSize, Box $result): void $adapter = $this->createMock(ImagineInterface::class); $media = $this->createMock(MediaInterface::class); - $media->expects($this->exactly(2))->method('getBox')->will($this->returnValue($mediaSize)); + $media->expects($this->exactly(2))->method('getBox')->willReturn($mediaSize); $metadata = $this->createMock(MetadataBuilderInterface::class); diff --git a/tests/Resizer/SquareResizerTest.php b/tests/Resizer/SquareResizerTest.php index 6e2c0b7a6c..eb8f058ce9 100644 --- a/tests/Resizer/SquareResizerTest.php +++ b/tests/Resizer/SquareResizerTest.php @@ -44,7 +44,7 @@ public function testGetBox($settings, Box $mediaSize, Box $expected): void $adapter = $this->createMock(ImagineInterface::class); $media = $this->createMock(MediaInterface::class); - $media->expects($this->once())->method('getBox')->will($this->returnValue($mediaSize)); + $media->expects($this->once())->method('getBox')->willReturn($mediaSize); $metadata = $this->createMock(MetadataBuilderInterface::class); diff --git a/tests/Security/RolesDownloadStrategyTest.php b/tests/Security/RolesDownloadStrategyTest.php index 355c4f4749..d9cffa0cea 100644 --- a/tests/Security/RolesDownloadStrategyTest.php +++ b/tests/Security/RolesDownloadStrategyTest.php @@ -31,9 +31,9 @@ public function testIsGrantedTrue(): void $security->expects($this->any()) ->method('isGranted') - ->will($this->returnCallback(static function (array $roles) { + ->willReturnCallback(static function (array $roles) { return \in_array('ROLE_ADMIN', $roles, true); - })); + }); $strategy = new RolesDownloadStrategy($translator, $security, ['ROLE_ADMIN']); $this->assertTrue($strategy->isGranted($media, $request)); @@ -48,9 +48,9 @@ public function testIsGrantedFalse(): void $security->expects($this->any()) ->method('isGranted') - ->will($this->returnCallback(static function (array $roles) { + ->willReturnCallback(static function (array $roles) { return \in_array('FOO', $roles, true); - })); + }); $strategy = new RolesDownloadStrategy($translator, $security, ['ROLE_ADMIN']); $this->assertFalse($strategy->isGranted($media, $request)); diff --git a/tests/Thumbnail/FormatThumbnailTest.php b/tests/Thumbnail/FormatThumbnailTest.php index 7268bafd6d..d203595608 100644 --- a/tests/Thumbnail/FormatThumbnailTest.php +++ b/tests/Thumbnail/FormatThumbnailTest.php @@ -38,19 +38,19 @@ public function testGenerate(): void ]; $resizer = $this->createMock(ResizerInterface::class); - $resizer->expects($this->exactly(2))->method('resize')->will($this->returnValue(true)); + $resizer->expects($this->exactly(2))->method('resize')->willReturn(true); $provider = $this->createMock(MediaProviderInterface::class); - $provider->expects($this->once())->method('requireThumbnails')->will($this->returnValue(true)); - $provider->expects($this->once())->method('getReferenceFile')->will($this->returnValue($referenceFile)); - $provider->expects($this->once())->method('getFormats')->will($this->returnValue($formats)); - $provider->expects($this->exactly(2))->method('getResizer')->will($this->returnValue($resizer)); - $provider->expects($this->exactly(2))->method('generatePrivateUrl')->will($this->returnValue('/my/private/path')); - $provider->expects($this->exactly(2))->method('getFilesystem')->will($this->returnValue($filesystem)); + $provider->expects($this->once())->method('requireThumbnails')->willReturn(true); + $provider->expects($this->once())->method('getReferenceFile')->willReturn($referenceFile); + $provider->expects($this->once())->method('getFormats')->willReturn($formats); + $provider->expects($this->exactly(2))->method('getResizer')->willReturn($resizer); + $provider->expects($this->exactly(2))->method('generatePrivateUrl')->willReturn('/my/private/path'); + $provider->expects($this->exactly(2))->method('getFilesystem')->willReturn($filesystem); $media = $this->createMock(MediaInterface::class); - $media->expects($this->exactly(6))->method('getContext')->will($this->returnValue('mycontext')); - $media->expects($this->exactly(2))->method('getExtension')->will($this->returnValue('png')); + $media->expects($this->exactly(6))->method('getContext')->willReturn('mycontext'); + $media->expects($this->exactly(2))->method('getExtension')->willReturn('png'); $thumbnail->generate($provider, $media); } diff --git a/tests/Twig/Extension/MediaExtensionTest.php b/tests/Twig/Extension/MediaExtensionTest.php index ddfb21d46e..48bdd7ea76 100644 --- a/tests/Twig/Extension/MediaExtensionTest.php +++ b/tests/Twig/Extension/MediaExtensionTest.php @@ -98,7 +98,7 @@ public function getProvider() { if (null === $this->provider) { $this->provider = $this->createMock(MediaProviderInterface::class); - $this->provider->method('getFormatName')->will($this->returnArgument(1)); + $this->provider->method('getFormatName')->willReturnArgument(1); } return $this->provider; diff --git a/tests/Validator/FormatValidatorTest.php b/tests/Validator/FormatValidatorTest.php index 14cadeb905..02d047d9de 100644 --- a/tests/Validator/FormatValidatorTest.php +++ b/tests/Validator/FormatValidatorTest.php @@ -28,8 +28,8 @@ public function testValidate(): void $pool->addContext('test', [], ['format1' => []]); $gallery = $this->createMock(GalleryInterface::class); - $gallery->expects($this->once())->method('getDefaultFormat')->will($this->returnValue('format1')); - $gallery->expects($this->once())->method('getContext')->will($this->returnValue('test')); + $gallery->expects($this->once())->method('getDefaultFormat')->willReturn('format1'); + $gallery->expects($this->once())->method('getContext')->willReturn('test'); $context = $this->createMock(ExecutionContext::class); $context->expects($this->never())->method('addViolation'); @@ -46,8 +46,8 @@ public function testValidateNotValidDefaultFormat(): void $pool->addContext('test', [], ['format1' => []]); $gallery = $this->createMock(GalleryInterface::class); - $gallery->expects($this->once())->method('getDefaultFormat')->will($this->returnValue('non_existing_format')); - $gallery->expects($this->once())->method('getContext')->will($this->returnValue('test')); + $gallery->expects($this->once())->method('getDefaultFormat')->willReturn('non_existing_format'); + $gallery->expects($this->once())->method('getContext')->willReturn('test'); $context = $this->createMock(ExecutionContext::class); $context->expects($this->once())->method('addViolation'); @@ -64,8 +64,8 @@ public function testValidateOnlyReferenceIsAllowedIfNotFormats(): void $pool->addContext('test'); $gallery = $this->createMock(GalleryInterface::class); - $gallery->expects($this->once())->method('getDefaultFormat')->will($this->returnValue('format_that_is_not_reference')); - $gallery->expects($this->once())->method('getContext')->will($this->returnValue('test')); + $gallery->expects($this->once())->method('getDefaultFormat')->willReturn('format_that_is_not_reference'); + $gallery->expects($this->once())->method('getContext')->willReturn('test'); $context = $this->createMock(ExecutionContext::class); $context->expects($this->once())->method('addViolation'); From d61921a3a6dee81a1769e3485d0b3b6e7f65ae2d Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 28 May 2019 09:20:08 +0200 Subject: [PATCH 46/77] [Bug]: GalleryMediaCollectionInterface references non existant Interface ## Changes: - The GalleryMediaCollectionInterface refereced the old GalleryHasMediaInterface wich was migrated to GalleryItemInterface. - The old reference was repalced with the new interface On branch master Changes to be committed: - modified: src/Model/GalleryMediaCollectionInterface.php --- src/Model/GalleryMediaCollectionInterface.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Model/GalleryMediaCollectionInterface.php b/src/Model/GalleryMediaCollectionInterface.php index 95eaf8451a..0f40555a14 100644 --- a/src/Model/GalleryMediaCollectionInterface.php +++ b/src/Model/GalleryMediaCollectionInterface.php @@ -19,7 +19,7 @@ */ interface GalleryMediaCollectionInterface { - public function addGalleryHasMedia(GalleryHasMediaInterface $galleryHasMedia); + public function addGalleryHasMedia(GalleryItemInterface $galleryItem); - public function removeGalleryHasMedia(GalleryHasMediaInterface $galleryHasMedia); + public function removeGalleryHasMedia(GalleryItemInterface $galleryItem); } From 4b7807ff2f7050809ec42af619331a7735758466 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Sun, 1 Sep 2019 09:35:42 -0300 Subject: [PATCH 47/77] Use Twig namespaced classes --- src/Twig/Extension/MediaExtension.php | 2 +- src/Twig/Node/MediaNode.php | 3 ++- src/Twig/Node/PathNode.php | 3 ++- src/Twig/Node/ThumbnailNode.php | 3 ++- src/Twig/TokenParser/MediaTokenParser.php | 2 +- src/Twig/TokenParser/PathTokenParser.php | 2 +- src/Twig/TokenParser/ThumbnailTokenParser.php | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Twig/Extension/MediaExtension.php b/src/Twig/Extension/MediaExtension.php index 9b63a94e19..bd78cff86e 100644 --- a/src/Twig/Extension/MediaExtension.php +++ b/src/Twig/Extension/MediaExtension.php @@ -69,7 +69,7 @@ public function getTokenParsers() /** * {@inheritdoc} */ - public function initRuntime(\Twig_Environment $environment): void + public function initRuntime(Environment $environment): void { $this->environment = $environment; } diff --git a/src/Twig/Node/MediaNode.php b/src/Twig/Node/MediaNode.php index 9e7671fbcc..18946fc004 100644 --- a/src/Twig/Node/MediaNode.php +++ b/src/Twig/Node/MediaNode.php @@ -13,6 +13,7 @@ namespace Sonata\MediaBundle\Twig\Node; +use Twig\Compiler; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Node; @@ -41,7 +42,7 @@ public function __construct($extensionName, AbstractExpression $media, AbstractE /** * {@inheritdoc} */ - public function compile(\Twig_Compiler $compiler): void + public function compile(Compiler $compiler): void { $compiler ->addDebugInfo($this) diff --git a/src/Twig/Node/PathNode.php b/src/Twig/Node/PathNode.php index 8ac71b836b..5f3263e122 100644 --- a/src/Twig/Node/PathNode.php +++ b/src/Twig/Node/PathNode.php @@ -13,6 +13,7 @@ namespace Sonata\MediaBundle\Twig\Node; +use Twig\Compiler; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Node; @@ -41,7 +42,7 @@ public function __construct($extensionName, AbstractExpression $media, AbstractE /** * {@inheritdoc} */ - public function compile(\Twig_Compiler $compiler): void + public function compile(Compiler $compiler): void { $compiler ->addDebugInfo($this) diff --git a/src/Twig/Node/ThumbnailNode.php b/src/Twig/Node/ThumbnailNode.php index 4bc31e0427..eb81d477a2 100644 --- a/src/Twig/Node/ThumbnailNode.php +++ b/src/Twig/Node/ThumbnailNode.php @@ -13,6 +13,7 @@ namespace Sonata\MediaBundle\Twig\Node; +use Twig\Compiler; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Node; @@ -41,7 +42,7 @@ public function __construct($extensionName, AbstractExpression $media, AbstractE /** * {@inheritdoc} */ - public function compile(\Twig_Compiler $compiler): void + public function compile(Compiler $compiler): void { $compiler ->addDebugInfo($this) diff --git a/src/Twig/TokenParser/MediaTokenParser.php b/src/Twig/TokenParser/MediaTokenParser.php index b85fbb8990..48cbf0b51c 100644 --- a/src/Twig/TokenParser/MediaTokenParser.php +++ b/src/Twig/TokenParser/MediaTokenParser.php @@ -39,7 +39,7 @@ public function __construct($extensionName) /** * {@inheritdoc} */ - public function parse(\Twig_Token $token) + public function parse(Token $token) { $media = $this->parser->getExpressionParser()->parseExpression(); diff --git a/src/Twig/TokenParser/PathTokenParser.php b/src/Twig/TokenParser/PathTokenParser.php index 3c95ccbf5c..ea79fa8fba 100644 --- a/src/Twig/TokenParser/PathTokenParser.php +++ b/src/Twig/TokenParser/PathTokenParser.php @@ -38,7 +38,7 @@ public function __construct($extensionName) /** * {@inheritdoc} */ - public function parse(\Twig_Token $token) + public function parse(Token $token) { $media = $this->parser->getExpressionParser()->parseExpression(); diff --git a/src/Twig/TokenParser/ThumbnailTokenParser.php b/src/Twig/TokenParser/ThumbnailTokenParser.php index 18dec0e07a..b6c4637bc7 100644 --- a/src/Twig/TokenParser/ThumbnailTokenParser.php +++ b/src/Twig/TokenParser/ThumbnailTokenParser.php @@ -39,7 +39,7 @@ public function __construct($extensionName) /** * {@inheritdoc} */ - public function parse(\Twig_Token $token) + public function parse(Token $token) { $media = $this->parser->getExpressionParser()->parseExpression(); From b4e0cbda462d1e99fcc6611f18dd435229022684 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Fri, 24 Jan 2020 02:15:13 +0100 Subject: [PATCH 48/77] DevKit updates (#1673) --- .travis.yml | 5 ----- .travis/before_install_test.sh | 1 - 2 files changed, 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 32ab3be520..3211d6d5aa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,10 +55,6 @@ matrix: env: DOCTRINE_ODM=1.* - php: '7.3' env: DOCTRINE_ODM='dev-master as 1.x-dev' - - php: '7.3' - env: SONATA_CORE=3.* - - php: '7.3' - env: SONATA_CORE='dev-master as 3.x-dev' - php: '7.3' env: SONATA_ADMIN=3.* - php: '7.3' @@ -77,7 +73,6 @@ matrix: - env: SYMFONY_DEPRECATIONS_HELPER=0 - env: SYMFONY='dev-master as 3.4.x-dev' - env: DOCTRINE_ODM='dev-master as 1.x-dev' - - env: SONATA_CORE='dev-master as 3.x-dev' - env: SONATA_ADMIN='dev-master as 3.x-dev' - env: IMAGINE='dev-master as 1.x-dev' diff --git a/.travis/before_install_test.sh b/.travis/before_install_test.sh index f31f3e6f55..46f6d3a136 100755 --- a/.travis/before_install_test.sh +++ b/.travis/before_install_test.sh @@ -16,6 +16,5 @@ sed --in-place "s/\"dev-master\":/\"dev-${TRAVIS_COMMIT}\":/" composer.json if [ "$SYMFONY" != "" ]; then composer require "symfony/symfony:$SYMFONY" --no-update; fi; if [ "$DOCTRINE_ODM" != "" ]; then composer require "doctrine/mongodb-odm:$DOCTRINE_ODM" --no-update; fi; -if [ "$SONATA_CORE" != "" ]; then composer require "sonata-project/core-bundle:$SONATA_CORE" --no-update; fi; if [ "$SONATA_ADMIN" != "" ]; then composer require "sonata-project/admin-bundle:$SONATA_ADMIN" --no-update; fi; if [ "$IMAGINE" != "" ]; then composer require "imagine/imagine:$IMAGINE" --no-update; fi; From ee8b75bea737dcddf2a42d33b506b98be34c1e55 Mon Sep 17 00:00:00 2001 From: bigfoot90 Date: Mon, 3 Feb 2020 22:42:05 +0100 Subject: [PATCH 49/77] [BC break] Fix commands return type (#1682) FIX commands return types after merging https://github.com/sonata-project/SonataMediaBundle/pull/1679 --- src/Command/AddMassMediaCommand.php | 2 +- src/Command/AddMediaCommand.php | 2 +- src/Command/CleanMediaCommand.php | 2 +- src/Command/FixMediaContextCommand.php | 2 +- src/Command/MigrateToJsonTypeCommand.php | 2 +- src/Command/RefreshMetadataCommand.php | 2 +- src/Command/RemoveThumbsCommand.php | 20 +++++--------------- src/Command/SyncThumbsCommand.php | 6 ++---- src/Command/UpdateCdnStatusCommand.php | 2 +- 9 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/Command/AddMassMediaCommand.php b/src/Command/AddMassMediaCommand.php index 233e30617f..748eaceac3 100644 --- a/src/Command/AddMassMediaCommand.php +++ b/src/Command/AddMassMediaCommand.php @@ -45,7 +45,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { $fp = $this->getFilePointer($input, $output); $imported = -1; diff --git a/src/Command/AddMediaCommand.php b/src/Command/AddMediaCommand.php index 43938e68bc..5e26611c0e 100644 --- a/src/Command/AddMediaCommand.php +++ b/src/Command/AddMediaCommand.php @@ -57,7 +57,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { $provider = $input->getArgument('providerName'); $context = $input->getArgument('context'); diff --git a/src/Command/CleanMediaCommand.php b/src/Command/CleanMediaCommand.php index 864e5366e6..579e3b5f67 100755 --- a/src/Command/CleanMediaCommand.php +++ b/src/Command/CleanMediaCommand.php @@ -46,7 +46,7 @@ public function configure(): void /** * {@inheritdoc} */ - protected function execute(InputInterface $input, OutputInterface $output): void + protected function execute(InputInterface $input, OutputInterface $output): int { $dryRun = (bool) $input->getOption('dry-run'); $verbose = $output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE; diff --git a/src/Command/FixMediaContextCommand.php b/src/Command/FixMediaContextCommand.php index fb8340b4dc..7aeee65b8b 100755 --- a/src/Command/FixMediaContextCommand.php +++ b/src/Command/FixMediaContextCommand.php @@ -35,7 +35,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { if (!$this->getContainer()->has('sonata.media.manager.category')) { throw new \LogicException('The classification feature is disabled.'); diff --git a/src/Command/MigrateToJsonTypeCommand.php b/src/Command/MigrateToJsonTypeCommand.php index 56347194ef..d50f69eb12 100644 --- a/src/Command/MigrateToJsonTypeCommand.php +++ b/src/Command/MigrateToJsonTypeCommand.php @@ -37,7 +37,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { $count = 0; $table = $input->getOption('table'); diff --git a/src/Command/RefreshMetadataCommand.php b/src/Command/RefreshMetadataCommand.php index 842040c484..ae91db791d 100644 --- a/src/Command/RefreshMetadataCommand.php +++ b/src/Command/RefreshMetadataCommand.php @@ -62,7 +62,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { $this->quiet = $input->getOption('quiet'); diff --git a/src/Command/RemoveThumbsCommand.php b/src/Command/RemoveThumbsCommand.php index a8d8b02e54..623b5712ca 100644 --- a/src/Command/RemoveThumbsCommand.php +++ b/src/Command/RemoveThumbsCommand.php @@ -68,7 +68,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { $this->input = $input; $this->output = $output; @@ -141,10 +141,7 @@ public function execute(InputInterface $input, OutputInterface $output): void return 0; } - /** - * @return MediaProviderInterface - */ - public function getProvider() + public function getProvider(): MediaProviderInterface { $providerName = $this->input->getArgument('providerName'); @@ -159,10 +156,7 @@ public function getProvider() return $this->getMediaPool()->getProvider($providerName); } - /** - * @return string - */ - public function getContext() + public function getContext(): string { $context = $this->input->getArgument('context'); @@ -179,10 +173,8 @@ public function getContext() /** * @param string $context - * - * @return string */ - public function getFormat(MediaProviderInterface $provider, $context) + public function getFormat(MediaProviderInterface $provider, $context): string { $format = $this->input->getArgument('format'); @@ -209,10 +201,8 @@ public function getFormat(MediaProviderInterface $provider, $context) /** * @param string $context * @param string $format - * - * @return bool */ - protected function processMedia(MediaInterface $media, MediaProviderInterface $provider, $context, $format) + protected function processMedia(MediaInterface $media, MediaProviderInterface $provider, $context, $format): bool { $this->log('Deleting thumbs for '.$media->getName().' - '.$media->getId()); diff --git a/src/Command/SyncThumbsCommand.php b/src/Command/SyncThumbsCommand.php index e8f53d7909..f9ed89c27e 100644 --- a/src/Command/SyncThumbsCommand.php +++ b/src/Command/SyncThumbsCommand.php @@ -61,7 +61,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { $helper = $this->getHelper('question'); @@ -161,10 +161,8 @@ public function execute(InputInterface $input, OutputInterface $output): void /** * @param MediaInterface $media * @param MediaProviderInterface $provider - * - * @return bool */ - protected function processMedia($media, $provider) + protected function processMedia($media, $provider): bool { $this->log('Generating thumbs for '.$media->getName().' - '.$media->getId()); diff --git a/src/Command/UpdateCdnStatusCommand.php b/src/Command/UpdateCdnStatusCommand.php index e44c578b14..d98fcbcbee 100644 --- a/src/Command/UpdateCdnStatusCommand.php +++ b/src/Command/UpdateCdnStatusCommand.php @@ -63,7 +63,7 @@ public function configure(): void /** * {@inheritdoc} */ - public function execute(InputInterface $input, OutputInterface $output): void + public function execute(InputInterface $input, OutputInterface $output): int { $this->quiet = $input->getOption('quiet'); From 1bbb24728c4b8e270ef44c0124801b2d4a294d5d Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Tue, 11 Feb 2020 04:42:54 +0100 Subject: [PATCH 50/77] DevKit updates (#1691) --- .github/workflows/documentation.yaml | 53 ++++++++++++++++++++++++++++ .github/workflows/lint.yaml | 14 -------- .travis.yml | 2 -- .travis/check_relevant_docs.sh | 6 ---- .travis/install_docs.sh | 4 --- 5 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 .github/workflows/documentation.yaml delete mode 100644 .github/workflows/lint.yaml delete mode 100755 .travis/check_relevant_docs.sh delete mode 100755 .travis/install_docs.sh diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 0000000000..64b848cbf8 --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,53 @@ +on: + push: + paths: + - 'docs/**' + + pull_request: + paths: + - 'docs/**' + +name: Documentation + +jobs: + build: + name: Build + + runs-on: ubuntu-latest + + steps: + - name: "Checkout" + uses: actions/checkout@v2 + + - name: "Set up Python 3.7" + uses: actions/setup-python@v1 + with: + python-version: '3.7' # Semantic version range syntax or exact version of a Python version + + - name: "Display Python version" + run: python -c "import sys; print(sys.version)" + + - name: "Install Sphinx dependencies" + run: sudo apt-get install python-dev build-essential + + - name: "Install custom requirements via pip" + run: pip install -r docs/requirements.txt + + - name: "Build documentation" + run: make docs + + doctor-rst: + name: DOCtor-RST + + runs-on: ubuntu-latest + + steps: + - name: "Checkout" + uses: actions/checkout@master + + - name: "Run DOCtor-RST" + uses: docker://oskarstark/doctor-rst + with: + args: --short + env: + DOCS_DIR: 'docs/' diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml deleted file mode 100644 index a441c78f1a..0000000000 --- a/.github/workflows/lint.yaml +++ /dev/null @@ -1,14 +0,0 @@ -on: [push, pull_request] -name: Lint -jobs: - doctor-rst: - name: DOCtor-RST - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: DOCtor-RST - uses: docker://oskarstark/doctor-rst - with: - args: --short - env: - DOCS_DIR: 'docs/' diff --git a/.travis.yml b/.travis.yml index c52ec3ac37..4599dd5479 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,8 +41,6 @@ env: matrix: fast_finish: true include: - - php: '7.3' - env: TARGET=docs - php: '7.3' env: TARGET=lint - php: '7.2' diff --git a/.travis/check_relevant_docs.sh b/.travis/check_relevant_docs.sh deleted file mode 100755 index 9e618c4e26..0000000000 --- a/.travis/check_relevant_docs.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash -set -ev - -RELEVANT_FILES=$(git diff --name-only HEAD upstream/${TRAVIS_BRANCH} -- '*.rst') - -if [[ -z ${RELEVANT_FILES} ]]; then echo -n 'KO'; exit 0; fi; diff --git a/.travis/install_docs.sh b/.travis/install_docs.sh deleted file mode 100755 index a5522d971c..0000000000 --- a/.travis/install_docs.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env sh -set -ev - -pip install -r docs/requirements.txt --user From 0d3940d8bb47b146872ad5be0b12a17265ec44c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20B=C5=82oszyk?= Date: Sat, 1 Aug 2020 11:35:32 +0200 Subject: [PATCH 51/77] Remove @inheritdoc --- src/Admin/BaseMediaAdmin.php | 18 -- src/Admin/GalleryAdmin.php | 21 --- src/Admin/GalleryItemAdmin.php | 6 - src/Admin/ODM/MediaAdmin.php | 3 - src/Admin/ORM/MediaAdmin.php | 3 - src/Admin/PHPCR/GalleryAdmin.php | 12 -- src/Admin/PHPCR/MediaAdmin.php | 12 -- .../BaseGalleryBreadcrumbBlockService.php | 3 - .../GalleryIndexBreadcrumbBlockService.php | 6 - .../GalleryViewBreadcrumbBlockService.php | 9 - .../MediaViewBreadcrumbBlockService.php | 9 - src/Block/FeatureMediaBlockService.php | 12 -- src/Block/GalleryBlockService.php | 9 - src/Block/GalleryListBlockService.php | 6 - src/Block/MediaBlockService.php | 15 -- src/CDN/CloudFront.php | 9 - src/CDN/Fallback.php | 15 -- src/CDN/PantherPortal.php | 15 -- src/CDN/Server.php | 15 -- src/Command/AddMassMediaCommand.php | 6 - src/Command/AddMediaCommand.php | 6 - src/Command/CleanMediaCommand.php | 6 - src/Command/FixMediaContextCommand.php | 6 - src/Command/MigrateToJsonTypeCommand.php | 6 - src/Command/RefreshMetadataCommand.php | 6 - src/Command/RemoveThumbsCommand.php | 6 - src/Command/SyncThumbsCommand.php | 6 - src/Command/UpdateCdnStatusCommand.php | 6 - src/Consumer/CreateThumbnailConsumer.php | 3 - src/Controller/MediaAdminController.php | 9 - .../Compiler/AddProviderCompilerPass.php | 3 - .../Compiler/GlobalVariablesCompilerPass.php | 3 - src/DependencyInjection/Configuration.php | 3 - .../SonataMediaExtension.php | 3 - src/Document/BaseMedia.php | 6 - src/Document/GalleryManager.php | 3 - src/Document/MediaManager.php | 6 - src/Entity/BaseGallery.php | 3 - src/Entity/BaseMedia.php | 6 - src/Entity/GalleryManager.php | 3 - src/Entity/MediaManager.php | 6 - src/Extra/ApiMediaFile.php | 12 -- src/Filesystem/Replicate.php | 39 ----- .../ProviderDataTransformer.php | 6 - .../ServiceProviderDataTransformer.php | 6 - src/Form/Type/ApiMediaType.php | 12 -- src/Form/Type/MediaType.php | 15 -- src/Listener/ODM/MediaEventSubscriber.php | 6 - src/Listener/ORM/MediaEventSubscriber.php | 9 - src/Listener/PHPCR/MediaEventSubscriber.php | 9 - src/Metadata/AmazonMetadataBuilder.php | 3 - src/Metadata/NoopMetadataBuilder.php | 3 - src/Metadata/ProxyMetadataBuilder.php | 3 - src/Model/CategoryManager.php | 21 --- src/Model/Gallery.php | 48 ------ src/Model/GalleryItem.php | 39 ----- src/Model/GalleryManager.php | 3 - src/Model/Media.php | 162 ------------------ src/PHPCR/BaseGallery.php | 6 - src/PHPCR/BaseMedia.php | 6 - src/PHPCR/GalleryManager.php | 3 - src/PHPCR/MediaManager.php | 6 - src/Provider/BaseProvider.php | 75 -------- src/Provider/BaseVideoProvider.php | 33 ---- src/Provider/DailyMotionProvider.php | 15 -- src/Provider/FileProvider.php | 45 ----- src/Provider/ImageProvider.php | 18 -- src/Provider/VimeoProvider.php | 15 -- src/Provider/YouTubeProvider.php | 15 -- src/Resizer/SimpleResizer.php | 6 - src/Resizer/SquareResizer.php | 12 -- src/Security/ForbiddenDownloadStrategy.php | 6 - src/Security/PublicDownloadStrategy.php | 6 - src/Security/RolesDownloadStrategy.php | 6 - src/Security/SessionDownloadStrategy.php | 6 - src/Serializer/GallerySerializerHandler.php | 3 - src/Serializer/MediaSerializerHandler.php | 3 - src/Templating/Helper/MediaHelper.php | 3 - src/Thumbnail/ConsumerThumbnail.php | 12 -- src/Thumbnail/FormatThumbnail.php | 12 -- src/Thumbnail/LiipImagineThumbnail.php | 12 -- .../Extension/FormatterMediaExtension.php | 9 - src/Twig/Extension/MediaExtension.php | 6 - src/Twig/Node/MediaNode.php | 3 - src/Twig/Node/PathNode.php | 3 - src/Twig/Node/ThumbnailNode.php | 3 - src/Twig/TokenParser/MediaTokenParser.php | 6 - src/Twig/TokenParser/PathTokenParser.php | 6 - src/Twig/TokenParser/ThumbnailTokenParser.php | 6 - .../Constraints/ValidMediaFormat.php | 6 - src/Validator/FormatValidator.php | 3 - tests/Command/CleanMediaCommandTest.php | 3 - tests/Command/FixMediaContextCommandTest.php | 3 - tests/Command/RemoveThumbsCommandTest.php | 3 - .../SonataMediaExtensionTest.php | 6 - tests/Provider/BaseProviderTest.php | 48 ------ 96 files changed, 1143 deletions(-) diff --git a/src/Admin/BaseMediaAdmin.php b/src/Admin/BaseMediaAdmin.php index 73b648b078..edc138bca6 100644 --- a/src/Admin/BaseMediaAdmin.php +++ b/src/Admin/BaseMediaAdmin.php @@ -53,18 +53,12 @@ public function __construct($code, $class, $baseControllerName, Pool $pool, ?Cat $this->categoryManager = $categoryManager; } - /** - * {@inheritdoc} - */ public function prePersist($media): void { $parameters = $this->getPersistentParameters(); $media->setContext($parameters['context']); } - /** - * {@inheritdoc} - */ public function getPersistentParameters() { $parameters = parent::getPersistentParameters(); @@ -109,9 +103,6 @@ public function getPersistentParameters() ]); } - /** - * {@inheritdoc} - */ public function getNewInstance() { $media = parent::getNewInstance(); @@ -146,9 +137,6 @@ public function getPool() return $this->pool; } - /** - * {@inheritdoc} - */ public function getObjectMetadata($object) { $provider = $this->pool->getProvider($object->getProviderName()); @@ -161,9 +149,6 @@ public function getObjectMetadata($object) return new Metadata($object->getName(), $object->getDescription(), $url); } - /** - * {@inheritdoc} - */ protected function configureListFields(ListMapper $listMapper): void { $listMapper @@ -174,9 +159,6 @@ protected function configureListFields(ListMapper $listMapper): void ; } - /** - * {@inheritdoc} - */ protected function configureFormFields(FormMapper $formMapper): void { $media = $this->getSubject(); diff --git a/src/Admin/GalleryAdmin.php b/src/Admin/GalleryAdmin.php index 7849348995..5f6e4df38e 100644 --- a/src/Admin/GalleryAdmin.php +++ b/src/Admin/GalleryAdmin.php @@ -45,9 +45,6 @@ public function __construct($code, $class, $baseControllerName, Pool $pool) $this->pool = $pool; } - /** - * {@inheritdoc} - */ public function prePersist($gallery): void { $parameters = $this->getPersistentParameters(); @@ -55,17 +52,11 @@ public function prePersist($gallery): void $gallery->setContext($parameters['context']); } - /** - * {@inheritdoc} - */ public function postUpdate($gallery) { $gallery->reorderGalleryHasMedia(); } - /** - * {@inheritdoc} - */ public function getPersistentParameters() { $parameters = parent::getPersistentParameters(); @@ -79,9 +70,6 @@ public function getPersistentParameters() ]); } - /** - * {@inheritdoc} - */ public function getNewInstance() { $gallery = parent::getNewInstance(); @@ -93,9 +81,6 @@ public function getNewInstance() return $gallery; } - /** - * {@inheritdoc} - */ protected function configureFormFields(FormMapper $formMapper): void { // define group zoning @@ -144,9 +129,6 @@ protected function configureFormFields(FormMapper $formMapper): void ; } - /** - * {@inheritdoc} - */ protected function configureListFields(ListMapper $listMapper): void { $listMapper @@ -157,9 +139,6 @@ protected function configureListFields(ListMapper $listMapper): void ; } - /** - * {@inheritdoc} - */ protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { $datagridMapper diff --git a/src/Admin/GalleryItemAdmin.php b/src/Admin/GalleryItemAdmin.php index f4e0c4831a..0b204ef01b 100644 --- a/src/Admin/GalleryItemAdmin.php +++ b/src/Admin/GalleryItemAdmin.php @@ -24,9 +24,6 @@ */ class GalleryItemAdmin extends AbstractAdmin { - /** - * {@inheritdoc} - */ protected function configureFormFields(FormMapper $formMapper): void { $link_parameters = []; @@ -52,9 +49,6 @@ protected function configureFormFields(FormMapper $formMapper): void ; } - /** - * {@inheritdoc} - */ protected function configureListFields(ListMapper $listMapper): void { $listMapper diff --git a/src/Admin/ODM/MediaAdmin.php b/src/Admin/ODM/MediaAdmin.php index a9a400668c..b0bbc5cd7c 100644 --- a/src/Admin/ODM/MediaAdmin.php +++ b/src/Admin/ODM/MediaAdmin.php @@ -21,9 +21,6 @@ */ class MediaAdmin extends Admin { - /** - * {@inheritdoc} - */ protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { $datagridMapper diff --git a/src/Admin/ORM/MediaAdmin.php b/src/Admin/ORM/MediaAdmin.php index 3bd0f935f3..3b1078559f 100644 --- a/src/Admin/ORM/MediaAdmin.php +++ b/src/Admin/ORM/MediaAdmin.php @@ -23,9 +23,6 @@ */ class MediaAdmin extends Admin { - /** - * {@inheritdoc} - */ protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { $options = [ diff --git a/src/Admin/PHPCR/GalleryAdmin.php b/src/Admin/PHPCR/GalleryAdmin.php index c0c72ef459..b2ff17b598 100644 --- a/src/Admin/PHPCR/GalleryAdmin.php +++ b/src/Admin/PHPCR/GalleryAdmin.php @@ -37,9 +37,6 @@ public function setRoot($root): void $this->root = $root; } - /** - * {@inheritdoc} - */ public function createQuery($context = 'list') { $query = $this->getModelManager()->createQuery($this->getClass(), 'a', $this->root); @@ -51,17 +48,11 @@ public function createQuery($context = 'list') return $query; } - /** - * {@inheritdoc} - */ public function id($object) { return $this->getUrlsafeIdentifier($object); } - /** - * {@inheritdoc} - */ protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { // TODO disabled filter due to no attached service for filter types: string, checkbox @@ -71,9 +62,6 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper): voi // ->add('context') } - /** - * {@inheritdoc} - */ protected function configureRoutes(RouteCollection $collection): void { // Allow path in id parameter diff --git a/src/Admin/PHPCR/MediaAdmin.php b/src/Admin/PHPCR/MediaAdmin.php index cea183504a..fe3c6b9f07 100644 --- a/src/Admin/PHPCR/MediaAdmin.php +++ b/src/Admin/PHPCR/MediaAdmin.php @@ -37,9 +37,6 @@ public function setRoot($root): void $this->root = $root; } - /** - * {@inheritdoc} - */ public function createQuery($context = 'list') { $query = $this->getModelManager()->createQuery($this->getClass(), 'a', $this->root); @@ -51,17 +48,11 @@ public function createQuery($context = 'list') return $query; } - /** - * {@inheritdoc} - */ public function id($object) { return $this->getUrlsafeIdentifier($object); } - /** - * {@inheritdoc} - */ protected function configureDatagridFilters(DatagridMapper $datagridMapper): void { // TODO disabled filter due to no attached service for filter types: string, checkbox @@ -73,9 +64,6 @@ protected function configureDatagridFilters(DatagridMapper $datagridMapper): voi // ; } - /** - * {@inheritdoc} - */ protected function configureRoutes(RouteCollection $collection): void { // Allow path in id parameter diff --git a/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php b/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php index 1dc252cecf..9f6b2d275e 100644 --- a/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php +++ b/src/Block/Breadcrumb/BaseGalleryBreadcrumbBlockService.php @@ -23,9 +23,6 @@ */ abstract class BaseGalleryBreadcrumbBlockService extends BaseBreadcrumbMenuBlockService { - /** - * {@inheritdoc} - */ protected function getRootMenu(BlockContextInterface $blockContext) { $menu = parent::getRootMenu($blockContext); diff --git a/src/Block/Breadcrumb/GalleryIndexBreadcrumbBlockService.php b/src/Block/Breadcrumb/GalleryIndexBreadcrumbBlockService.php index c259e32630..e32b4f6ef3 100644 --- a/src/Block/Breadcrumb/GalleryIndexBreadcrumbBlockService.php +++ b/src/Block/Breadcrumb/GalleryIndexBreadcrumbBlockService.php @@ -24,17 +24,11 @@ */ class GalleryIndexBreadcrumbBlockService extends BaseGalleryBreadcrumbBlockService { - /** - * {@inheritdoc} - */ public function getName() { return 'Breadcrumb Index: Media Gallery'; } - /** - * {@inheritdoc} - */ protected function getMenu(BlockContextInterface $blockContext) { $menu = $this->getRootMenu($blockContext); diff --git a/src/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php b/src/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php index bb475db83f..aa727723ba 100644 --- a/src/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php +++ b/src/Block/Breadcrumb/GalleryViewBreadcrumbBlockService.php @@ -25,17 +25,11 @@ */ class GalleryViewBreadcrumbBlockService extends BaseGalleryBreadcrumbBlockService { - /** - * {@inheritdoc} - */ public function getName() { return 'Breadcrumb View: Media Gallery'; } - /** - * {@inheritdoc} - */ public function configureSettings(OptionsResolver $resolver): void { parent::configureSettings($resolver); @@ -45,9 +39,6 @@ public function configureSettings(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ protected function getMenu(BlockContextInterface $blockContext) { $menu = $this->getRootMenu($blockContext); diff --git a/src/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php b/src/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php index d13dec24d8..eee0782e41 100644 --- a/src/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php +++ b/src/Block/Breadcrumb/MediaViewBreadcrumbBlockService.php @@ -25,17 +25,11 @@ */ class MediaViewBreadcrumbBlockService extends BaseGalleryBreadcrumbBlockService { - /** - * {@inheritdoc} - */ public function getName() { return 'Breadcrumb View: Media'; } - /** - * {@inheritdoc} - */ public function configureSettings(OptionsResolver $resolver): void { parent::configureSettings($resolver); @@ -45,9 +39,6 @@ public function configureSettings(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ protected function getMenu(BlockContextInterface $blockContext) { $menu = $this->getRootMenu($blockContext); diff --git a/src/Block/FeatureMediaBlockService.php b/src/Block/FeatureMediaBlockService.php index 945b3f32bb..971bf80dad 100644 --- a/src/Block/FeatureMediaBlockService.php +++ b/src/Block/FeatureMediaBlockService.php @@ -29,9 +29,6 @@ */ class FeatureMediaBlockService extends MediaBlockService { - /** - * {@inheritdoc} - */ public function configureSettings(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -49,9 +46,6 @@ public function configureSettings(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ public function buildEditForm(FormMapper $formMapper, BlockInterface $block): void { $formatChoices = $this->getFormatChoices($block->getSetting('mediaId')); @@ -97,9 +91,6 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block): vo ]); } - /** - * {@inheritdoc} - */ public function getStylesheets($media) { return [ @@ -107,9 +98,6 @@ public function getStylesheets($media) ]; } - /** - * {@inheritdoc} - */ public function getBlockMetadata($code = null) { return new Metadata($this->getName(), (null !== $code ? $code : $this->getName()), false, 'SonataMediaBundle', [ diff --git a/src/Block/GalleryBlockService.php b/src/Block/GalleryBlockService.php index 660bdcbf3d..4322186340 100644 --- a/src/Block/GalleryBlockService.php +++ b/src/Block/GalleryBlockService.php @@ -92,9 +92,6 @@ public function getGalleryAdmin() return $this->galleryAdmin; } - /** - * {@inheritdoc} - */ public function configureSettings(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -195,9 +192,6 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block): vo ]); } - /** - * {@inheritdoc} - */ public function execute(BlockContextInterface $blockContext, ?Response $response = null) { $gallery = $blockContext->getBlock()->getSetting('galleryId'); @@ -210,9 +204,6 @@ public function execute(BlockContextInterface $blockContext, ?Response $response ], $response); } - /** - * {@inheritdoc} - */ public function load(BlockInterface $block): void { $gallery = $block->getSetting('galleryId'); diff --git a/src/Block/GalleryListBlockService.php b/src/Block/GalleryListBlockService.php index a2978edba0..bbc0dacea7 100755 --- a/src/Block/GalleryListBlockService.php +++ b/src/Block/GalleryListBlockService.php @@ -126,9 +126,6 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block): vo ]); } - /** - * {@inheritdoc} - */ public function execute(BlockContextInterface $blockContext, ?Response $response = null) { $context = $blockContext->getBlock()->getSetting('context'); @@ -155,9 +152,6 @@ public function execute(BlockContextInterface $blockContext, ?Response $response ], $response); } - /** - * {@inheritdoc} - */ public function configureSettings(OptionsResolver $resolver): void { $resolver->setDefaults([ diff --git a/src/Block/MediaBlockService.php b/src/Block/MediaBlockService.php index 3eee5e8c95..304da10dbd 100644 --- a/src/Block/MediaBlockService.php +++ b/src/Block/MediaBlockService.php @@ -94,9 +94,6 @@ public function getMediaAdmin() return $this->mediaAdmin; } - /** - * {@inheritdoc} - */ public function configureSettings(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -155,9 +152,6 @@ public function buildEditForm(FormMapper $formMapper, BlockInterface $block): vo ]); } - /** - * {@inheritdoc} - */ public function execute(BlockContextInterface $blockContext, ?Response $response = null) { // make sure we have a valid format @@ -177,9 +171,6 @@ public function execute(BlockContextInterface $blockContext, ?Response $response ], $response); } - /** - * {@inheritdoc} - */ public function load(BlockInterface $block): void { $media = $block->getSetting('mediaId', null); @@ -191,17 +182,11 @@ public function load(BlockInterface $block): void $block->setSetting('mediaId', $media); } - /** - * {@inheritdoc} - */ public function prePersist(BlockInterface $block): void { $block->setSetting('mediaId', \is_object($block->getSetting('mediaId')) ? $block->getSetting('mediaId')->getId() : null); } - /** - * {@inheritdoc} - */ public function preUpdate(BlockInterface $block): void { $block->setSetting('mediaId', \is_object($block->getSetting('mediaId')) ? $block->getSetting('mediaId')->getId() : null); diff --git a/src/CDN/CloudFront.php b/src/CDN/CloudFront.php index 5cd97e7789..aa7f7db8b9 100644 --- a/src/CDN/CloudFront.php +++ b/src/CDN/CloudFront.php @@ -90,25 +90,16 @@ public function __construct($path, $key, $secret, $distributionId) $this->distributionId = $distributionId; } - /** - * {@inheritdoc} - */ public function getPath($relativePath, $isFlushable = false) { return sprintf('%s/%s', rtrim($this->path, '/'), ltrim($relativePath, '/')); } - /** - * {@inheritdoc} - */ public function flushByString($string) { return $this->flushPaths([$string]); } - /** - * {@inheritdoc} - */ public function flush($string) { return $this->flushPaths([$string]); diff --git a/src/CDN/Fallback.php b/src/CDN/Fallback.php index 7dcc24d759..3f841f9968 100644 --- a/src/CDN/Fallback.php +++ b/src/CDN/Fallback.php @@ -34,9 +34,6 @@ public function __construct(CDNInterface $cdn, CDNInterface $fallback) $this->fallback = $fallback; } - /** - * {@inheritdoc} - */ public function getPath($relativePath, $isFlushable) { if ($isFlushable) { @@ -46,33 +43,21 @@ public function getPath($relativePath, $isFlushable) return $this->cdn->getPath($relativePath, $isFlushable); } - /** - * {@inheritdoc} - */ public function flushByString($string) { return $this->cdn->flushByString($string); } - /** - * {@inheritdoc} - */ public function flush($string) { return $this->cdn->flush($string); } - /** - * {@inheritdoc} - */ public function flushPaths(array $paths) { return $this->cdn->flushPaths($paths); } - /** - * {@inheritdoc} - */ public function getFlushStatus($identifier) { return $this->cdn->getFlushStatus($identifier); diff --git a/src/CDN/PantherPortal.php b/src/CDN/PantherPortal.php index 8876fe6e39..364316bdca 100644 --- a/src/CDN/PantherPortal.php +++ b/src/CDN/PantherPortal.php @@ -81,33 +81,21 @@ public function __construct($path, $username, $password, $siteId, $wsdl = 'https $this->wsdl = $wsdl; } - /** - * {@inheritdoc} - */ public function getPath($relativePath, $isFlushable) { return sprintf('%s/%s', $this->path, $relativePath); } - /** - * {@inheritdoc} - */ public function flushByString($string): void { $this->flushPaths([$string]); } - /** - * {@inheritdoc} - */ public function flush($string): void { $this->flushPaths([$string]); } - /** - * {@inheritdoc} - */ public function flushPaths(array $paths): void { $result = $this->getClient()->flush($this->username, $this->password, 'paths', $this->siteId, implode("\n", $paths), true, false); @@ -127,9 +115,6 @@ public function setClient($client): void $this->client = $client; } - /** - * {@inheritdoc} - */ public function getFlushStatus($identifier): void { // nothing to do diff --git a/src/CDN/Server.php b/src/CDN/Server.php index dabfe81503..6d1ded6cc4 100644 --- a/src/CDN/Server.php +++ b/src/CDN/Server.php @@ -31,41 +31,26 @@ public function __construct($path) $this->path = $path; } - /** - * {@inheritdoc} - */ public function getPath($relativePath, $isFlushable) { return sprintf('%s/%s', rtrim($this->path, '/'), ltrim($relativePath, '/')); } - /** - * {@inheritdoc} - */ public function flushByString($string): void { // nothing to do } - /** - * {@inheritdoc} - */ public function flush($string): void { // nothing to do } - /** - * {@inheritdoc} - */ public function flushPaths(array $paths): void { // nothing to do } - /** - * {@inheritdoc} - */ public function getFlushStatus($identifier): void { // nothing to do diff --git a/src/Command/AddMassMediaCommand.php b/src/Command/AddMassMediaCommand.php index 748eaceac3..6c45a27290 100644 --- a/src/Command/AddMassMediaCommand.php +++ b/src/Command/AddMassMediaCommand.php @@ -27,9 +27,6 @@ class AddMassMediaCommand extends BaseCommand */ protected $setters; - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:add-multiple') @@ -42,9 +39,6 @@ public function configure(): void ]); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { $fp = $this->getFilePointer($input, $output); diff --git a/src/Command/AddMediaCommand.php b/src/Command/AddMediaCommand.php index 5e26611c0e..ebb8e06e3e 100644 --- a/src/Command/AddMediaCommand.php +++ b/src/Command/AddMediaCommand.php @@ -35,9 +35,6 @@ class AddMediaCommand extends BaseCommand */ protected $output; - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:add') @@ -54,9 +51,6 @@ public function configure(): void ]); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { $provider = $input->getArgument('providerName'); diff --git a/src/Command/CleanMediaCommand.php b/src/Command/CleanMediaCommand.php index 33c0e0dce5..7bdf6228f0 100755 --- a/src/Command/CleanMediaCommand.php +++ b/src/Command/CleanMediaCommand.php @@ -60,9 +60,6 @@ public function __construct(Local $filesystemLocal, Pool $mediaPool, MediaManage $this->mediaManager = $mediaManager; } - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:clean-uploads') @@ -70,9 +67,6 @@ public function configure(): void ->addOption('dry-run', null, InputOption::VALUE_NONE, 'Execute the cleanup as a dry run. This doesn\'t remove any files'); } - /** - * {@inheritdoc} - */ protected function execute(InputInterface $input, OutputInterface $output): int { $dryRun = (bool) $input->getOption('dry-run'); diff --git a/src/Command/FixMediaContextCommand.php b/src/Command/FixMediaContextCommand.php index 7aeee65b8b..3fbb1b2009 100755 --- a/src/Command/FixMediaContextCommand.php +++ b/src/Command/FixMediaContextCommand.php @@ -23,18 +23,12 @@ */ class FixMediaContextCommand extends ContainerAwareCommand { - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:fix-media-context'); $this->setDescription('Generate the default category for each media context'); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { if (!$this->getContainer()->has('sonata.media.manager.category')) { diff --git a/src/Command/MigrateToJsonTypeCommand.php b/src/Command/MigrateToJsonTypeCommand.php index d50f69eb12..2fb6bfac53 100644 --- a/src/Command/MigrateToJsonTypeCommand.php +++ b/src/Command/MigrateToJsonTypeCommand.php @@ -22,9 +22,6 @@ */ class MigrateToJsonTypeCommand extends BaseCommand { - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:migrate-json'); @@ -34,9 +31,6 @@ public function configure(): void $this->setDescription('Migrate all media provider metadata to the doctrine JsonType'); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { $count = 0; diff --git a/src/Command/RefreshMetadataCommand.php b/src/Command/RefreshMetadataCommand.php index 962a9b1048..3abd760f2f 100644 --- a/src/Command/RefreshMetadataCommand.php +++ b/src/Command/RefreshMetadataCommand.php @@ -45,9 +45,6 @@ class RefreshMetadataCommand extends BaseCommand */ private $input; - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:refresh-metadata') @@ -60,9 +57,6 @@ public function configure(): void ); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { $this->quiet = $input->getOption('quiet'); diff --git a/src/Command/RemoveThumbsCommand.php b/src/Command/RemoveThumbsCommand.php index e6b0d151a3..f9282c9531 100644 --- a/src/Command/RemoveThumbsCommand.php +++ b/src/Command/RemoveThumbsCommand.php @@ -47,9 +47,6 @@ class RemoveThumbsCommand extends BaseCommand */ protected $output; - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:remove-thumbnails') @@ -66,9 +63,6 @@ public function configure(): void ); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { $this->input = $input; diff --git a/src/Command/SyncThumbsCommand.php b/src/Command/SyncThumbsCommand.php index 0b78b985db..4c963376f1 100644 --- a/src/Command/SyncThumbsCommand.php +++ b/src/Command/SyncThumbsCommand.php @@ -41,9 +41,6 @@ class SyncThumbsCommand extends BaseCommand */ protected $output; - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:sync-thumbnails') @@ -59,9 +56,6 @@ public function configure(): void ); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { $helper = $this->getHelper('question'); diff --git a/src/Command/UpdateCdnStatusCommand.php b/src/Command/UpdateCdnStatusCommand.php index 90290eaa8f..6c7ab67163 100644 --- a/src/Command/UpdateCdnStatusCommand.php +++ b/src/Command/UpdateCdnStatusCommand.php @@ -46,9 +46,6 @@ class UpdateCdnStatusCommand extends BaseCommand */ private $input; - /** - * {@inheritdoc} - */ public function configure(): void { $this->setName('sonata:media:update-cdn-status') @@ -61,9 +58,6 @@ public function configure(): void ); } - /** - * {@inheritdoc} - */ public function execute(InputInterface $input, OutputInterface $output): int { $this->quiet = $input->getOption('quiet'); diff --git a/src/Consumer/CreateThumbnailConsumer.php b/src/Consumer/CreateThumbnailConsumer.php index c73edaf06c..b0b9dcfa14 100644 --- a/src/Consumer/CreateThumbnailConsumer.php +++ b/src/Consumer/CreateThumbnailConsumer.php @@ -48,9 +48,6 @@ public function __construct(ManagerInterface $mediaManager, Pool $pool, Containe $this->container = $container; } - /** - * {@inheritdoc} - */ public function process(ConsumerEvent $event): void { $media = $this->mediaManager->findOneBy([ diff --git a/src/Controller/MediaAdminController.php b/src/Controller/MediaAdminController.php index 69ee1affcd..6f1e94ff7c 100644 --- a/src/Controller/MediaAdminController.php +++ b/src/Controller/MediaAdminController.php @@ -24,9 +24,6 @@ */ class MediaAdminController extends Controller { - /** - * {@inheritdoc} - */ public function createAction(?Request $request = null) { $this->admin->checkAccess('create'); @@ -45,9 +42,6 @@ public function createAction(?Request $request = null) return parent::createAction(); } - /** - * {@inheritdoc} - */ public function render($view, array $parameters = [], ?Response $response = null) { $parameters['media_pool'] = $this->get('sonata.media.pool'); @@ -56,9 +50,6 @@ public function render($view, array $parameters = [], ?Response $response = null return parent::renderWithExtraParams($view, $parameters, $response); } - /** - * {@inheritdoc} - */ public function listAction(?Request $request = null) { $this->admin->checkAccess('list'); diff --git a/src/DependencyInjection/Compiler/AddProviderCompilerPass.php b/src/DependencyInjection/Compiler/AddProviderCompilerPass.php index 5fdcd436ce..c6385dba2b 100644 --- a/src/DependencyInjection/Compiler/AddProviderCompilerPass.php +++ b/src/DependencyInjection/Compiler/AddProviderCompilerPass.php @@ -27,9 +27,6 @@ */ class AddProviderCompilerPass implements CompilerPassInterface { - /** - * {@inheritdoc} - */ public function process(ContainerBuilder $container): void { $config = $this->getExtensionConfig($container); diff --git a/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php b/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php index fc77aa4fb8..b659c54f51 100644 --- a/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php +++ b/src/DependencyInjection/Compiler/GlobalVariablesCompilerPass.php @@ -26,9 +26,6 @@ */ class GlobalVariablesCompilerPass implements CompilerPassInterface { - /** - * {@inheritdoc} - */ public function process(ContainerBuilder $container): void { $container->getDefinition('twig')->addMethodCall('addGlobal', ['sonata_media', new Reference('sonata.media.twig.global')]); diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index e7f5c335a3..19781506fc 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -32,9 +32,6 @@ class Configuration implements ConfigurationInterface */ public const DB_DRIVERS = ['doctrine_orm', 'doctrine_mongodb', 'doctrine_phpcr', 'no_driver']; - /** - * {@inheritdoc} - */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder('sonata_media'); diff --git a/src/DependencyInjection/SonataMediaExtension.php b/src/DependencyInjection/SonataMediaExtension.php index c89f781759..aaac297efe 100644 --- a/src/DependencyInjection/SonataMediaExtension.php +++ b/src/DependencyInjection/SonataMediaExtension.php @@ -36,9 +36,6 @@ class SonataMediaExtension extends Extension implements PrependExtensionInterfac */ private $bundleConfigs; - /** - * {@inheritdoc} - */ public function load(array $configs, ContainerBuilder $container): void { $processor = new Processor(); diff --git a/src/Document/BaseMedia.php b/src/Document/BaseMedia.php index 4b86adea05..f6d23950f7 100644 --- a/src/Document/BaseMedia.php +++ b/src/Document/BaseMedia.php @@ -17,18 +17,12 @@ abstract class BaseMedia extends Media { - /** - * {@inheritdoc} - */ public function prePersist(): void { $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); } - /** - * {@inheritdoc} - */ public function preUpdate(): void { $this->updatedAt = new \DateTime(); diff --git a/src/Document/GalleryManager.php b/src/Document/GalleryManager.php index d8bf83995e..d87da8407d 100644 --- a/src/Document/GalleryManager.php +++ b/src/Document/GalleryManager.php @@ -34,9 +34,6 @@ public function update(GalleryInterface $gallery): void parent::save($gallery); } - /** - * {@inheritdoc} - */ public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void { throw new \RuntimeException('Not Implemented yet'); diff --git a/src/Document/MediaManager.php b/src/Document/MediaManager.php index 7799d0e2c2..b004e40cc2 100644 --- a/src/Document/MediaManager.php +++ b/src/Document/MediaManager.php @@ -20,9 +20,6 @@ */ class MediaManager extends BaseDocumentManager { - /** - * {@inheritdoc} - */ public function save($entity, $andFlush = true): void { // BC compatibility for $context parameter @@ -43,9 +40,6 @@ public function save($entity, $andFlush = true): void } } - /** - * {@inheritdoc} - */ public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void { throw new \RuntimeException('Not Implemented yet'); diff --git a/src/Entity/BaseGallery.php b/src/Entity/BaseGallery.php index 8cc9065b1d..2cc6a7f619 100644 --- a/src/Entity/BaseGallery.php +++ b/src/Entity/BaseGallery.php @@ -21,9 +21,6 @@ */ abstract class BaseGallery extends Gallery { - /** - * {@inheritdoc} - */ public function __construct() { $this->galleryItems = new ArrayCollection(); diff --git a/src/Entity/BaseMedia.php b/src/Entity/BaseMedia.php index ed27ecdcb2..82c83fc137 100644 --- a/src/Entity/BaseMedia.php +++ b/src/Entity/BaseMedia.php @@ -17,18 +17,12 @@ abstract class BaseMedia extends Media { - /** - * {@inheritdoc} - */ public function prePersist(): void { $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); } - /** - * {@inheritdoc} - */ public function preUpdate(): void { $this->updatedAt = new \DateTime(); diff --git a/src/Entity/GalleryManager.php b/src/Entity/GalleryManager.php index 4dd2ca3c21..3695047e55 100644 --- a/src/Entity/GalleryManager.php +++ b/src/Entity/GalleryManager.php @@ -36,9 +36,6 @@ public function update(GalleryInterface $gallery): void parent::save($gallery); } - /** - * {@inheritdoc} - */ public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { $query = $this->getRepository() diff --git a/src/Entity/MediaManager.php b/src/Entity/MediaManager.php index ade98b1587..b73a83b012 100644 --- a/src/Entity/MediaManager.php +++ b/src/Entity/MediaManager.php @@ -23,9 +23,6 @@ */ class MediaManager extends BaseEntityManager implements MediaManagerInterface { - /** - * {@inheritdoc} - */ public function save($media, $andFlush = true): void { /* @@ -50,9 +47,6 @@ public function save($media, $andFlush = true): void } } - /** - * {@inheritdoc} - */ public function getPager(array $criteria, $page, $limit = 10, array $sort = []) { $query = $this->getRepository() diff --git a/src/Extra/ApiMediaFile.php b/src/Extra/ApiMediaFile.php index 5608cd6bbe..7bef5c7892 100644 --- a/src/Extra/ApiMediaFile.php +++ b/src/Extra/ApiMediaFile.php @@ -35,9 +35,6 @@ class ApiMediaFile extends File */ protected $resource; - /** - * {@inheritdoc} - */ public function __construct($handle) { if (!\is_resource($handle)) { @@ -51,9 +48,6 @@ public function __construct($handle) parent::__construct($meta['uri']); } - /** - * {@inheritdoc} - */ public function getExtension() { return $this->extension ?: parent::getExtension(); @@ -67,9 +61,6 @@ public function setExtension($extension): void $this->extension = $extension; } - /** - * {@inheritdoc} - */ public function getMimetype() { return $this->mimetype ?: parent::getMimeType(); @@ -83,9 +74,6 @@ public function setMimetype($mimetype): void $this->mimetype = $mimetype; } - /** - * {@inheritdoc} - */ public function guessExtension() { return $this->extension ?: parent::guessExtension(); diff --git a/src/Filesystem/Replicate.php b/src/Filesystem/Replicate.php index 53935c1e2f..33bc31def2 100644 --- a/src/Filesystem/Replicate.php +++ b/src/Filesystem/Replicate.php @@ -48,9 +48,6 @@ public function __construct(AdapterInterface $master, AdapterInterface $slave, ? $this->logger = $logger; } - /** - * {@inheritdoc} - */ public function delete($key) { $ok = true; @@ -78,33 +75,21 @@ public function delete($key) return $ok; } - /** - * {@inheritdoc} - */ public function mtime($key) { return $this->master->mtime($key); } - /** - * {@inheritdoc} - */ public function keys() { return $this->master->keys(); } - /** - * {@inheritdoc} - */ public function exists($key) { return $this->master->exists($key); } - /** - * {@inheritdoc} - */ public function write($key, $content, ?array $metadata = null) { $ok = true; @@ -133,17 +118,11 @@ public function write($key, $content, ?array $metadata = null) return $ok && $return; } - /** - * {@inheritdoc} - */ public function read($key) { return $this->master->read($key); } - /** - * {@inheritdoc} - */ public function rename($key, $new) { $ok = true; @@ -181,9 +160,6 @@ public function supportsMetadata() return $this->master instanceof MetadataSupporter || $this->slave instanceof MetadataSupporter; } - /** - * {@inheritdoc} - */ public function setMetadata($key, $metadata): void { if ($this->master instanceof MetadataSupporter) { @@ -194,9 +170,6 @@ public function setMetadata($key, $metadata): void } } - /** - * {@inheritdoc} - */ public function getMetadata($key) { if ($this->master instanceof MetadataSupporter) { @@ -221,33 +194,21 @@ public function getAdapterClassNames() ]; } - /** - * {@inheritdoc} - */ public function createFile($key, Filesystem $filesystem) { return $this->master->createFile($key, $filesystem); } - /** - * {@inheritdoc} - */ public function createFileStream($key, Filesystem $filesystem) { return $this->master->createFileStream($key, $filesystem); } - /** - * {@inheritdoc} - */ public function listDirectory($directory = '') { return $this->master->listDirectory($directory); } - /** - * {@inheritdoc} - */ public function isDirectory($key) { return $this->master->isDirectory($key); diff --git a/src/Form/DataTransformer/ProviderDataTransformer.php b/src/Form/DataTransformer/ProviderDataTransformer.php index e114218073..b3937e723e 100644 --- a/src/Form/DataTransformer/ProviderDataTransformer.php +++ b/src/Form/DataTransformer/ProviderDataTransformer.php @@ -49,9 +49,6 @@ public function __construct(Pool $pool, $class, array $options = []) $this->logger = new NullLogger(); } - /** - * {@inheritdoc} - */ public function transform($value) { if (null === $value) { @@ -61,9 +58,6 @@ public function transform($value) return $value; } - /** - * {@inheritdoc} - */ public function reverseTransform($media) { if (!$media instanceof MediaInterface) { diff --git a/src/Form/DataTransformer/ServiceProviderDataTransformer.php b/src/Form/DataTransformer/ServiceProviderDataTransformer.php index cf4c076cfc..40851171e0 100644 --- a/src/Form/DataTransformer/ServiceProviderDataTransformer.php +++ b/src/Form/DataTransformer/ServiceProviderDataTransformer.php @@ -39,17 +39,11 @@ public function __construct(MediaProviderInterface $provider) $this->logger = new NullLogger(); } - /** - * {@inheritdoc} - */ public function transform($value) { return $value; } - /** - * {@inheritdoc} - */ public function reverseTransform($media) { if (!$media instanceof MediaInterface) { diff --git a/src/Form/Type/ApiMediaType.php b/src/Form/Type/ApiMediaType.php index e426fedbb8..7f0d27dd54 100644 --- a/src/Form/Type/ApiMediaType.php +++ b/src/Form/Type/ApiMediaType.php @@ -51,9 +51,6 @@ public function __construct(Pool $mediaPool, $class) $this->logger = new NullLogger(); } - /** - * {@inheritdoc} - */ public function buildForm(FormBuilderInterface $builder, array $options): void { $dataTransformer = new ProviderDataTransformer($this->mediaPool, $this->class, [ @@ -67,9 +64,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void $provider->buildMediaType($builder); } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $resolver->setDefaults([ @@ -78,17 +72,11 @@ public function configureOptions(OptionsResolver $resolver): void ]); } - /** - * {@inheritdoc} - */ public function getParent() { return ApiDoctrineMediaType::class; } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'sonata_media_api_form_media'; diff --git a/src/Form/Type/MediaType.php b/src/Form/Type/MediaType.php index bba795d00e..fcbd1ac6b0 100644 --- a/src/Form/Type/MediaType.php +++ b/src/Form/Type/MediaType.php @@ -55,9 +55,6 @@ public function __construct(Pool $pool, $class) $this->logger = new NullLogger(); } - /** - * {@inheritdoc} - */ public function buildForm(FormBuilderInterface $builder, array $options): void { $dataTransformer = new ProviderDataTransformer($this->pool, $this->class, [ @@ -86,18 +83,12 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]); } - /** - * {@inheritdoc} - */ public function buildView(FormView $view, FormInterface $form, array $options): void { $view->vars['provider'] = $options['provider']; $view->vars['context'] = $options['context']; } - /** - * {@inheritdoc} - */ public function configureOptions(OptionsResolver $resolver): void { $resolver @@ -114,17 +105,11 @@ public function configureOptions(OptionsResolver $resolver): void ->setAllowedValues('context', array_keys($this->pool->getContexts())); } - /** - * {@inheritdoc} - */ public function getParent() { return FormType::class; } - /** - * {@inheritdoc} - */ public function getBlockPrefix() { return 'sonata_media_type'; diff --git a/src/Listener/ODM/MediaEventSubscriber.php b/src/Listener/ODM/MediaEventSubscriber.php index d38d40320c..8c41836161 100644 --- a/src/Listener/ODM/MediaEventSubscriber.php +++ b/src/Listener/ODM/MediaEventSubscriber.php @@ -22,9 +22,6 @@ */ class MediaEventSubscriber extends BaseMediaEventSubscriber { - /** - * {@inheritdoc} - */ public function getSubscribedEvents() { return [ @@ -37,9 +34,6 @@ public function getSubscribedEvents() ]; } - /** - * {@inheritdoc} - */ protected function recomputeSingleEntityChangeSet(EventArgs $args): void { $em = $args->getDocumentManager(); diff --git a/src/Listener/ORM/MediaEventSubscriber.php b/src/Listener/ORM/MediaEventSubscriber.php index 966a27167e..ce40d9ba6d 100644 --- a/src/Listener/ORM/MediaEventSubscriber.php +++ b/src/Listener/ORM/MediaEventSubscriber.php @@ -29,9 +29,6 @@ class MediaEventSubscriber extends BaseMediaEventSubscriber */ protected $rootCategories; - /** - * {@inheritdoc} - */ public function getSubscribedEvents() { return [ @@ -50,9 +47,6 @@ public function onClear(): void $this->rootCategories = null; } - /** - * {@inheritdoc} - */ protected function recomputeSingleEntityChangeSet(EventArgs $args): void { $em = $args->getEntityManager(); @@ -63,9 +57,6 @@ protected function recomputeSingleEntityChangeSet(EventArgs $args): void ); } - /** - * {@inheritdoc} - */ protected function getMedia(EventArgs $args) { $media = $args->getEntity(); diff --git a/src/Listener/PHPCR/MediaEventSubscriber.php b/src/Listener/PHPCR/MediaEventSubscriber.php index 24e5bc3da4..862c696982 100644 --- a/src/Listener/PHPCR/MediaEventSubscriber.php +++ b/src/Listener/PHPCR/MediaEventSubscriber.php @@ -22,9 +22,6 @@ */ class MediaEventSubscriber extends BaseMediaEventSubscriber { - /** - * {@inheritdoc} - */ public function getSubscribedEvents() { return [ @@ -37,9 +34,6 @@ public function getSubscribedEvents() ]; } - /** - * {@inheritdoc} - */ protected function recomputeSingleEntityChangeSet(EventArgs $args): void { /* @var $args \Doctrine\Common\Persistence\Event\LifecycleEventArgs */ @@ -51,9 +45,6 @@ protected function recomputeSingleEntityChangeSet(EventArgs $args): void ); } - /** - * {@inheritdoc} - */ protected function getMedia(EventArgs $args) { return $args->getObject(); diff --git a/src/Metadata/AmazonMetadataBuilder.php b/src/Metadata/AmazonMetadataBuilder.php index a81ca572e9..b2bea5f425 100644 --- a/src/Metadata/AmazonMetadataBuilder.php +++ b/src/Metadata/AmazonMetadataBuilder.php @@ -54,9 +54,6 @@ public function __construct(array $settings) $this->settings = $settings; } - /** - * {@inheritdoc} - */ public function get(MediaInterface $media, $filename) { return array_replace_recursive( diff --git a/src/Metadata/NoopMetadataBuilder.php b/src/Metadata/NoopMetadataBuilder.php index 79152eda73..3c85c6f14b 100644 --- a/src/Metadata/NoopMetadataBuilder.php +++ b/src/Metadata/NoopMetadataBuilder.php @@ -20,9 +20,6 @@ */ class NoopMetadataBuilder implements MetadataBuilderInterface { - /** - * {@inheritdoc} - */ public function get(MediaInterface $media, $filename) { return []; diff --git a/src/Metadata/ProxyMetadataBuilder.php b/src/Metadata/ProxyMetadataBuilder.php index 5225391f0b..048dcc8ba3 100644 --- a/src/Metadata/ProxyMetadataBuilder.php +++ b/src/Metadata/ProxyMetadataBuilder.php @@ -46,9 +46,6 @@ public function __construct(ContainerInterface $container, ?array $map = null) } } - /** - * {@inheritdoc} - */ public function get(MediaInterface $media, $filename) { //get adapter for current media diff --git a/src/Model/CategoryManager.php b/src/Model/CategoryManager.php index 40698ef911..e2baa7e158 100644 --- a/src/Model/CategoryManager.php +++ b/src/Model/CategoryManager.php @@ -32,57 +32,36 @@ public function __construct(ManagerInterface $categoryManager) $this->categoryManager = $categoryManager; } - /** - * {@inheritdoc} - */ public function getRootCategory($context): CategoryInterface { return $this->categoryManager->getRootCategory($context); } - /** - * {@inheritdoc} - */ public function getRootCategories($loadChildren = true): iterable { return $this->categoryManager->getRootCategories($loadChildren); } - /** - * {@inheritdoc} - */ public function find($categoryId): ?CategoryInterface { return $this->categoryManager->find($categoryId); } - /** - * {@inheritdoc} - */ public function findBy(array $criteria): iterable { return $this->categoryManager->findBy($criteria); } - /** - * {@inheritdoc} - */ public function findOneBy(array $criteria): ?CategoryInterface { return $this->categoryManager->findOneBy($criteria); } - /** - * {@inheritdoc} - */ public function create(): CategoryInterface { return $this->categoryManager->create(); } - /** - * {@inheritdoc} - */ public function save($category): void { $this->categoryManager->save($category); diff --git a/src/Model/Gallery.php b/src/Model/Gallery.php index 949c0de78e..2ec6854b13 100644 --- a/src/Model/Gallery.php +++ b/src/Model/Gallery.php @@ -57,97 +57,61 @@ abstract class Gallery implements GalleryInterface, GalleryMediaCollectionInterf */ protected $galleryItems; - /** - * {@inheritdoc} - */ public function __toString() { return $this->getName() ?: '-'; } - /** - * {@inheritdoc} - */ public function setName($name): void { $this->name = $name; } - /** - * {@inheritdoc} - */ public function getName() { return $this->name; } - /** - * {@inheritdoc} - */ public function setEnabled($enabled): void { $this->enabled = $enabled; } - /** - * {@inheritdoc} - */ public function getEnabled() { return $this->enabled; } - /** - * {@inheritdoc} - */ public function setUpdatedAt(?\DateTime $updatedAt = null): void { $this->updatedAt = $updatedAt; } - /** - * {@inheritdoc} - */ public function getUpdatedAt() { return $this->updatedAt; } - /** - * {@inheritdoc} - */ public function setCreatedAt(?\DateTime $createdAt = null): void { $this->createdAt = $createdAt; } - /** - * {@inheritdoc} - */ public function getCreatedAt() { return $this->createdAt; } - /** - * {@inheritdoc} - */ public function setDefaultFormat($defaultFormat): void { $this->defaultFormat = $defaultFormat; } - /** - * {@inheritdoc} - */ public function getDefaultFormat() { return $this->defaultFormat; } - /** - * {@inheritdoc} - */ public function setGalleryItems($galleryItems): void { $this->galleryItems = new ArrayCollection(); @@ -157,17 +121,11 @@ public function setGalleryItems($galleryItems): void } } - /** - * {@inheritdoc} - */ public function getGalleryItems() { return $this->galleryItems; } - /** - * {@inheritdoc} - */ public function addGalleryItem(GalleryItemInterface $galleryItem): void { $galleryItem->setGallery($this); @@ -175,17 +133,11 @@ public function addGalleryItem(GalleryItemInterface $galleryItem): void $this->galleryItems[] = $galleryItem; } - /** - * {@inheritdoc} - */ public function setContext($context): void { $this->context = $context; } - /** - * {@inheritdoc} - */ public function getContext() { return $this->context; diff --git a/src/Model/GalleryItem.php b/src/Model/GalleryItem.php index 69ca1ed47e..f7c348e738 100644 --- a/src/Model/GalleryItem.php +++ b/src/Model/GalleryItem.php @@ -45,105 +45,66 @@ abstract class GalleryItem implements GalleryItemInterface */ protected $enabled = false; - /** - * {@inheritdoc} - */ public function __toString() { return $this->getGallery().' | '.$this->getMedia(); } - /** - * {@inheritdoc} - */ public function setCreatedAt(?\DateTime $createdAt = null): void { $this->createdAt = $createdAt; } - /** - * {@inheritdoc} - */ public function getCreatedAt() { return $this->createdAt; } - /** - * {@inheritdoc} - */ public function setEnabled($enabled): void { $this->enabled = $enabled; } - /** - * {@inheritdoc} - */ public function getEnabled() { return $this->enabled; } - /** - * {@inheritdoc} - */ public function setGallery(?GalleryInterface $gallery = null): void { $this->gallery = $gallery; } - /** - * {@inheritdoc} - */ public function getGallery() { return $this->gallery; } - /** - * {@inheritdoc} - */ public function setMedia(?MediaInterface $media = null): void { $this->media = $media; } - /** - * {@inheritdoc} - */ public function getMedia() { return $this->media; } - /** - * {@inheritdoc} - */ public function setPosition($position): void { $this->position = $position; } - /** - * {@inheritdoc} - */ public function getPosition() { return $this->position; } - /** - * {@inheritdoc} - */ public function setUpdatedAt(?\DateTime $updatedAt = null): void { $this->updatedAt = $updatedAt; } - /** - * {@inheritdoc} - */ public function getUpdatedAt() { return $this->updatedAt; diff --git a/src/Model/GalleryManager.php b/src/Model/GalleryManager.php index 8ad6f7933b..a8bd7d03a7 100644 --- a/src/Model/GalleryManager.php +++ b/src/Model/GalleryManager.php @@ -15,9 +15,6 @@ abstract class GalleryManager implements GalleryManagerInterface { - /** - * {@inheritdoc} - */ public function create() { $class = $this->getClass(); diff --git a/src/Model/Media.php b/src/Model/Media.php index a0b8f16caf..3aea028d99 100644 --- a/src/Model/Media.php +++ b/src/Model/Media.php @@ -144,9 +144,6 @@ abstract class Media implements MediaInterface */ protected $category; - /** - * {@inheritdoc} - */ public function __toString() { return $this->getName() ?: 'n/a'; @@ -179,9 +176,6 @@ public static function getStatusList() ]; } - /** - * {@inheritdoc} - */ public function setBinaryContent($binaryContent): void { $this->previousProviderReference = $this->providerReference; @@ -189,25 +183,16 @@ public function setBinaryContent($binaryContent): void $this->binaryContent = $binaryContent; } - /** - * {@inheritdoc} - */ public function resetBinaryContent(): void { $this->binaryContent = null; } - /** - * {@inheritdoc} - */ public function getBinaryContent() { return $this->binaryContent; } - /** - * {@inheritdoc} - */ public function getMetadataValue($name, $default = null) { $metadata = $this->getProviderMetadata(); @@ -215,9 +200,6 @@ public function getMetadataValue($name, $default = null) return $metadata[$name] ?? $default; } - /** - * {@inheritdoc} - */ public function setMetadataValue($name, $value): void { $metadata = $this->getProviderMetadata(); @@ -225,9 +207,6 @@ public function setMetadataValue($name, $value): void $this->setProviderMetadata($metadata); } - /** - * {@inheritdoc} - */ public function unsetMetadataValue($name): void { $metadata = $this->getProviderMetadata(); @@ -235,313 +214,196 @@ public function unsetMetadataValue($name): void $this->setProviderMetadata($metadata); } - /** - * {@inheritdoc} - */ public function setName($name): void { $this->name = $name; } - /** - * {@inheritdoc} - */ public function getName() { return $this->name; } - /** - * {@inheritdoc} - */ public function setDescription($description): void { $this->description = $description; } - /** - * {@inheritdoc} - */ public function getDescription() { return $this->description; } - /** - * {@inheritdoc} - */ public function setEnabled($enabled): void { $this->enabled = $enabled; } - /** - * {@inheritdoc} - */ public function getEnabled() { return $this->enabled; } - /** - * {@inheritdoc} - */ public function setProviderName($providerName): void { $this->providerName = $providerName; } - /** - * {@inheritdoc} - */ public function getProviderName() { return $this->providerName; } - /** - * {@inheritdoc} - */ public function setProviderStatus($providerStatus): void { $this->providerStatus = $providerStatus; } - /** - * {@inheritdoc} - */ public function getProviderStatus() { return $this->providerStatus; } - /** - * {@inheritdoc} - */ public function setProviderReference($providerReference): void { $this->providerReference = $providerReference; } - /** - * {@inheritdoc} - */ public function getProviderReference() { return $this->providerReference; } - /** - * {@inheritdoc} - */ public function setProviderMetadata(array $providerMetadata = []): void { $this->providerMetadata = $providerMetadata; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return $this->providerMetadata; } - /** - * {@inheritdoc} - */ public function setWidth($width): void { $this->width = $width; } - /** - * {@inheritdoc} - */ public function getWidth() { return $this->width; } - /** - * {@inheritdoc} - */ public function setHeight($height): void { $this->height = $height; } - /** - * {@inheritdoc} - */ public function getHeight() { return $this->height; } - /** - * {@inheritdoc} - */ public function setLength($length): void { $this->length = $length; } - /** - * {@inheritdoc} - */ public function getLength() { return $this->length; } - /** - * {@inheritdoc} - */ public function setCopyright($copyright): void { $this->copyright = $copyright; } - /** - * {@inheritdoc} - */ public function getCopyright() { return $this->copyright; } - /** - * {@inheritdoc} - */ public function setAuthorName($authorName): void { $this->authorName = $authorName; } - /** - * {@inheritdoc} - */ public function getAuthorName() { return $this->authorName; } - /** - * {@inheritdoc} - */ public function setContext($context): void { $this->context = $context; } - /** - * {@inheritdoc} - */ public function getContext() { return $this->context; } - /** - * {@inheritdoc} - */ public function setCdnIsFlushable($cdnIsFlushable): void { $this->cdnIsFlushable = $cdnIsFlushable; } - /** - * {@inheritdoc} - */ public function getCdnIsFlushable() { return $this->cdnIsFlushable; } - /** - * {@inheritdoc} - */ public function setCdnFlushIdentifier($cdnFlushIdentifier): void { $this->cdnFlushIdentifier = $cdnFlushIdentifier; } - /** - * {@inheritdoc} - */ public function getCdnFlushIdentifier() { return $this->cdnFlushIdentifier; } - /** - * {@inheritdoc} - */ public function setCdnFlushAt(?\DateTime $cdnFlushAt = null): void { $this->cdnFlushAt = $cdnFlushAt; } - /** - * {@inheritdoc} - */ public function getCdnFlushAt() { return $this->cdnFlushAt; } - /** - * {@inheritdoc} - */ public function setUpdatedAt(?\DateTime $updatedAt = null): void { $this->updatedAt = $updatedAt; } - /** - * {@inheritdoc} - */ public function getUpdatedAt() { return $this->updatedAt; } - /** - * {@inheritdoc} - */ public function setCreatedAt(?\DateTime $createdAt = null): void { $this->createdAt = $createdAt; } - /** - * {@inheritdoc} - */ public function getCreatedAt() { return $this->createdAt; } - /** - * {@inheritdoc} - */ public function setContentType($contentType): void { $this->contentType = $contentType; } - /** - * {@inheritdoc} - */ public function getContentType() { return $this->contentType; } - /** - * {@inheritdoc} - */ public function getExtension() { $providerReference = $this->getProviderReference(); @@ -553,65 +415,41 @@ public function getExtension() return preg_replace('{(\?|#).*}', '', pathinfo($providerReference, PATHINFO_EXTENSION)); } - /** - * {@inheritdoc} - */ public function setSize($size): void { $this->size = $size; } - /** - * {@inheritdoc} - */ public function getSize() { return $this->size; } - /** - * {@inheritdoc} - */ public function setCdnStatus($cdnStatus): void { $this->cdnStatus = $cdnStatus; } - /** - * {@inheritdoc} - */ public function getCdnStatus() { return $this->cdnStatus; } - /** - * {@inheritdoc} - */ public function getBox() { return new Box($this->width, $this->height); } - /** - * {@inheritdoc} - */ public function setGalleryItems($galleryItems): void { $this->galleryItems = $galleryItems; } - /** - * {@inheritdoc} - */ public function getGalleryItems() { return $this->galleryItems; } - /** - * {@inheritdoc} - */ public function getPreviousProviderReference() { return $this->previousProviderReference; diff --git a/src/PHPCR/BaseGallery.php b/src/PHPCR/BaseGallery.php index 02db216cb9..c639192f04 100644 --- a/src/PHPCR/BaseGallery.php +++ b/src/PHPCR/BaseGallery.php @@ -27,9 +27,6 @@ abstract class BaseGallery extends Gallery */ private $uuid; - /** - * {@inheritdoc} - */ public function __construct() { $this->galleryItems = new ArrayCollection(); @@ -45,9 +42,6 @@ public function getUuid() return $this->uuid; } - /** - * {@inheritdoc} - */ public function addGalleryItem(GalleryItemInterface $galleryItem): void { $galleryItem->setGallery($this); diff --git a/src/PHPCR/BaseMedia.php b/src/PHPCR/BaseMedia.php index d6600104c6..4a8f1e4e08 100644 --- a/src/PHPCR/BaseMedia.php +++ b/src/PHPCR/BaseMedia.php @@ -32,18 +32,12 @@ public function getUuid() return $this->uuid; } - /** - * {@inheritdoc} - */ public function prePersist(): void { $this->createdAt = new \DateTime(); $this->updatedAt = new \DateTime(); } - /** - * {@inheritdoc} - */ public function preUpdate(): void { $this->updatedAt = new \DateTime(); diff --git a/src/PHPCR/GalleryManager.php b/src/PHPCR/GalleryManager.php index aea6ebb898..66fe7580c2 100644 --- a/src/PHPCR/GalleryManager.php +++ b/src/PHPCR/GalleryManager.php @@ -34,9 +34,6 @@ public function update(GalleryInterface $gallery): void parent::save($gallery); } - /** - * {@inheritdoc} - */ public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void { throw new \RuntimeException('Not Implemented yet'); diff --git a/src/PHPCR/MediaManager.php b/src/PHPCR/MediaManager.php index 81c41f50a7..01fde4f780 100644 --- a/src/PHPCR/MediaManager.php +++ b/src/PHPCR/MediaManager.php @@ -20,9 +20,6 @@ */ class MediaManager extends BasePHPCRManager { - /** - * {@inheritdoc} - */ public function save($entity, $andFlush = true): void { // BC compatibility for $context parameter @@ -43,9 +40,6 @@ public function save($entity, $andFlush = true): void } } - /** - * {@inheritdoc} - */ public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void { throw new \RuntimeException('Not Implemented yet'); diff --git a/src/Provider/BaseProvider.php b/src/Provider/BaseProvider.php index 61a56250c1..4dfbdb5740 100644 --- a/src/Provider/BaseProvider.php +++ b/src/Provider/BaseProvider.php @@ -80,9 +80,6 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge $this->thumbnail = $thumbnail; } - /** - * {@inheritdoc} - */ final public function transform(MediaInterface $media): void { if (null === $media->getBinaryContent()) { @@ -112,49 +109,31 @@ public function flushCdn(MediaInterface $media): void } } - /** - * {@inheritdoc} - */ public function addFormat($name, $format): void { $this->formats[$name] = $format; } - /** - * {@inheritdoc} - */ public function getFormat($name) { return isset($this->formats[$name]) ? $this->formats[$name] : false; } - /** - * {@inheritdoc} - */ public function requireThumbnails() { return null !== $this->getResizer(); } - /** - * {@inheritdoc} - */ public function generateThumbnails(MediaInterface $media): void { $this->thumbnail->generate($this, $media); } - /** - * {@inheritdoc} - */ public function removeThumbnails(MediaInterface $media, $formats = null): void { $this->thumbnail->delete($this, $media, $formats); } - /** - * {@inheritdoc} - */ public function getFormatName(MediaInterface $media, $format) { if (MediaProviderInterface::FORMAT_ADMIN === $format) { @@ -173,17 +152,11 @@ public function getFormatName(MediaInterface $media, $format) return $baseName.$format; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return new Metadata($this->getName(), $this->getName().'.description', null, 'SonataMediaBundle', ['class' => 'fa fa-file']); } - /** - * {@inheritdoc} - */ public function preRemove(MediaInterface $media): void { $hash = spl_object_hash($media); @@ -194,9 +167,6 @@ public function preRemove(MediaInterface $media): void } } - /** - * {@inheritdoc} - */ public function postRemove(MediaInterface $media): void { $hash = spl_object_hash($media); @@ -213,122 +183,77 @@ public function postRemove(MediaInterface $media): void } } - /** - * {@inheritdoc} - */ public function generatePath(MediaInterface $media) { return $this->pathGenerator->generatePath($media); } - /** - * {@inheritdoc} - */ public function getFormats() { return $this->formats; } - /** - * {@inheritdoc} - */ public function setName($name): void { $this->name = $name; } - /** - * {@inheritdoc} - */ public function getName() { return $this->name; } - /** - * {@inheritdoc} - */ public function setTemplates(array $templates): void { $this->templates = $templates; } - /** - * {@inheritdoc} - */ public function getTemplates() { return $this->templates; } - /** - * {@inheritdoc} - */ public function getTemplate($name) { return isset($this->templates[$name]) ? $this->templates[$name] : null; } - /** - * {@inheritdoc} - */ public function getResizer() { return $this->resizer; } - /** - * {@inheritdoc} - */ public function getFilesystem() { return $this->filesystem; } - /** - * {@inheritdoc} - */ public function getCdn() { return $this->cdn; } - /** - * {@inheritdoc} - */ public function getCdnPath($relativePath, $isFlushable) { return $this->getCdn()->getPath($relativePath, $isFlushable); } - /** - * {@inheritdoc} - */ public function setResizer(ResizerInterface $resizer): void { $this->resizer = $resizer; } - /** - * {@inheritdoc} - */ public function prePersist(MediaInterface $media): void { $media->setCreatedAt(new \DateTime()); $media->setUpdatedAt(new \DateTime()); } - /** - * {@inheritdoc} - */ public function preUpdate(MediaInterface $media): void { $media->setUpdatedAt(new \DateTime()); } - /** - * {@inheritdoc} - */ public function validate(ErrorElement $errorElement, MediaInterface $media): void { } diff --git a/src/Provider/BaseVideoProvider.php b/src/Provider/BaseVideoProvider.php index 34434c2fab..25edd05493 100644 --- a/src/Provider/BaseVideoProvider.php +++ b/src/Provider/BaseVideoProvider.php @@ -55,25 +55,16 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge $this->metadata = $metadata; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return new Metadata($this->getName(), $this->getName().'.description', null, 'SonataMediaBundle', ['class' => 'fa fa-video-camera']); } - /** - * {@inheritdoc} - */ public function getReferenceImage(MediaInterface $media) { return $media->getMetadataValue('thumbnail_url'); } - /** - * {@inheritdoc} - */ public function getReferenceFile(MediaInterface $media) { $key = $this->generatePrivateUrl($media, MediaProviderInterface::FORMAT_REFERENCE); @@ -90,9 +81,6 @@ public function getReferenceFile(MediaInterface $media) return $referenceFile; } - /** - * {@inheritdoc} - */ public function generatePublicUrl(MediaInterface $media, $format) { return $this->getCdn()->getPath(sprintf( @@ -103,9 +91,6 @@ public function generatePublicUrl(MediaInterface $media, $format) ), $media->getCdnIsFlushable()); } - /** - * {@inheritdoc} - */ public function generatePrivateUrl(MediaInterface $media, $format) { return sprintf( @@ -116,9 +101,6 @@ public function generatePrivateUrl(MediaInterface $media, $format) ); } - /** - * {@inheritdoc} - */ public function buildEditForm(FormMapper $formMapper): void { $formMapper->add('name'); @@ -130,9 +112,6 @@ public function buildEditForm(FormMapper $formMapper): void $formMapper->add('binaryContent', TextType::class, ['required' => false]); } - /** - * {@inheritdoc} - */ public function buildCreateForm(FormMapper $formMapper): void { $formMapper->add('binaryContent', TextType::class, [ @@ -143,9 +122,6 @@ public function buildCreateForm(FormMapper $formMapper): void ]); } - /** - * {@inheritdoc} - */ public function buildMediaType(FormBuilder $formBuilder): void { $formBuilder->add('binaryContent', TextType::class, [ @@ -153,17 +129,11 @@ public function buildMediaType(FormBuilder $formBuilder): void ]); } - /** - * {@inheritdoc} - */ public function postUpdate(MediaInterface $media): void { $this->postPersist($media); } - /** - * {@inheritdoc} - */ public function postPersist(MediaInterface $media): void { if (!$media->getBinaryContent()) { @@ -175,9 +145,6 @@ public function postPersist(MediaInterface $media): void $media->resetBinaryContent(); } - /** - * {@inheritdoc} - */ public function postRemove(MediaInterface $media): void { } diff --git a/src/Provider/DailyMotionProvider.php b/src/Provider/DailyMotionProvider.php index edf11e8a99..b2776ee53c 100644 --- a/src/Provider/DailyMotionProvider.php +++ b/src/Provider/DailyMotionProvider.php @@ -21,9 +21,6 @@ */ class DailyMotionProvider extends BaseVideoProvider { - /** - * {@inheritdoc} - */ public function getHelperProperties(MediaInterface $media, $format, $options = []) { // documentation : http://www.dailymotion.com/en/doc/api/player @@ -89,17 +86,11 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ return $params; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return new Metadata($this->getName(), $this->getName().'.description', 'bundles/sonatamedia/dailymotion-icon.png', 'SonataMediaBundle'); } - /** - * {@inheritdoc} - */ public function updateMetadata(MediaInterface $media, $force = false): void { $url = sprintf('http://www.dailymotion.com/services/oembed?url=%s&format=json', $this->getReferenceUrl($media)); @@ -124,9 +115,6 @@ public function updateMetadata(MediaInterface $media, $force = false): void $media->setWidth($metadata['width']); } - /** - * {@inheritdoc} - */ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { return new RedirectResponse($this->getReferenceUrl($media), 302, $headers); @@ -153,9 +141,6 @@ protected function fixBinaryContent(MediaInterface $media): void } } - /** - * {@inheritdoc} - */ protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); diff --git a/src/Provider/FileProvider.php b/src/Provider/FileProvider.php index 439ae42259..7244dad0f4 100644 --- a/src/Provider/FileProvider.php +++ b/src/Provider/FileProvider.php @@ -59,9 +59,6 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge $this->metadata = $metadata; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return new Metadata( @@ -73,9 +70,6 @@ public function getProviderMetadata() ); } - /** - * {@inheritdoc} - */ public function getReferenceImage(MediaInterface $media) { return sprintf( @@ -85,9 +79,6 @@ public function getReferenceImage(MediaInterface $media) ); } - /** - * {@inheritdoc} - */ public function getReferenceFile(MediaInterface $media) { return $this->getFilesystem()->get($this->getReferenceImage($media), true); @@ -109,9 +100,6 @@ public function getAllowedMimeTypes() return $this->allowedMimeTypes; } - /** - * {@inheritdoc} - */ public function buildEditForm(FormMapper $formMapper): void { $formMapper->add('name'); @@ -123,9 +111,6 @@ public function buildEditForm(FormMapper $formMapper): void $formMapper->add('binaryContent', FileType::class, ['required' => false]); } - /** - * {@inheritdoc} - */ public function buildCreateForm(FormMapper $formMapper): void { $formMapper->add('binaryContent', FileType::class, [ @@ -136,9 +121,6 @@ public function buildCreateForm(FormMapper $formMapper): void ]); } - /** - * {@inheritdoc} - */ public function buildMediaType(FormBuilder $formBuilder): void { if ('api' === $formBuilder->getOption('context')) { @@ -152,9 +134,6 @@ public function buildMediaType(FormBuilder $formBuilder): void } } - /** - * {@inheritdoc} - */ public function postPersist(MediaInterface $media): void { if (null === $media->getBinaryContent()) { @@ -168,9 +147,6 @@ public function postPersist(MediaInterface $media): void $media->resetBinaryContent(); } - /** - * {@inheritdoc} - */ public function postUpdate(MediaInterface $media): void { if (!$media->getBinaryContent() instanceof \SplFileInfo) { @@ -200,9 +176,6 @@ public function postUpdate(MediaInterface $media): void $media->resetBinaryContent(); } - /** - * {@inheritdoc} - */ public function updateMetadata(MediaInterface $media, $force = true): void { if (!$media->getBinaryContent() instanceof \SplFileInfo) { @@ -217,9 +190,6 @@ public function updateMetadata(MediaInterface $media, $force = true): void $media->setSize($fileObject->getSize()); } - /** - * {@inheritdoc} - */ public function generatePublicUrl(MediaInterface $media, $format) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { @@ -232,9 +202,6 @@ public function generatePublicUrl(MediaInterface $media, $format) return $this->getCdn()->getPath($path, $media->getCdnIsFlushable()); } - /** - * {@inheritdoc} - */ public function getHelperProperties(MediaInterface $media, $format, $options = []) { return array_merge([ @@ -244,9 +211,6 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ ], $options); } - /** - * {@inheritdoc} - */ public function generatePrivateUrl(MediaInterface $media, $format) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { @@ -256,9 +220,6 @@ public function generatePrivateUrl(MediaInterface $media, $format) return false; } - /** - * {@inheritdoc} - */ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { // build the default headers @@ -296,9 +257,6 @@ public function getDownloadResponse(MediaInterface $media, $format, $mode, array return new BinaryFileResponse($filename, 200, $headers); } - /** - * {@inheritdoc} - */ public function validate(ErrorElement $errorElement, MediaInterface $media): void { if (!$media->getBinaryContent() instanceof \SplFileInfo) { @@ -379,9 +337,6 @@ protected function fixFilename(MediaInterface $media): void } } - /** - * {@inheritdoc} - */ protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); diff --git a/src/Provider/ImageProvider.php b/src/Provider/ImageProvider.php index 559396c7d9..5b9c76c874 100644 --- a/src/Provider/ImageProvider.php +++ b/src/Provider/ImageProvider.php @@ -44,9 +44,6 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge $this->imagineAdapter = $adapter; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return new Metadata( @@ -58,9 +55,6 @@ public function getProviderMetadata() ); } - /** - * {@inheritdoc} - */ public function getHelperProperties(MediaInterface $media, $format, $options = []) { if (isset($options['srcset'], $options['picture'])) { @@ -150,9 +144,6 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ return array_merge($params, $options); } - /** - * {@inheritdoc} - */ public function updateMetadata(MediaInterface $media, $force = true): void { try { @@ -180,9 +171,6 @@ public function updateMetadata(MediaInterface $media, $force = true): void } } - /** - * {@inheritdoc} - */ public function generatePublicUrl(MediaInterface $media, $format) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { @@ -199,9 +187,6 @@ public function generatePublicUrl(MediaInterface $media, $format) return $this->getCdn()->getPath($path, $media->getCdnIsFlushable()); } - /** - * {@inheritdoc} - */ public function generatePrivateUrl(MediaInterface $media, $format) { return $this->thumbnail->generatePrivateUrl($this, $media, $format); @@ -217,9 +202,6 @@ public function getFormatsForContext(string $context): array }, ARRAY_FILTER_USE_KEY); } - /** - * {@inheritdoc} - */ protected function doTransform(MediaInterface $media): void { parent::doTransform($media); diff --git a/src/Provider/VimeoProvider.php b/src/Provider/VimeoProvider.php index e95a6c04d5..f521e63e66 100644 --- a/src/Provider/VimeoProvider.php +++ b/src/Provider/VimeoProvider.php @@ -21,9 +21,6 @@ */ class VimeoProvider extends BaseVideoProvider { - /** - * {@inheritdoc} - */ public function getHelperProperties(MediaInterface $media, $format, $options = []) { // documentation : http://vimeo.com/api/docs/moogaloop @@ -77,9 +74,6 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ return $params; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return new Metadata( @@ -91,9 +85,6 @@ public function getProviderMetadata() ); } - /** - * {@inheritdoc} - */ public function updateMetadata(MediaInterface $media, $force = false): void { $url = sprintf('https://vimeo.com/api/oembed.json?url=%s', $this->getReferenceUrl($media)); @@ -123,9 +114,6 @@ public function updateMetadata(MediaInterface $media, $force = false): void $media->setContentType('video/x-flv'); } - /** - * {@inheritdoc} - */ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { return new RedirectResponse($this->getReferenceUrl($media), 302, $headers); @@ -152,9 +140,6 @@ protected function fixBinaryContent(MediaInterface $media): void } } - /** - * {@inheritdoc} - */ protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); diff --git a/src/Provider/YouTubeProvider.php b/src/Provider/YouTubeProvider.php index 07143d9f32..29e987e349 100644 --- a/src/Provider/YouTubeProvider.php +++ b/src/Provider/YouTubeProvider.php @@ -43,9 +43,6 @@ public function __construct($name, Filesystem $filesystem, CDNInterface $cdn, Ge $this->html5 = $html5; } - /** - * {@inheritdoc} - */ public function getProviderMetadata() { return new Metadata( @@ -57,9 +54,6 @@ public function getProviderMetadata() ); } - /** - * {@inheritdoc} - */ public function getHelperProperties(MediaInterface $media, $format, $options = []) { // Override html5 value if $options['html5'] is a boolean @@ -202,9 +196,6 @@ public function getHelperProperties(MediaInterface $media, $format, $options = [ return $params; } - /** - * {@inheritdoc} - */ public function updateMetadata(MediaInterface $media, $force = false): void { $url = sprintf('https://www.youtube.com/oembed?url=%s&format=json', $this->getReferenceUrl($media)); @@ -230,9 +221,6 @@ public function updateMetadata(MediaInterface $media, $force = false): void $media->setContentType('video/x-flv'); } - /** - * {@inheritdoc} - */ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []) { return new RedirectResponse($this->getReferenceUrl($media), 302, $headers); @@ -263,9 +251,6 @@ protected function fixBinaryContent(MediaInterface $media): void } } - /** - * {@inheritdoc} - */ protected function doTransform(MediaInterface $media): void { $this->fixBinaryContent($media); diff --git a/src/Resizer/SimpleResizer.php b/src/Resizer/SimpleResizer.php index f9e2515f79..dcfcbdcbbe 100644 --- a/src/Resizer/SimpleResizer.php +++ b/src/Resizer/SimpleResizer.php @@ -53,9 +53,6 @@ public function __construct(ImagineInterface $adapter, $mode, MetadataBuilderInt $this->metadata = $metadata; } - /** - * {@inheritdoc} - */ public function resize(MediaInterface $media, File $in, File $out, $format, array $settings): void { if (!isset($settings['width']) && !isset($settings['height'])) { @@ -71,9 +68,6 @@ public function resize(MediaInterface $media, File $in, File $out, $format, arra $out->setContent($content, $this->metadata->get($media, $out->getName())); } - /** - * {@inheritdoc} - */ public function getBox(MediaInterface $media, array $settings) { $size = $media->getBox(); diff --git a/src/Resizer/SquareResizer.php b/src/Resizer/SquareResizer.php index 2aa61cc092..72c06a17e4 100755 --- a/src/Resizer/SquareResizer.php +++ b/src/Resizer/SquareResizer.php @@ -59,25 +59,16 @@ public function __construct(ImagineInterface $adapter, $mode, MetadataBuilderInt $this->metadata = $metadata; } - /** - * {@inheritdoc} - */ public function getAdapter() { return $this->adapter; } - /** - * {@inheritdoc} - */ public function setAdapter(ImagineInterface $adapter): void { $this->adapter = $adapter; } - /** - * {@inheritdoc} - */ public function resize(MediaInterface $media, File $in, File $out, $format, array $settings): void { if (!isset($settings['width'])) { @@ -118,9 +109,6 @@ public function resize(MediaInterface $media, File $in, File $out, $format, arra $out->setContent($content, $this->metadata->get($media, $out->getName())); } - /** - * {@inheritdoc} - */ public function getBox(MediaInterface $media, array $settings) { $size = $media->getBox(); diff --git a/src/Security/ForbiddenDownloadStrategy.php b/src/Security/ForbiddenDownloadStrategy.php index dd201ceb4d..e70fa6d288 100644 --- a/src/Security/ForbiddenDownloadStrategy.php +++ b/src/Security/ForbiddenDownloadStrategy.php @@ -32,17 +32,11 @@ public function __construct(TranslatorInterface $translator) $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function isGranted(MediaInterface $media, Request $request) { return false; } - /** - * {@inheritdoc} - */ public function getDescription() { return $this->translator->trans('description.forbidden_download_strategy', [], 'SonataMediaBundle'); diff --git a/src/Security/PublicDownloadStrategy.php b/src/Security/PublicDownloadStrategy.php index 2a154d1efb..3ac7ae5fbe 100644 --- a/src/Security/PublicDownloadStrategy.php +++ b/src/Security/PublicDownloadStrategy.php @@ -32,17 +32,11 @@ public function __construct(TranslatorInterface $translator) $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function isGranted(MediaInterface $media, Request $request) { return true; } - /** - * {@inheritdoc} - */ public function getDescription() { return $this->translator->trans('description.public_download_strategy', [], 'SonataMediaBundle'); diff --git a/src/Security/RolesDownloadStrategy.php b/src/Security/RolesDownloadStrategy.php index 1090b8bcf5..c497153479 100644 --- a/src/Security/RolesDownloadStrategy.php +++ b/src/Security/RolesDownloadStrategy.php @@ -49,9 +49,6 @@ public function __construct(TranslatorInterface $translator, AuthorizationChecke $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function isGranted(MediaInterface $media, Request $request) { try { @@ -62,9 +59,6 @@ public function isGranted(MediaInterface $media, Request $request) } } - /** - * {@inheritdoc} - */ public function getDescription() { return $this->translator->trans('description.roles_download_strategy', ['%roles%' => ''.implode(', ', $this->roles).''], 'SonataMediaBundle'); diff --git a/src/Security/SessionDownloadStrategy.php b/src/Security/SessionDownloadStrategy.php index cf789a1aa6..bca57528a6 100644 --- a/src/Security/SessionDownloadStrategy.php +++ b/src/Security/SessionDownloadStrategy.php @@ -55,9 +55,6 @@ public function __construct(TranslatorInterface $translator, SessionInterface $s $this->translator = $translator; } - /** - * {@inheritdoc} - */ public function isGranted(MediaInterface $media, Request $request) { $times = $this->session->get($this->sessionKey, 0); @@ -73,9 +70,6 @@ public function isGranted(MediaInterface $media, Request $request) return true; } - /** - * {@inheritdoc} - */ public function getDescription() { return $this->translator->transChoice( diff --git a/src/Serializer/GallerySerializerHandler.php b/src/Serializer/GallerySerializerHandler.php index 71754298dc..2ad92c75c7 100644 --- a/src/Serializer/GallerySerializerHandler.php +++ b/src/Serializer/GallerySerializerHandler.php @@ -22,9 +22,6 @@ */ class GallerySerializerHandler extends BaseSerializerHandler { - /** - * {@inheritdoc} - */ public static function getType() { return 'sonata_media_gallery_id'; diff --git a/src/Serializer/MediaSerializerHandler.php b/src/Serializer/MediaSerializerHandler.php index 33d782b878..6f283d8484 100644 --- a/src/Serializer/MediaSerializerHandler.php +++ b/src/Serializer/MediaSerializerHandler.php @@ -22,9 +22,6 @@ */ class MediaSerializerHandler extends BaseSerializerHandler { - /** - * {@inheritdoc} - */ public static function getType() { return 'sonata_media_media_id'; diff --git a/src/Templating/Helper/MediaHelper.php b/src/Templating/Helper/MediaHelper.php index 7c4351a235..61f75d4a4e 100644 --- a/src/Templating/Helper/MediaHelper.php +++ b/src/Templating/Helper/MediaHelper.php @@ -45,9 +45,6 @@ public function __construct(Pool $pool, EngineInterface $templating) $this->templating = $templating; } - /** - * {@inheritdoc} - */ public function getName() { return 'sonata_media'; diff --git a/src/Thumbnail/ConsumerThumbnail.php b/src/Thumbnail/ConsumerThumbnail.php index e8fd5b1126..89ce1decd9 100644 --- a/src/Thumbnail/ConsumerThumbnail.php +++ b/src/Thumbnail/ConsumerThumbnail.php @@ -68,25 +68,16 @@ public function __construct($id, ThumbnailInterface $thumbnail, BackendInterface $this->dispatcher = $dispatcher; } - /** - * {@inheritdoc} - */ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterface $media, $format) { return $this->thumbnail->generatePrivateUrl($provider, $media, $format); } - /** - * {@inheritdoc} - */ public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterface $media, $format) { return $this->thumbnail->generatePrivateUrl($provider, $media, $format); } - /** - * {@inheritdoc} - */ public function generate(MediaProviderInterface $provider, MediaInterface $media): void { $backend = $this->backend; @@ -114,9 +105,6 @@ public function generate(MediaProviderInterface $provider, MediaInterface $media } } - /** - * {@inheritdoc} - */ public function delete(MediaProviderInterface $provider, MediaInterface $media, $formats = null) { return $this->thumbnail->delete($provider, $media, $formats); diff --git a/src/Thumbnail/FormatThumbnail.php b/src/Thumbnail/FormatThumbnail.php index a520fe07d5..d0ee3a7c57 100644 --- a/src/Thumbnail/FormatThumbnail.php +++ b/src/Thumbnail/FormatThumbnail.php @@ -66,9 +66,6 @@ public function getResizer($id) return $this->resizers[$id]; } - /** - * {@inheritdoc} - */ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterface $media, $format) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { @@ -80,9 +77,6 @@ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterfa return $path; } - /** - * {@inheritdoc} - */ public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterface $media, $format) { if (MediaProviderInterface::FORMAT_REFERENCE === $format) { @@ -98,9 +92,6 @@ public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterf ); } - /** - * {@inheritdoc} - */ public function generate(MediaProviderInterface $provider, MediaInterface $media): void { if (!$provider->requireThumbnails()) { @@ -130,9 +121,6 @@ public function generate(MediaProviderInterface $provider, MediaInterface $media } } - /** - * {@inheritdoc} - */ public function delete(MediaProviderInterface $provider, MediaInterface $media, $formats = null): void { if (null === $formats) { diff --git a/src/Thumbnail/LiipImagineThumbnail.php b/src/Thumbnail/LiipImagineThumbnail.php index 7c2a2b8357..6df2d85834 100644 --- a/src/Thumbnail/LiipImagineThumbnail.php +++ b/src/Thumbnail/LiipImagineThumbnail.php @@ -51,9 +51,6 @@ public function __construct($cacheManager) $this->cacheManager = $cacheManager; } - /** - * {@inheritdoc} - */ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterface $media, $format) { $path = $provider->getReferenceImage($media); @@ -76,9 +73,6 @@ public function generatePublicUrl(MediaProviderInterface $provider, MediaInterfa return $path; } - /** - * {@inheritdoc} - */ public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterface $media, $format) { if (MediaProviderInterface::FORMAT_REFERENCE !== $format) { @@ -90,17 +84,11 @@ public function generatePrivateUrl(MediaProviderInterface $provider, MediaInterf return $path; } - /** - * {@inheritdoc} - */ public function generate(MediaProviderInterface $provider, MediaInterface $media): void { // nothing to generate, as generated on demand } - /** - * {@inheritdoc} - */ public function delete(MediaProviderInterface $provider, MediaInterface $media, $formats = null): void { // feature not available diff --git a/src/Twig/Extension/FormatterMediaExtension.php b/src/Twig/Extension/FormatterMediaExtension.php index 65b84b6045..a137a35e58 100644 --- a/src/Twig/Extension/FormatterMediaExtension.php +++ b/src/Twig/Extension/FormatterMediaExtension.php @@ -35,9 +35,6 @@ public function __construct(ExtensionInterface $twigExtension) $this->twigExtension = $twigExtension; } - /** - * {@inheritdoc} - */ public function getAllowedTags(): array { return [ @@ -47,9 +44,6 @@ public function getAllowedTags(): array ]; } - /** - * {@inheritdoc} - */ public function getAllowedMethods(): array { return [ @@ -59,9 +53,6 @@ public function getAllowedMethods(): array ]; } - /** - * {@inheritdoc} - */ public function getTokenParsers(): array { return [ diff --git a/src/Twig/Extension/MediaExtension.php b/src/Twig/Extension/MediaExtension.php index 96318a1470..de9c08203e 100644 --- a/src/Twig/Extension/MediaExtension.php +++ b/src/Twig/Extension/MediaExtension.php @@ -54,9 +54,6 @@ public function __construct(Pool $mediaService, ManagerInterface $mediaManager) $this->mediaManager = $mediaManager; } - /** - * {@inheritdoc} - */ public function getTokenParsers() { return [ @@ -66,9 +63,6 @@ public function getTokenParsers() ]; } - /** - * {@inheritdoc} - */ public function initRuntime(Environment $environment): void { $this->environment = $environment; diff --git a/src/Twig/Node/MediaNode.php b/src/Twig/Node/MediaNode.php index 194c22126d..2c6f75f0ba 100644 --- a/src/Twig/Node/MediaNode.php +++ b/src/Twig/Node/MediaNode.php @@ -39,9 +39,6 @@ public function __construct($extensionName, AbstractExpression $media, AbstractE parent::__construct(['media' => $media, 'format' => $format, 'attributes' => $attributes], [], $lineno, $tag); } - /** - * {@inheritdoc} - */ public function compile(Compiler $compiler): void { $compiler diff --git a/src/Twig/Node/PathNode.php b/src/Twig/Node/PathNode.php index 0e8f1618a8..4a7d862786 100644 --- a/src/Twig/Node/PathNode.php +++ b/src/Twig/Node/PathNode.php @@ -39,9 +39,6 @@ public function __construct($extensionName, AbstractExpression $media, AbstractE parent::__construct(['media' => $media, 'format' => $format], [], $lineno, $tag); } - /** - * {@inheritdoc} - */ public function compile(Compiler $compiler): void { $compiler diff --git a/src/Twig/Node/ThumbnailNode.php b/src/Twig/Node/ThumbnailNode.php index 9f70e3342c..adc7caa826 100644 --- a/src/Twig/Node/ThumbnailNode.php +++ b/src/Twig/Node/ThumbnailNode.php @@ -39,9 +39,6 @@ public function __construct($extensionName, AbstractExpression $media, AbstractE parent::__construct(['media' => $media, 'format' => $format, 'attributes' => $attributes], [], $lineno, $tag); } - /** - * {@inheritdoc} - */ public function compile(Compiler $compiler): void { $compiler diff --git a/src/Twig/TokenParser/MediaTokenParser.php b/src/Twig/TokenParser/MediaTokenParser.php index 0561726c80..af8e4599c8 100644 --- a/src/Twig/TokenParser/MediaTokenParser.php +++ b/src/Twig/TokenParser/MediaTokenParser.php @@ -36,9 +36,6 @@ public function __construct($extensionName) $this->extensionName = $extensionName; } - /** - * {@inheritdoc} - */ public function parse(Token $token) { $media = $this->parser->getExpressionParser()->parseExpression(); @@ -61,9 +58,6 @@ public function parse(Token $token) return new MediaNode($this->extensionName, $media, $format, $attributes, $token->getLine(), $this->getTag()); } - /** - * {@inheritdoc} - */ public function getTag() { return 'media'; diff --git a/src/Twig/TokenParser/PathTokenParser.php b/src/Twig/TokenParser/PathTokenParser.php index 7387a27c7e..71a7a92a76 100644 --- a/src/Twig/TokenParser/PathTokenParser.php +++ b/src/Twig/TokenParser/PathTokenParser.php @@ -35,9 +35,6 @@ public function __construct($extensionName) $this->extensionName = $extensionName; } - /** - * {@inheritdoc} - */ public function parse(Token $token) { $media = $this->parser->getExpressionParser()->parseExpression(); @@ -51,9 +48,6 @@ public function parse(Token $token) return new PathNode($this->extensionName, $media, $format, $token->getLine(), $this->getTag()); } - /** - * {@inheritdoc} - */ public function getTag() { return 'path'; diff --git a/src/Twig/TokenParser/ThumbnailTokenParser.php b/src/Twig/TokenParser/ThumbnailTokenParser.php index 7534e09b19..95045c2cfb 100644 --- a/src/Twig/TokenParser/ThumbnailTokenParser.php +++ b/src/Twig/TokenParser/ThumbnailTokenParser.php @@ -36,9 +36,6 @@ public function __construct($extensionName) $this->extensionName = $extensionName; } - /** - * {@inheritdoc} - */ public function parse(Token $token) { $media = $this->parser->getExpressionParser()->parseExpression(); @@ -61,9 +58,6 @@ public function parse(Token $token) return new ThumbnailNode($this->extensionName, $media, $format, $attributes, $token->getLine(), $this->getTag()); } - /** - * {@inheritdoc} - */ public function getTag() { return 'thumbnail'; diff --git a/src/Validator/Constraints/ValidMediaFormat.php b/src/Validator/Constraints/ValidMediaFormat.php index 1f515e15c8..c600411e89 100644 --- a/src/Validator/Constraints/ValidMediaFormat.php +++ b/src/Validator/Constraints/ValidMediaFormat.php @@ -25,17 +25,11 @@ class ValidMediaFormat extends Constraint { public $message = 'The format is not valid'; - /** - * {@inheritdoc} - */ public function validatedBy() { return 'sonata.media.validator.format'; } - /** - * {@inheritdoc} - */ public function getTargets() { return self::CLASS_CONSTRAINT; diff --git a/src/Validator/FormatValidator.php b/src/Validator/FormatValidator.php index 4a854b29f6..8234b1b6fd 100644 --- a/src/Validator/FormatValidator.php +++ b/src/Validator/FormatValidator.php @@ -34,9 +34,6 @@ public function __construct(Pool $pool) $this->pool = $pool; } - /** - * {@inheritdoc} - */ public function validate($value, Constraint $constraint): void { $formats = $this->pool->getFormatNamesByContext($value->getContext()); diff --git a/tests/Command/CleanMediaCommandTest.php b/tests/Command/CleanMediaCommandTest.php index 08d0469133..adf293f035 100755 --- a/tests/Command/CleanMediaCommandTest.php +++ b/tests/Command/CleanMediaCommandTest.php @@ -51,9 +51,6 @@ class CleanMediaCommandTest extends FilesystemTestCase private $fileSystemLocal; - /** - * {@inheritdoc} - */ protected function setUp(): void { parent::setUp(); diff --git a/tests/Command/FixMediaContextCommandTest.php b/tests/Command/FixMediaContextCommandTest.php index 1f2966d5c3..3a144e1d0a 100755 --- a/tests/Command/FixMediaContextCommandTest.php +++ b/tests/Command/FixMediaContextCommandTest.php @@ -52,9 +52,6 @@ class FixMediaContextCommandTest extends TestCase private $categoryManager; - /** - * {@inheritdoc} - */ protected function setUp(): void { $this->container = new Container(); diff --git a/tests/Command/RemoveThumbsCommandTest.php b/tests/Command/RemoveThumbsCommandTest.php index 4646b57b6c..667e7aa649 100644 --- a/tests/Command/RemoveThumbsCommandTest.php +++ b/tests/Command/RemoveThumbsCommandTest.php @@ -62,9 +62,6 @@ final class RemoveThumbsCommandTest extends FilesystemTestCase */ private $mediaManager; - /** - * {@inheritdoc} - */ protected function setUp(): void { parent::setUp(); diff --git a/tests/DependencyInjection/SonataMediaExtensionTest.php b/tests/DependencyInjection/SonataMediaExtensionTest.php index 7d10830827..bc126a52b7 100644 --- a/tests/DependencyInjection/SonataMediaExtensionTest.php +++ b/tests/DependencyInjection/SonataMediaExtensionTest.php @@ -26,9 +26,6 @@ class SonataMediaExtensionTest extends AbstractExtensionTestCase { - /** - * {@inheritdoc} - */ protected function setUp(): void { parent::setUp(); @@ -290,9 +287,6 @@ protected function getMinimalConfiguration(): array ]; } - /** - * {@inheritdoc} - */ protected function getContainerExtensions(): array { return [ diff --git a/tests/Provider/BaseProviderTest.php b/tests/Provider/BaseProviderTest.php index 51856698c8..c5e5ac5deb 100644 --- a/tests/Provider/BaseProviderTest.php +++ b/tests/Provider/BaseProviderTest.php @@ -124,57 +124,36 @@ class TestProvider extends BaseProvider */ public $prevReferenceImage; - /** - * {@inheritdoc} - */ public function getHelperProperties(MediaInterface $media, $format, $options = []): void { // TODO: Implement getHelperProperties() method. } - /** - * {@inheritdoc} - */ public function postPersist(MediaInterface $media): void { // TODO: Implement postPersist() method. } - /** - * {@inheritdoc} - */ public function buildEditForm(FormMapper $form): void { $form->add('foo'); } - /** - * {@inheritdoc} - */ public function buildCreateForm(FormMapper $form): void { $form->add('foo'); } - /** - * {@inheritdoc} - */ public function postUpdate(MediaInterface $media): void { // TODO: Implement postUpdate() method. } - /** - * {@inheritdoc} - */ public function getAbsolutePath(MediaInterface $media): void { // TODO: Implement getAbsolutePath() method. } - /** - * {@inheritdoc} - */ public function getReferenceImage(MediaInterface $media): string { // A copy of the code from \Sonata\MediaBundle\Provider\FileProvider::getReferenceImage() @@ -187,73 +166,46 @@ public function getReferenceImage(MediaInterface $media): string return $this->prevReferenceImage; } - /** - * {@inheritdoc} - */ public function generatePrivateUrl(MediaInterface $media, $format): void { // TODO: Implement generatePrivateUrl() method. } - /** - * {@inheritdoc} - */ public function generatePublicUrl(MediaInterface $media, $format): void { // TODO: Implement generatePublicUrl() method. } - /** - * {@inheritdoc} - */ public function getReferenceFile(MediaInterface $media): void { // TODO: Implement getReferenceFile() method. } - /** - * {@inheritdoc} - */ public function preUpdate(MediaInterface $media): void { // TODO: Implement preUpdate() method. } - /** - * {@inheritdoc} - */ public function prePersist(MediaInterface $media): void { // TODO: Implement prePersist() method. } - /** - * {@inheritdoc} - */ public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = []): void { // TODO: Implement getDownloadResponse() method. } - /** - * {@inheritdoc} - */ public function buildMediaType(FormBuilder $formBuilder): void { $formBuilder->add('foo'); } - /** - * {@inheritdoc} - */ public function updateMetadata(MediaInterface $media, $force = false): void { // TODO: Implement updateMetadata() method. } - /** - * {@inheritdoc} - */ protected function doTransform(MediaInterface $media): void { // TODO: Implement doTransform() method. From d663309e57e61a86c8f421dad34f30a9df76652a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20B=C5=82oszyk?= Date: Sat, 1 Aug 2020 11:52:16 +0200 Subject: [PATCH 52/77] Rename GalleryItems --- docs/reference/installation.rst | 2 +- src/Admin/GalleryAdmin.php | 2 +- src/Controller/Api/GalleryController.php | 4 ++-- src/Model/Gallery.php | 10 +++++----- src/Model/GalleryInterface.php | 3 +-- src/Resources/translations/SonataMediaBundle.ca.xliff | 4 ++-- src/Resources/translations/SonataMediaBundle.cs.xliff | 4 ++-- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/docs/reference/installation.rst b/docs/reference/installation.rst index de6df11e04..e3830882e2 100644 --- a/docs/reference/installation.rst +++ b/docs/reference/installation.rst @@ -221,7 +221,7 @@ Configure SonataMediaBundle to use the newly generated classes: class: media: App\Application\Sonata\MediaBundle\Entity\Media gallery: App\Application\Sonata\MediaBundle\Entity\Gallery - gallery_has_media: App\Application\Sonata\MediaBundle\Entity\GalleryHasMedia + gallery_item: App\Application\Sonata\MediaBundle\Entity\GalleryItem If you are not using auto-mapping in doctrine you will have to add it there too: diff --git a/src/Admin/GalleryAdmin.php b/src/Admin/GalleryAdmin.php index 5f6e4df38e..6c7253117c 100644 --- a/src/Admin/GalleryAdmin.php +++ b/src/Admin/GalleryAdmin.php @@ -54,7 +54,7 @@ public function prePersist($gallery): void public function postUpdate($gallery) { - $gallery->reorderGalleryHasMedia(); + $gallery->reorderGalleryItems(); } public function getPersistentParameters() diff --git a/src/Controller/Api/GalleryController.php b/src/Controller/Api/GalleryController.php index 81a267e1b6..f8a78f1c31 100644 --- a/src/Controller/Api/GalleryController.php +++ b/src/Controller/Api/GalleryController.php @@ -20,7 +20,7 @@ use FOS\RestBundle\View\View as FOSRestView; use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Sonata\DatagridBundle\Pager\PagerInterface; -use Sonata\MediaBundle\Form\Type\ApiGalleryHasMediaType; +use Sonata\MediaBundle\Form\Type\ApiGalleryItemType; use Sonata\MediaBundle\Form\Type\ApiGalleryType; use Sonata\MediaBundle\Model\GalleryInterface; use Sonata\MediaBundle\Model\GalleryItemInterface; @@ -426,7 +426,7 @@ public function deleteGalleryAction($id) */ protected function handleWriteGalleryItem(GalleryInterface $gallery, MediaInterface $media, ?GalleryItemInterface $galleryItem = null, Request $request) { - $form = $this->formFactory->createNamed(null, ApiGalleryHasMediaType::class, $galleryItem, [ + $form = $this->formFactory->createNamed(null, ApiGalleryItemType::class, $galleryItem, [ 'csrf_protection' => false, ]); diff --git a/src/Model/Gallery.php b/src/Model/Gallery.php index 2ec6854b13..6b24bbe8ff 100644 --- a/src/Model/Gallery.php +++ b/src/Model/Gallery.php @@ -144,13 +144,13 @@ public function getContext() } /** - * Reorders $galleryHasMedia items based on their position. + * Reorders $galleryItems based on their position. */ - public function reorderGalleryHasMedia() + public function reorderGalleryItems() { - if ($this->getGalleryHasMedias() && $this->getGalleryHasMedias() instanceof \IteratorAggregate) { + if ($this->getGalleryItems() && $this->getGalleryItems() instanceof \IteratorAggregate) { // reorder - $iterator = $this->getGalleryHasMedias()->getIterator(); + $iterator = $this->getGalleryItems()->getIterator(); $iterator->uasort(static function ($a, $b) { if ($a->getPosition() === $b->getPosition()) { @@ -160,7 +160,7 @@ public function reorderGalleryHasMedia() return $a->getPosition() > $b->getPosition() ? 1 : -1; }); - $this->setGalleryHasMedias($iterator); + $this->setGalleryItems($iterator); } } } diff --git a/src/Model/GalleryInterface.php b/src/Model/GalleryInterface.php index 32194741e1..60d5be076f 100644 --- a/src/Model/GalleryInterface.php +++ b/src/Model/GalleryInterface.php @@ -110,8 +110,7 @@ public function setGalleryItems($galleryItems); public function getGalleryItems(); /** - * @deprecated implement addGalleryHasMedia method instead, it will be provided with the next major release - * NEXT_MAJOR: remove this method + * @return void */ public function addGalleryItem(GalleryItemInterface $galleryItem); } diff --git a/src/Resources/translations/SonataMediaBundle.ca.xliff b/src/Resources/translations/SonataMediaBundle.ca.xliff index bef73e9d6f..6bed95c941 100644 --- a/src/Resources/translations/SonataMediaBundle.ca.xliff +++ b/src/Resources/translations/SonataMediaBundle.ca.xliff @@ -146,8 +146,8 @@ form.label_default_format Format - - form.label_gallery_has_medias + + form.label_gallery_items Media diff --git a/src/Resources/translations/SonataMediaBundle.cs.xliff b/src/Resources/translations/SonataMediaBundle.cs.xliff index 3afd9ab662..6ea72bac4c 100644 --- a/src/Resources/translations/SonataMediaBundle.cs.xliff +++ b/src/Resources/translations/SonataMediaBundle.cs.xliff @@ -146,8 +146,8 @@ form.label_default_format Formát - - form.label_gallery_has_medias + + form.label_gallery_items Média From eb9ee077933db750ea1990d87c6aaea1e3506b22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20B=C5=82oszyk?= Date: Sun, 2 Aug 2020 13:19:42 +0200 Subject: [PATCH 53/77] Rename `GalleryHasMedia` to `GalleryItem` --- src/Controller/Api/GalleryController.php | 2 +- src/Model/GalleryMediaCollectionInterface.php | 4 ++-- src/Resources/config/routing/api/gallery.xml | 8 ++++---- tests/App/Entity/Gallery.php | 8 ++++++++ tests/App/Entity/{GalleryHasMedia.php => GalleryItem.php} | 6 +++--- tests/App/config.yml | 2 +- tests/Controller/Api/GalleryControllerTest.php | 2 +- tests/Functional/RoutingTest.php | 8 ++++---- 8 files changed, 24 insertions(+), 16 deletions(-) rename tests/App/Entity/{GalleryHasMedia.php => GalleryItem.php} (80%) diff --git a/src/Controller/Api/GalleryController.php b/src/Controller/Api/GalleryController.php index 2d6a0575a8..f53aecab9b 100644 --- a/src/Controller/Api/GalleryController.php +++ b/src/Controller/Api/GalleryController.php @@ -212,7 +212,7 @@ public function getGalleryMediasAction($id) * * @return GalleryItemInterface[] */ - public function getGalleryGalleryItemAction($id) + public function getGalleryGalleryItemsAction($id) { return $this->getGallery($id)->getGalleryItems(); } diff --git a/src/Model/GalleryMediaCollectionInterface.php b/src/Model/GalleryMediaCollectionInterface.php index 0f40555a14..5d6015d198 100644 --- a/src/Model/GalleryMediaCollectionInterface.php +++ b/src/Model/GalleryMediaCollectionInterface.php @@ -19,7 +19,7 @@ */ interface GalleryMediaCollectionInterface { - public function addGalleryHasMedia(GalleryItemInterface $galleryItem); + public function addGalleryItem(GalleryItemInterface $galleryItem); - public function removeGalleryHasMedia(GalleryItemInterface $galleryItem); + public function removeGalleryItem(GalleryItemInterface $galleryItem); } diff --git a/src/Resources/config/routing/api/gallery.xml b/src/Resources/config/routing/api/gallery.xml index 13e74a7c0f..165053263e 100644 --- a/src/Resources/config/routing/api/gallery.xml +++ b/src/Resources/config/routing/api/gallery.xml @@ -9,7 +9,7 @@ json|xml|html - + json|xml|html @@ -18,13 +18,13 @@ json|xml|html - + json|xml|html - + json|xml|html - + json|xml|html diff --git a/tests/App/Entity/Gallery.php b/tests/App/Entity/Gallery.php index 70f8e7e589..adc185fa73 100644 --- a/tests/App/Entity/Gallery.php +++ b/tests/App/Entity/Gallery.php @@ -15,6 +15,7 @@ use Doctrine\ORM\Mapping as ORM; use Sonata\MediaBundle\Entity\BaseGallery; +use Sonata\MediaBundle\Model\GalleryItemInterface; /** * @ORM\Entity @@ -36,4 +37,11 @@ public function getId(): int { return $this->id; } + + public function removeGalleryItem(GalleryItemInterface $galleryItem) + { + if ($this->galleryItems->contains($galleryItem)) { + $this->galleryItems->removeElement($galleryItem); + } + } } diff --git a/tests/App/Entity/GalleryHasMedia.php b/tests/App/Entity/GalleryItem.php similarity index 80% rename from tests/App/Entity/GalleryHasMedia.php rename to tests/App/Entity/GalleryItem.php index 746b27b2b4..8d6a93ed87 100644 --- a/tests/App/Entity/GalleryHasMedia.php +++ b/tests/App/Entity/GalleryItem.php @@ -14,13 +14,13 @@ namespace Sonata\MediaBundle\Tests\App\Entity; use Doctrine\ORM\Mapping as ORM; -use Sonata\MediaBundle\Entity\BaseGalleryHasMedia; +use Sonata\MediaBundle\Entity\BaseGalleryItem; /** * @ORM\Entity - * @ORM\Table(name="media__gallery_has_media") + * @ORM\Table(name="media__gallery_item") */ -class GalleryHasMedia extends BaseGalleryHasMedia +class GalleryItem extends BaseGalleryItem { /** * @ORM\Id diff --git a/tests/App/config.yml b/tests/App/config.yml index 863ae45a13..13bec50fd0 100644 --- a/tests/App/config.yml +++ b/tests/App/config.yml @@ -17,7 +17,7 @@ sonata_media: class: media: Sonata\MediaBundle\Tests\App\Entity\Media gallery: Sonata\MediaBundle\Tests\App\Entity\Gallery - gallery_has_media: Sonata\MediaBundle\Tests\App\Entity\GalleryHasMedia + gallery_item: Sonata\MediaBundle\Tests\App\Entity\GalleryItem force_disable_category: true default_context: default contexts: diff --git a/tests/Controller/Api/GalleryControllerTest.php b/tests/Controller/Api/GalleryControllerTest.php index ea8d90a467..3fcbd3990c 100644 --- a/tests/Controller/Api/GalleryControllerTest.php +++ b/tests/Controller/Api/GalleryControllerTest.php @@ -99,7 +99,7 @@ public function testGetGalleryGalleryItemsAction(): void $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); - $this->assertSame([$galleryItem], $gController->getGalleryGalleryItemAction(1)); + $this->assertSame([$galleryItem], $gController->getGalleryGalleryItemsAction(1)); } public function testGetGalleryMediaAction(): void diff --git a/tests/Functional/RoutingTest.php b/tests/Functional/RoutingTest.php index 049ffbc58e..a159f69d51 100644 --- a/tests/Functional/RoutingTest.php +++ b/tests/Functional/RoutingTest.php @@ -82,12 +82,12 @@ public function getRoutes(): iterable yield ['sonata_api_media_gallery_get_galleries', '/api/media/galleries.{_format}', ['GET']]; yield ['sonata_api_media_gallery_get_gallery', '/api/media/galleries/{id}.{_format}', ['GET']]; yield ['sonata_api_media_gallery_get_gallery_medias', '/api/media/galleries/{id}/medias.{_format}', ['GET']]; - yield ['sonata_api_media_gallery_get_gallery_galleryhasmedias', '/api/media/galleries/{id}/galleryhasmedias.{_format}', ['GET']]; + yield ['sonata_api_media_gallery_get_gallery_galleryitems', '/api/media/galleries/{id}/galleryitems.{_format}', ['GET']]; yield ['sonata_api_media_gallery_post_gallery', '/api/media/galleries.{_format}', ['POST']]; yield ['sonata_api_media_gallery_put_gallery', '/api/media/galleries/{id}.{_format}', ['PUT']]; - yield ['sonata_api_media_gallery_post_gallery_media_galleryhasmedia', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}', ['POST']]; - yield ['sonata_api_media_gallery_put_gallery_media_galleryhasmedia', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}', ['PUT']]; - yield ['sonata_api_media_gallery_delete_gallery_media_galleryhasmedia', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryhasmedia.{_format}', ['DELETE']]; + yield ['sonata_api_media_gallery_post_gallery_media_galleryitem', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}', ['POST']]; + yield ['sonata_api_media_gallery_put_gallery_media_galleryitem', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}', ['PUT']]; + yield ['sonata_api_media_gallery_delete_gallery_media_galleryitem', '/api/media/galleries/{galleryId}/media/{mediaId}/galleryitem.{_format}', ['DELETE']]; yield ['sonata_api_media_gallery_delete_gallery', '/api/media/galleries/{id}.{_format}', ['DELETE']]; yield ['sonata_api_media_media_get_media', '/api/media/media.{_format}', ['GET']]; yield ['sonata_api_media_media_get_medium', '/api/media/media/{id}.{_format}', ['GET']]; From 249ac762dd8bbea60d0bb4d13d06ce65b5c86c7f Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Wed, 18 Nov 2020 19:17:04 +0100 Subject: [PATCH 54/77] Remove file from fixtures --- .../Model/ContextInterface.php | 25 ------------------- 1 file changed, 25 deletions(-) delete mode 100644 tests/fixtures/SonataClassificationBundle/Model/ContextInterface.php diff --git a/tests/fixtures/SonataClassificationBundle/Model/ContextInterface.php b/tests/fixtures/SonataClassificationBundle/Model/ContextInterface.php deleted file mode 100644 index bed628f775..0000000000 --- a/tests/fixtures/SonataClassificationBundle/Model/ContextInterface.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Sonata\ClassificationBundle\Model; - -interface ContextInterface -{ - public function setId($id); - - public function setName($name); - - public function setEnabled($enabled); - - public function getContext(); -} From 271aeaeac10e331caa7d9a31c625b9670642971d Mon Sep 17 00:00:00 2001 From: Fran Moreno Date: Wed, 18 Nov 2020 19:46:40 +0100 Subject: [PATCH 55/77] Remove duplicated method --- src/CDN/CloudFront.php | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/src/CDN/CloudFront.php b/src/CDN/CloudFront.php index 255ad16452..e031839420 100644 --- a/src/CDN/CloudFront.php +++ b/src/CDN/CloudFront.php @@ -264,38 +264,6 @@ public static function getStatusList() ]; } - /** - * NEXT_MAJOR: Remove this method. - * - * @deprecated since sonata-project/media-bundle 3.28, to be removed in version 4.0. - * - * @param CloudFrontClient $client - */ - public function setClient($client) - { - @trigger_error(sprintf( - 'Method "%s()" is deprecated since sonata-project/media-bundle 3.28 and will be removed in version 4.0.', - __METHOD__ - ), E_USER_DEPRECATED); - - if (!$this->client) { - $config = [ - 'key' => $this->region, - 'secret' => $this->version, - ]; - - if (null !== $this->region) { - $config['region'] = $this->region; - } - - if (null !== $this->version) { - $config['version'] = $this->version; - } - - $this->client = CloudFrontClient::factory($config); - } - } - /** * Generates a valid caller reference from given paths regardless its order. * From 6c2e4e77335f47f095d9a7f49dc078cc0fc54ce6 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Fri, 4 Dec 2020 09:57:08 +0000 Subject: [PATCH 56/77] DevKit updates (#1875) --- .github/workflows/documentation.yaml | 3 +++ .github/workflows/lint.yaml | 3 +++ .github/workflows/test.yaml | 3 +++ 3 files changed, 9 insertions(+) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 82a3ec782a..310369d830 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -11,6 +11,9 @@ on: - master pull_request: +env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + jobs: build: name: Sphinx build diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index cdf70225a6..d60a2ed35b 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -11,6 +11,9 @@ on: - master pull_request: +env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + jobs: php-cs-fixer: name: PHP-CS-Fixer diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 571e157eb6..0481a10abb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -11,6 +11,9 @@ on: - master pull_request: +env: + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + jobs: test: name: PHP ${{ matrix.php-version }} + ${{ matrix.dependencies }} + ${{ matrix.variant }} From 60700c53ff3f1cfbeed44d3f861316897c9e99d2 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Sun, 3 Jan 2021 08:22:01 +0000 Subject: [PATCH 57/77] DevKit updates (#1882) --- phpunit.xml.dist | 5 +---- tests/autoload.php.dist_DELETE | 33 +++++++++++++++++++++++++++++++++ tests/bootstrap.php | 20 +++----------------- 3 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 tests/autoload.php.dist_DELETE diff --git a/phpunit.xml.dist b/phpunit.xml.dist index fe518fbb02..b3bd4faba9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -9,11 +9,8 @@ It's auto-generated by sonata-project/dev-kit package. diff --git a/tests/autoload.php.dist_DELETE b/tests/autoload.php.dist_DELETE new file mode 100644 index 0000000000..3a2b7e8661 --- /dev/null +++ b/tests/autoload.php.dist_DELETE @@ -0,0 +1,33 @@ + Date: Mon, 4 Jan 2021 04:12:25 +0000 Subject: [PATCH 58/77] DevKit updates (#1884) --- tests/autoload.php.dist_DELETE | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100644 tests/autoload.php.dist_DELETE diff --git a/tests/autoload.php.dist_DELETE b/tests/autoload.php.dist_DELETE deleted file mode 100644 index 3a2b7e8661..0000000000 --- a/tests/autoload.php.dist_DELETE +++ /dev/null @@ -1,33 +0,0 @@ - Date: Mon, 4 Jan 2021 07:33:14 +0000 Subject: [PATCH 59/77] DevKit updates (#1886) --- .github/ISSUE_TEMPLATE/Bug.md | 12 ++++++++++++ phpunit.xml.dist | 1 + tests/bootstrap.php | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/Bug.md b/.github/ISSUE_TEMPLATE/Bug.md index 929641ca19..234aae565b 100644 --- a/.github/ISSUE_TEMPLATE/Bug.md +++ b/.github/ISSUE_TEMPLATE/Bug.md @@ -18,18 +18,30 @@ labels: bug, unconfirmed #### Sonata packages +
    show +

    + ``` $ composer show --latest 'sonata-project/*' # Put the result here. ``` +

    +
    + #### Symfony packages +
    show +

    + ``` $ composer show --latest 'symfony/*' # Put the result here. ``` +

    +
    + #### PHP version ``` diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b3bd4faba9..569dff795e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,6 +26,7 @@ It's auto-generated by sonata-project/dev-kit package. + diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9109f57584..ab2851f0ef 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -24,6 +24,6 @@ require_once __DIR__.'/../vendor/autoload.php'; -if (file_exists($file = __DIR__.'/custom_boostrap.php')) { +if (file_exists($file = __DIR__.'/custom_bootstrap.php')) { require_once $file; } From 2cd4fe8c97924645ff375432584943a5911891de Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Tue, 5 Jan 2021 04:12:19 +0000 Subject: [PATCH 60/77] DevKit updates (#1890) --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 569dff795e..b3bd4faba9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -26,7 +26,6 @@ It's auto-generated by sonata-project/dev-kit package. - From cf8517af205149bad4a4e0e9ab3cae67713f8a32 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Tue, 5 Jan 2021 14:21:48 +0000 Subject: [PATCH 61/77] DevKit updates (#1892) --- .github/workflows/documentation.yaml | 4 ++-- .github/workflows/lint.yaml | 8 ++++---- .github/workflows/stale.yaml | 2 +- .github/workflows/test.yaml | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 310369d830..00b844be8c 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -18,7 +18,7 @@ jobs: build: name: Sphinx build - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout @@ -52,7 +52,7 @@ jobs: doctor-rst: name: DOCtor-RST - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index b512335a1c..4a55167246 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -18,7 +18,7 @@ jobs: php-cs-fixer: name: PHP-CS-Fixer - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout @@ -32,7 +32,7 @@ jobs: composer-normalize: name: composer-normalize - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout @@ -46,7 +46,7 @@ jobs: yaml-files: name: YAML files - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout @@ -66,7 +66,7 @@ jobs: xml-files: name: XML files - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Checkout diff --git a/.github/workflows/stale.yaml b/.github/workflows/stale.yaml index 44f8078fed..6ddf10f04f 100644 --- a/.github/workflows/stale.yaml +++ b/.github/workflows/stale.yaml @@ -12,7 +12,7 @@ on: jobs: stale: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Close stale issues and pull requests diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0481a10abb..d889274801 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -18,7 +18,7 @@ jobs: test: name: PHP ${{ matrix.php-version }} + ${{ matrix.dependencies }} + ${{ matrix.variant }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest continue-on-error: ${{ matrix.allowed-to-fail }} From c4d80fb8d36eb065edb4a887f868916042177ede Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Mon, 11 Jan 2021 12:11:45 +0000 Subject: [PATCH 62/77] DevKit updates (#1894) --- docs/.doctor-rst.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/.doctor-rst.yaml b/docs/.doctor-rst.yaml index afeffb3d6f..34641db8e0 100644 --- a/docs/.doctor-rst.yaml +++ b/docs/.doctor-rst.yaml @@ -4,6 +4,7 @@ rules: american_english: ~ + blank_line_after_anchor: ~ blank_line_after_directive: ~ blank_line_after_filepath_in_code_block: ~ composer_dev_option_at_the_end: ~ @@ -27,6 +28,7 @@ rules: no_php_open_tag_in_code_block_php_directive: ~ no_php_prefix_before_bin_console: ~ no_space_before_self_xml_closing_tag: ~ + max_colons: ~ only_backslashes_in_namespace_in_php_code_block: ~ only_backslashes_in_use_statements_in_php_code_block: ~ replacement: ~ From fc4a0762438e3fce11bc3468e3b04caf37b07bdc Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Fri, 22 Jan 2021 00:18:32 +0000 Subject: [PATCH 63/77] DevKit updates (#1905) --- .github/workflows/lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index dfd6414624..0a87151384 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -25,7 +25,7 @@ jobs: uses: actions/checkout@v2 - name: Run PHP-CS-Fixer - uses: docker://oskarstark/php-cs-fixer-ga:2.18.0 + uses: docker://oskarstark/php-cs-fixer-ga:2.18.1 with: args: --ansi --verbose --diff --dry-run From 633b29f8845951cbd1b763efeab6316f87a5296e Mon Sep 17 00:00:00 2001 From: Yozhef Date: Wed, 27 Jan 2021 11:31:53 +0200 Subject: [PATCH 64/77] add more version sonata-project/datagrid-bundle. (#1907) --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c802f7e066..08b85c06b1 100644 --- a/composer.json +++ b/composer.json @@ -86,7 +86,7 @@ "nelmio/api-doc-bundle": "^2.13.4", "sonata-project/admin-bundle": "^3.41", "sonata-project/block-bundle": "^3.17", - "sonata-project/datagrid-bundle": "^2.5", + "sonata-project/datagrid-bundle": "^2.5 || ^3.0", "sonata-project/doctrine-orm-admin-bundle": "^3.14", "sonata-project/notification-bundle": "^3.3", "sonata-project/seo-bundle": "^2.5", From ea1fc23819d7d549ef1e7fc91b772603502e8524 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Wed, 27 Jan 2021 09:42:20 +0000 Subject: [PATCH 65/77] DevKit updates (#1908) --- CONTRIBUTING.md | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2e9268816c..86544a365d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -148,6 +148,7 @@ If your PR contains an addition, a new feature, this one has to be fully covered Some rules have to be respected about the test: +* Prefer [the built-in test doubles implementation](https://phpunit.de/manual/current/en/test-doubles.html) over prophecy. * Annotations about coverage are prohibited. This concerns: * `@covers` * `@coversDefaultClass` @@ -161,22 +162,6 @@ Some rules have to be respected about the test: * Most of the time, the test class SHOULD have the same name as the targeted class, suffixed by `Test`. * The `@expectedException*` annotations are prohibited. Use `PHPUnit_Framework_TestCase::setExpectedException()`. -##### Using test doubles - -Historically, Sonata has been using [the built-in test doubles implementation](https://phpunit.de/manual/current/en/test-doubles.html), -but [started to use Prophecy](https://github.com/sonata-project/dev-kit/issues/89). -This means the current Sonata codebase currently uses both implementations. - -If you want to contribute a test that uses test doubles, please follow these rules : - -1. All new test classes MUST use built-in test double implementation. -2. If you are changing an existing test method, you MUST use the same implementation it already uses, -and focus on the goal of your PR and only on that. -3. If you are changing an existing test class, you MUST use the same implementation it already uses, -to be more consistent. -4. You MAY submit a PR that migrates a test class from Prophecy to the built-in test double implementation, -but it MUST migrate it entirely. The PR SHOULD only be about the migration. - ### Writing a Pull Request #### Subject From 6b658e30901ca759500cf6561ffe835ae7a1703b Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 10 Feb 2021 20:12:18 +0100 Subject: [PATCH 66/77] Add support for doctrine/persistence 2 --- composer.json | 1 + src/Listener/PHPCR/MediaEventSubscriber.php | 2 +- tests/Document/MediaManagerTest.php | 2 +- tests/Entity/GalleryManagerTest.php | 2 +- tests/Entity/MediaManagerTest.php | 2 +- tests/PHPCR/MediaManagerTest.php | 2 +- 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 08b85c06b1..d4cd98d214 100644 --- a/composer.json +++ b/composer.json @@ -65,6 +65,7 @@ "conflict": { "doctrine/dbal": "<2.6.0", "doctrine/mongodb-odm": "<2.0", + "doctrine/persistence": "<1.3", "friendsofsymfony/rest-bundle": "<2.6", "jms/serializer": "<0.13", "liip/imagine-bundle": "<1.9", diff --git a/src/Listener/PHPCR/MediaEventSubscriber.php b/src/Listener/PHPCR/MediaEventSubscriber.php index ca84b7b2c4..3003e25beb 100644 --- a/src/Listener/PHPCR/MediaEventSubscriber.php +++ b/src/Listener/PHPCR/MediaEventSubscriber.php @@ -36,7 +36,7 @@ public function getSubscribedEvents() protected function recomputeSingleEntityChangeSet(EventArgs $args) { - /* @var $args \Doctrine\Common\Persistence\Event\LifecycleEventArgs */ + /* @var $args \Doctrine\Persistence\Event\LifecycleEventArgs */ /** @var $dm \Doctrine\ODM\PHPCR\DocumentManager */ $dm = $args->getObjectManager(); diff --git a/tests/Document/MediaManagerTest.php b/tests/Document/MediaManagerTest.php index 00efbb81c3..def9a08958 100644 --- a/tests/Document/MediaManagerTest.php +++ b/tests/Document/MediaManagerTest.php @@ -13,8 +13,8 @@ namespace Sonata\MediaBundle\Tests\Document; -use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\ODM\MongoDB\DocumentManager; +use Doctrine\Persistence\ManagerRegistry; use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Document\MediaManager; use Sonata\MediaBundle\Model\MediaInterface; diff --git a/tests/Entity/GalleryManagerTest.php b/tests/Entity/GalleryManagerTest.php index 615dbf1a49..701d525a9f 100644 --- a/tests/Entity/GalleryManagerTest.php +++ b/tests/Entity/GalleryManagerTest.php @@ -13,7 +13,7 @@ namespace Sonata\MediaBundle\Test\Entity; -use Doctrine\Common\Persistence\ManagerRegistry; +use Doctrine\Persistence\ManagerRegistry; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Sonata\Doctrine\Test\EntityManagerMockFactoryTrait; diff --git a/tests/Entity/MediaManagerTest.php b/tests/Entity/MediaManagerTest.php index 054f98bf68..81bb5f7a6b 100644 --- a/tests/Entity/MediaManagerTest.php +++ b/tests/Entity/MediaManagerTest.php @@ -13,7 +13,7 @@ namespace Sonata\MediaBundle\Test\Entity; -use Doctrine\Common\Persistence\ManagerRegistry; +use Doctrine\Persistence\ManagerRegistry; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Sonata\Doctrine\Test\EntityManagerMockFactoryTrait; diff --git a/tests/PHPCR/MediaManagerTest.php b/tests/PHPCR/MediaManagerTest.php index 07cf1434dc..bca0163c62 100644 --- a/tests/PHPCR/MediaManagerTest.php +++ b/tests/PHPCR/MediaManagerTest.php @@ -13,8 +13,8 @@ namespace Sonata\MediaBundle\Tests\PHPCR; -use Doctrine\Common\Persistence\ManagerRegistry; use Doctrine\ODM\PHPCR\DocumentManager; +use Doctrine\Persistence\ManagerRegistry; use PHPUnit\Framework\TestCase; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\PHPCR\MediaManager; From c2a6c0b955720f2d820930447b322920b864b676 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 15 Feb 2021 22:16:20 +0100 Subject: [PATCH 67/77] 3.3 (#1911) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index afaf8d1ddb..a2ee0a6a7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [3.30.0](https://github.com/sonata-project/SonataMediaBundle/compare/3.29.0...3.30.0) - 2021-02-15 +### Added +- [[#1907](https://github.com/sonata-project/SonataMediaBundle/pull/1907)] Support `sonata-project/datagrid-bundle:^3.0` ([@Yozhef](https://github.com/Yozhef)) + ## [3.29.0](https://github.com/sonata-project/SonataMediaBundle/compare/3.28.0...3.29.0) - 2020-11-30 ### Fixed - [[#1866](https://github.com/sonata-project/SonataMediaBundle/pull/1866)] Guessing the content type of a file stored on Amazon S3 ([@jorrit](https://github.com/jorrit)) From 359e0025711faf1e270c407772344006d231cf93 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Wed, 17 Feb 2021 10:11:24 +0000 Subject: [PATCH 68/77] DevKit updates for 3.x branch (#1912) * DevKit updates * Applied fixes from FlintCI (#1914) Co-authored-by: Sullivan SENECHAL --- .php_cs.dist | 2 -- tests/Fixtures/FilesystemTestCase.php | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 0e5b579f3c..88d5aed0a1 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -62,8 +62,6 @@ $rules = [ $finder = PhpCsFixer\Finder::create() ->in(__DIR__) - ->exclude('Tests/Fixtures') - ->exclude('tests/Fixtures') ->exclude('Resources/skeleton') ->exclude('Resources/public/vendor') ; diff --git a/tests/Fixtures/FilesystemTestCase.php b/tests/Fixtures/FilesystemTestCase.php index b87aa052ff..00b16785c7 100644 --- a/tests/Fixtures/FilesystemTestCase.php +++ b/tests/Fixtures/FilesystemTestCase.php @@ -142,7 +142,7 @@ protected function markAsSkippedIfSymlinkIsMissing(bool $relative = false): void } // https://bugs.php.net/69473 - if ($relative && '\\' === \DIRECTORY_SEPARATOR && 1 === PHP_ZTS) { + if ($relative && '\\' === \DIRECTORY_SEPARATOR && 1 === \PHP_ZTS) { $this->markTestSkipped('symlink does not support relative paths on thread safe Windows PHP versions'); } } From 79f5463891661ee4a1cd73f853c7505370311325 Mon Sep 17 00:00:00 2001 From: david <42849369+dps910@users.noreply.github.com> Date: Wed, 17 Feb 2021 12:41:39 +0000 Subject: [PATCH 69/77] =?UTF-8?q?changed=20words=20to=20primary=20and=20se?= =?UTF-8?q?condary=20=F0=9F=91=8D=20(#1778)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Grégoire Paris Co-authored-by: Wojciech Błoszyk --- src/Filesystem/Replicate.php | 76 ++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/src/Filesystem/Replicate.php b/src/Filesystem/Replicate.php index 44bc8bf243..af0a758619 100644 --- a/src/Filesystem/Replicate.php +++ b/src/Filesystem/Replicate.php @@ -25,26 +25,44 @@ class Replicate implements AdapterInterface, MetadataSupporter { /** * @var AdapterInterface + * + * @deprecated since version 3.x, to be removed in 4.0. Use `$primary` instead. */ protected $master; /** * @var AdapterInterface + * + * @deprecated since version 3.x, to be removed in 4.0. Use `$primary` instead. */ protected $slave; - /** * @var LoggerInterface + * + * NEXT_MAJOR change visibiity to private */ protected $logger; + /** + * @var AdapterInterface + */ + private $primary; + + /** + * @var AdapterInterface + */ + private $secondary; + /** * @param LoggerInterface $logger */ - public function __construct(AdapterInterface $master, AdapterInterface $slave, ?LoggerInterface $logger = null) + public function __construct(AdapterInterface $primary, AdapterInterface $secondary, ?LoggerInterface $logger = null) { - $this->master = $master; - $this->slave = $slave; + // NEXT_MAJOR: remove master nad slave + $this->master = $primary; + $this->slave = $secondary; + $this->primary = $primary; + $this->secondary = $secondary; $this->logger = $logger; } @@ -53,7 +71,7 @@ public function delete($key) $ok = true; try { - $this->slave->delete($key); + $this->secondary->delete($key); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); @@ -63,7 +81,7 @@ public function delete($key) } try { - $this->master->delete($key); + $this->primary->delete($key); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to delete %s, error: %s', $key, $e->getMessage())); @@ -77,17 +95,17 @@ public function delete($key) public function mtime($key) { - return $this->master->mtime($key); + return $this->primary->mtime($key); } public function keys() { - return $this->master->keys(); + return $this->primary->keys(); } public function exists($key) { - return $this->master->exists($key); + return $this->primary->exists($key); } public function write($key, $content, ?array $metadata = null) @@ -96,7 +114,7 @@ public function write($key, $content, ?array $metadata = null) $return = false; try { - $return = $this->master->write($key, $content, $metadata); + $return = $this->primary->write($key, $content, $metadata); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); @@ -106,7 +124,7 @@ public function write($key, $content, ?array $metadata = null) } try { - $return = $this->slave->write($key, $content, $metadata); + $return = $this->secondary->write($key, $content, $metadata); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to write %s, error: %s', $key, $e->getMessage())); @@ -120,7 +138,7 @@ public function write($key, $content, ?array $metadata = null) public function read($key) { - return $this->master->read($key); + return $this->primary->read($key); } public function rename($key, $new) @@ -128,7 +146,7 @@ public function rename($key, $new) $ok = true; try { - $this->master->rename($key, $new); + $this->primary->rename($key, $new); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to rename %s, error: %s', $key, $e->getMessage())); @@ -138,7 +156,7 @@ public function rename($key, $new) } try { - $this->slave->rename($key, $new); + $this->secondary->rename($key, $new); } catch (\Exception $e) { if ($this->logger) { $this->logger->critical(sprintf('Unable to rename %s, error: %s', $key, $e->getMessage())); @@ -157,25 +175,25 @@ public function rename($key, $new) */ public function supportsMetadata() { - return $this->master instanceof MetadataSupporter || $this->slave instanceof MetadataSupporter; + return $this->primary instanceof MetadataSupporter || $this->secondary instanceof MetadataSupporter; } public function setMetadata($key, $metadata) { - if ($this->master instanceof MetadataSupporter) { - $this->master->setMetadata($key, $metadata); + if ($this->primary instanceof MetadataSupporter) { + $this->primary->setMetadata($key, $metadata); } - if ($this->slave instanceof MetadataSupporter) { - $this->slave->setMetadata($key, $metadata); + if ($this->secondary instanceof MetadataSupporter) { + $this->secondary->setMetadata($key, $metadata); } } public function getMetadata($key) { - if ($this->master instanceof MetadataSupporter) { - return $this->master->getMetadata($key); - } elseif ($this->slave instanceof MetadataSupporter) { - return $this->slave->getMetadata($key); + if ($this->primary instanceof MetadataSupporter) { + return $this->primary->getMetadata($key); + } elseif ($this->secondary instanceof MetadataSupporter) { + return $this->secondary->getMetadata($key); } return []; @@ -189,28 +207,28 @@ public function getMetadata($key) public function getAdapterClassNames() { return [ - \get_class($this->master), - \get_class($this->slave), + \get_class($this->primary), + \get_class($this->secondary), ]; } public function createFile($key, Filesystem $filesystem) { - return $this->master->createFile($key, $filesystem); + return $this->primary->createFile($key, $filesystem); } public function createFileStream($key, Filesystem $filesystem) { - return $this->master->createFileStream($key, $filesystem); + return $this->primary->createFileStream($key, $filesystem); } public function listDirectory($directory = '') { - return $this->master->listDirectory($directory); + return $this->primary->listDirectory($directory); } public function isDirectory($key) { - return $this->master->isDirectory($key); + return $this->primary->isDirectory($key); } } From fe29aaa827e3da369d37b858f37c8dc5a223db46 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Wed, 17 Feb 2021 17:13:05 +0100 Subject: [PATCH 70/77] Move suggest to conflict (#1917) --- composer.json | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index d4cd98d214..bad04f01ed 100644 --- a/composer.json +++ b/composer.json @@ -69,13 +69,16 @@ "friendsofsymfony/rest-bundle": "<2.6", "jms/serializer": "<0.13", "liip/imagine-bundle": "<1.9", + "rackspace/php-opencloud": "<1.6", "sonata-project/block-bundle": "<3.17 || >=4.0", "sonata-project/classification-bundle": "<3.0 || >= 5.0", "sonata-project/core-bundle": "<3.20", + "sonata-project/doctrine-orm-admin-bundle": "<3.0", "sonata-project/formatter-bundle": "<3.4", "sonata-project/notification-bundle": "<3.3", "sonata-project/seo-bundle": "<2.5 || >=3.0", - "symfony/monolog-bundle": "<2.4" + "symfony/monolog-bundle": "<2.4", + "tilleuls/ckeditor-sonata-media-bundle": "<1.0" }, "require-dev": { "aws/aws-sdk-php": "^2.8 || ^3.0", @@ -98,14 +101,14 @@ }, "suggest": { "liip/imagine-bundle": "If you want on-the-fly thumbnail generation or image filtering (scale, crop, watermark...)", - "rackspace/php-opencloud": "^1.6", + "rackspace/php-opencloud": "If you want to use OpenStack/Rackspace APIs", "sonata-project/classification-bundle": "If you want to categorize your media items.", - "sonata-project/doctrine-orm-admin-bundle": "^3.0", + "sonata-project/doctrine-orm-admin-bundle": "If you want to persist entities", "sonata-project/notification-bundle": "If you want to generate thumbnails asynchronously.", - "sonata-project/seo-bundle": "^2.1", + "sonata-project/seo-bundle": "If you're sensible to SEO", "symfony/http-client": "If you want to load external content", "symfony/monolog-bundle": "If you want to log exceptions produced when dealing with images.", - "tilleuls/ckeditor-sonata-media-bundle": "^1.0", + "tilleuls/ckeditor-sonata-media-bundle": "If you want to use CKEditor", "twig/extra-bundle": "Auto configures the Twig Intl extension" }, "config": { From a6c50422339682259c22b7007a7e50d1e26a9d47 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Mon, 22 Feb 2021 12:15:07 +0000 Subject: [PATCH 71/77] DevKit updates (#1919) --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 88d5aed0a1..baaaf87dfa 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -64,6 +64,7 @@ $finder = PhpCsFixer\Finder::create() ->in(__DIR__) ->exclude('Resources/skeleton') ->exclude('Resources/public/vendor') + ->exclude('var') ; return PhpCsFixer\Config::create() From 3f11c09dce4fe9ac072d6936da2a849b1c24a06d Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Mon, 22 Feb 2021 12:21:59 +0000 Subject: [PATCH 72/77] DevKit updates (#1920) --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 88d5aed0a1..baaaf87dfa 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -64,6 +64,7 @@ $finder = PhpCsFixer\Finder::create() ->in(__DIR__) ->exclude('Resources/skeleton') ->exclude('Resources/public/vendor') + ->exclude('var') ; return PhpCsFixer\Config::create() From ba611d662a31c124a83f85947df2eca6f2c76ffb Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Wed, 10 Mar 2021 20:48:51 +0000 Subject: [PATCH 73/77] DevKit updates for 3.x branch (#1928) * DevKit updates * DevKit updates --- .github/workflows/test.yaml | 4 ++-- .yamllint | 15 ++++++++++++--- Makefile | 2 +- phpunit.xml.dist | 3 ++- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d889274801..c1cda5b975 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -71,8 +71,8 @@ jobs: with: php-version: ${{ matrix.php-version }} coverage: pcov - tools: composer:v2, pecl - extensions: mongodb-1.9.0 + tools: composer:v2 + extensions: mongodb-1.9.0, soap, gd - name: Add PHPUnit matcher run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" diff --git a/.yamllint b/.yamllint index f742af8fe1..74dd918044 100644 --- a/.yamllint +++ b/.yamllint @@ -2,10 +2,19 @@ # # It's auto-generated by sonata-project/dev-kit package. +ignore: vendor/ + extends: default rules: + comments: disable + comments-indentation: disable document-start: disable - line-length: - max: 120 - level: warning + empty-lines: + max: 1 + max-start: 0 + max-end: 0 + line-length: disable + truthy: + allowed-values: ['true', 'false'] + check-keys: false diff --git a/Makefile b/Makefile index 2e849e04c9..6e6664fbfb 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ lint-composer: .PHONY: lint-composer lint-yaml: - yaml-lint --ignore-non-yaml-files --quiet --exclude vendor . + yamllint . .PHONY: lint-yaml diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b3bd4faba9..59c3b69fdc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -28,7 +28,8 @@ It's auto-generated by sonata-project/dev-kit package. - + + From ea9d86ae296ca834d41d619310979e3b309e865b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20B=C5=82oszyk?= Date: Mon, 8 Mar 2021 18:37:58 +0100 Subject: [PATCH 74/77] Replace PageableManagerInterface --- UPGRADE-4.0.md | 15 +++++++++++++++ composer.json | 2 +- src/Controller/Api/GalleryController.php | 2 +- src/Controller/Api/MediaController.php | 2 +- src/Document/GalleryManager.php | 3 ++- src/Document/MediaManager.php | 3 ++- src/Entity/GalleryManager.php | 3 ++- src/Entity/MediaManager.php | 3 ++- src/Model/GalleryManagerInterface.php | 4 ++-- src/Model/MediaManagerInterface.php | 4 ++-- src/Model/NoDriverManager.php | 3 ++- tests/Controller/Api/GalleryControllerTest.php | 6 ++++-- tests/Controller/Api/MediaControllerTest.php | 7 ++++--- 13 files changed, 40 insertions(+), 17 deletions(-) diff --git a/UPGRADE-4.0.md b/UPGRADE-4.0.md index 5c2fb15d38..e44f0cea2a 100644 --- a/UPGRADE-4.0.md +++ b/UPGRADE-4.0.md @@ -1,6 +1,21 @@ UPGRADE FROM 3.x to 4.0 ======================= +### Sonata\DatagridBundle\Pager\PageableInterface + + Usages of `Sonata\Doctrine\Model\PageableManagerInterface` were replaced in favor of `Sonata\DatagridBundle\Pager\PageableInterface`. + +### Dependencies + + - Drop support for `sonata-project/datagrid-bundle` < 3.0. + + If you are extending these methods, you MUST add argument and return type declarations: + + - `Sonata\MediaBundle\Entity\GalleryManager::getPager()` + - `Sonata\MediaBundle\Entity\MediaManager::getPager()` + - `Sonata\MediaBundle\Model\GalleryManager::getPager()` + - `Sonata\MediaBundle\Model\MediaManager::getPager()` + ## Deprecations All the deprecated code introduced on 3.x is removed on 4.0. diff --git a/composer.json b/composer.json index 4659e34561..728faf9db7 100644 --- a/composer.json +++ b/composer.json @@ -90,7 +90,7 @@ "nelmio/api-doc-bundle": "^2.13.4", "sonata-project/admin-bundle": "^3.41", "sonata-project/block-bundle": "^3.17", - "sonata-project/datagrid-bundle": "^2.5 || ^3.0", + "sonata-project/datagrid-bundle": "^3.0.1", "sonata-project/doctrine-orm-admin-bundle": "^3.14", "sonata-project/notification-bundle": "^3.3", "sonata-project/seo-bundle": "^2.5", diff --git a/src/Controller/Api/GalleryController.php b/src/Controller/Api/GalleryController.php index 360a3baa21..396ef5ad58 100644 --- a/src/Controller/Api/GalleryController.php +++ b/src/Controller/Api/GalleryController.php @@ -132,7 +132,7 @@ public function getGalleriesAction(ParamFetcherInterface $paramFetcher) $sort = [$sort => 'asc']; } - return $this->getGalleryManager()->getPager($criteria, $page, $limit, $sort); + return $this->getGalleryManager()->getPager($criteria, (int) $page, (int) $limit, $sort); } /** diff --git a/src/Controller/Api/MediaController.php b/src/Controller/Api/MediaController.php index 6c164d061b..1e72010feb 100644 --- a/src/Controller/Api/MediaController.php +++ b/src/Controller/Api/MediaController.php @@ -132,7 +132,7 @@ public function getMediaAction(ParamFetcherInterface $paramFetcher) $sort = [$sort => 'asc']; } - return $this->mediaManager->getPager($criteria, $page, $limit, $sort); + return $this->mediaManager->getPager($criteria, (int) $page, (int) $limit, $sort); } /** diff --git a/src/Document/GalleryManager.php b/src/Document/GalleryManager.php index d87da8407d..7de4597c20 100644 --- a/src/Document/GalleryManager.php +++ b/src/Document/GalleryManager.php @@ -13,6 +13,7 @@ namespace Sonata\MediaBundle\Document; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\Doctrine\Document\BaseDocumentManager; use Sonata\MediaBundle\Model\GalleryInterface; use Sonata\MediaBundle\Model\GalleryManagerInterface; @@ -34,7 +35,7 @@ public function update(GalleryInterface $gallery): void parent::save($gallery); } - public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void + public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { throw new \RuntimeException('Not Implemented yet'); } diff --git a/src/Document/MediaManager.php b/src/Document/MediaManager.php index b004e40cc2..13f8666665 100644 --- a/src/Document/MediaManager.php +++ b/src/Document/MediaManager.php @@ -13,6 +13,7 @@ namespace Sonata\MediaBundle\Document; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\Doctrine\Document\BaseDocumentManager; /** @@ -40,7 +41,7 @@ public function save($entity, $andFlush = true): void } } - public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void + public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { throw new \RuntimeException('Not Implemented yet'); } diff --git a/src/Entity/GalleryManager.php b/src/Entity/GalleryManager.php index 3695047e55..bf953643fa 100644 --- a/src/Entity/GalleryManager.php +++ b/src/Entity/GalleryManager.php @@ -14,6 +14,7 @@ namespace Sonata\MediaBundle\Entity; use Sonata\DatagridBundle\Pager\Doctrine\Pager; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\DatagridBundle\ProxyQuery\Doctrine\ProxyQuery; use Sonata\Doctrine\Entity\BaseEntityManager; use Sonata\MediaBundle\Model\GalleryInterface; @@ -36,7 +37,7 @@ public function update(GalleryInterface $gallery): void parent::save($gallery); } - public function getPager(array $criteria, $page, $limit = 10, array $sort = []) + public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { $query = $this->getRepository() ->createQueryBuilder('g') diff --git a/src/Entity/MediaManager.php b/src/Entity/MediaManager.php index b73a83b012..fa0d92acbd 100644 --- a/src/Entity/MediaManager.php +++ b/src/Entity/MediaManager.php @@ -14,6 +14,7 @@ namespace Sonata\MediaBundle\Entity; use Sonata\DatagridBundle\Pager\Doctrine\Pager; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\DatagridBundle\ProxyQuery\Doctrine\ProxyQuery; use Sonata\Doctrine\Entity\BaseEntityManager; use Sonata\MediaBundle\Model\MediaManagerInterface; @@ -47,7 +48,7 @@ public function save($media, $andFlush = true): void } } - public function getPager(array $criteria, $page, $limit = 10, array $sort = []) + public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { $query = $this->getRepository() ->createQueryBuilder('m') diff --git a/src/Model/GalleryManagerInterface.php b/src/Model/GalleryManagerInterface.php index 6c553b2af5..ca7a1d6cbd 100644 --- a/src/Model/GalleryManagerInterface.php +++ b/src/Model/GalleryManagerInterface.php @@ -13,9 +13,9 @@ namespace Sonata\MediaBundle\Model; +use Sonata\DatagridBundle\Pager\PageableInterface; use Sonata\Doctrine\Model\ManagerInterface; -use Sonata\Doctrine\Model\PageableManagerInterface; -interface GalleryManagerInterface extends ManagerInterface, PageableManagerInterface +interface GalleryManagerInterface extends ManagerInterface, PageableInterface { } diff --git a/src/Model/MediaManagerInterface.php b/src/Model/MediaManagerInterface.php index f2793768c3..026c064be7 100644 --- a/src/Model/MediaManagerInterface.php +++ b/src/Model/MediaManagerInterface.php @@ -13,9 +13,9 @@ namespace Sonata\MediaBundle\Model; +use Sonata\DatagridBundle\Pager\PageableInterface; use Sonata\Doctrine\Model\ManagerInterface; -use Sonata\Doctrine\Model\PageableManagerInterface; -interface MediaManagerInterface extends ManagerInterface, PageableManagerInterface +interface MediaManagerInterface extends ManagerInterface, PageableInterface { } diff --git a/src/Model/NoDriverManager.php b/src/Model/NoDriverManager.php index 1c7ee61d8e..913554b9e3 100644 --- a/src/Model/NoDriverManager.php +++ b/src/Model/NoDriverManager.php @@ -13,6 +13,7 @@ namespace Sonata\MediaBundle\Model; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\MediaBundle\Exception\NoDriverException; /** @@ -87,7 +88,7 @@ public function getConnection(): void throw new NoDriverException(); } - public function getPager(array $criteria, $page, $limit = 10, array $sort = []) + public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { throw new NoDriverException(); } diff --git a/tests/Controller/Api/GalleryControllerTest.php b/tests/Controller/Api/GalleryControllerTest.php index 3fcbd3990c..31548f5d5c 100644 --- a/tests/Controller/Api/GalleryControllerTest.php +++ b/tests/Controller/Api/GalleryControllerTest.php @@ -15,6 +15,7 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use PHPUnit\Framework\TestCase; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\MediaBundle\Controller\Api\GalleryController; use Sonata\MediaBundle\Model\GalleryInterface; use Sonata\MediaBundle\Model\GalleryItemInterface; @@ -31,11 +32,12 @@ class GalleryControllerTest extends TestCase { public function testGetGalleriesAction(): void { + $pager = $this->createStub(PagerInterface::class); $galleryManager = $this->createMock(GalleryManagerInterface::class); $mediaManager = $this->createMock(MediaManagerInterface::class); $formFactory = $this->createMock(FormFactoryInterface::class); - $galleryManager->expects($this->once())->method('getPager')->willReturn([]); + $galleryManager->expects($this->once())->method('getPager')->willReturn($pager); $gController = new GalleryController($galleryManager, $mediaManager, $formFactory, 'test'); @@ -50,7 +52,7 @@ public function testGetGalleriesAction(): void 'orderBy' => ['id' => 'ASC'], ]); - $this->assertSame([], $gController->getGalleriesAction($paramFetcher)); + $this->assertSame($pager, $gController->getGalleriesAction($paramFetcher)); } public function testGetGalleryAction(): void diff --git a/tests/Controller/Api/MediaControllerTest.php b/tests/Controller/Api/MediaControllerTest.php index 4cd998cbd1..7d1a93582d 100644 --- a/tests/Controller/Api/MediaControllerTest.php +++ b/tests/Controller/Api/MediaControllerTest.php @@ -16,6 +16,7 @@ use FOS\RestBundle\Request\ParamFetcherInterface; use FOS\RestBundle\View\View; use PHPUnit\Framework\TestCase; +use Sonata\DatagridBundle\Pager\PagerInterface; use Sonata\MediaBundle\Controller\Api\MediaController; use Sonata\MediaBundle\Model\MediaInterface; use Sonata\MediaBundle\Model\MediaManagerInterface; @@ -34,10 +35,10 @@ class MediaControllerTest extends TestCase { public function testGetMediaAction(): void { + $pager = $this->createStub(PagerInterface::class); $mManager = $this->createMock(MediaManagerInterface::class); - $media = $this->createMock(MediaInterface::class); - $mManager->expects($this->once())->method('getPager')->willReturn([$media]); + $mManager->expects($this->once())->method('getPager')->willReturn($pager); $mController = $this->createMediaController($mManager); @@ -45,7 +46,7 @@ public function testGetMediaAction(): void $paramFetcher->expects($this->exactly(3))->method('get'); $paramFetcher->expects($this->once())->method('all')->willReturn([]); - $this->assertSame([$media], $mController->getMediaAction($paramFetcher)); + $this->assertSame($pager, $mController->getMediaAction($paramFetcher)); } public function testGetMediumAction(): void From e9581bc178a62476781f4a834c03eaee567b1166 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Sat, 13 Mar 2021 08:16:37 -0300 Subject: [PATCH 75/77] Replace some `\RuntimeException` exceptions with `\BadMethodCallException` --- src/Document/GalleryManager.php | 2 +- src/Document/MediaManager.php | 2 +- src/PHPCR/GalleryManager.php | 2 +- src/PHPCR/MediaManager.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Document/GalleryManager.php b/src/Document/GalleryManager.php index 7de4597c20..ec2c0ddb59 100644 --- a/src/Document/GalleryManager.php +++ b/src/Document/GalleryManager.php @@ -37,6 +37,6 @@ public function update(GalleryInterface $gallery): void public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { - throw new \RuntimeException('Not Implemented yet'); + throw new \BadMethodCallException('Not implemented yet.'); } } diff --git a/src/Document/MediaManager.php b/src/Document/MediaManager.php index 13f8666665..e155c32a1b 100644 --- a/src/Document/MediaManager.php +++ b/src/Document/MediaManager.php @@ -43,6 +43,6 @@ public function save($entity, $andFlush = true): void public function getPager(array $criteria, int $page, int $limit = 10, array $sort = []): PagerInterface { - throw new \RuntimeException('Not Implemented yet'); + throw new \BadMethodCallException('Not implemented yet.'); } } diff --git a/src/PHPCR/GalleryManager.php b/src/PHPCR/GalleryManager.php index 66fe7580c2..f3e2ca3859 100644 --- a/src/PHPCR/GalleryManager.php +++ b/src/PHPCR/GalleryManager.php @@ -36,6 +36,6 @@ public function update(GalleryInterface $gallery): void public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void { - throw new \RuntimeException('Not Implemented yet'); + throw new \BadMethodCallException('Not implemented yet.'); } } diff --git a/src/PHPCR/MediaManager.php b/src/PHPCR/MediaManager.php index 01fde4f780..4e1eb24723 100644 --- a/src/PHPCR/MediaManager.php +++ b/src/PHPCR/MediaManager.php @@ -42,6 +42,6 @@ public function save($entity, $andFlush = true): void public function getPager(array $criteria, $page, $limit = 10, array $sort = []): void { - throw new \RuntimeException('Not Implemented yet'); + throw new \BadMethodCallException('Not implemented yet.'); } } From 832f92dc4026f8bd7f5bad2f3731fa4048aad336 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Sun, 14 Mar 2021 12:10:20 +0000 Subject: [PATCH 76/77] DevKit updates (#1936) --- .github/workflows/documentation.yaml | 5 +---- .php_cs.dist | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 00b844be8c..f037039543 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -25,16 +25,13 @@ jobs: uses: actions/checkout@v2 - name: Set up Python 3.7 - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: '3.7' - name: Display Python version run: python -c "import sys; print(sys.version)" - - name: Install Sphinx dependencies - run: sudo apt-get install python-dev build-essential - - name: Cache pip uses: actions/cache@v2 with: diff --git a/.php_cs.dist b/.php_cs.dist index baaaf87dfa..675f179b75 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -56,7 +56,7 @@ $rules = [ 'static_lambda' => true, 'strict_comparison' => true, 'strict_param' => true, - 'void_return' => null, + 'void_return' => false, ]; From 04b9f35d7682a876d276df90d5fb9c987b31d4d3 Mon Sep 17 00:00:00 2001 From: Sonata CI Date: Sun, 14 Mar 2021 12:22:08 +0000 Subject: [PATCH 77/77] DevKit updates (#1937) --- .github/workflows/documentation.yaml | 5 +---- .php_cs.dist | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml index 00b844be8c..f037039543 100644 --- a/.github/workflows/documentation.yaml +++ b/.github/workflows/documentation.yaml @@ -25,16 +25,13 @@ jobs: uses: actions/checkout@v2 - name: Set up Python 3.7 - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: '3.7' - name: Display Python version run: python -c "import sys; print(sys.version)" - - name: Install Sphinx dependencies - run: sudo apt-get install python-dev build-essential - - name: Cache pip uses: actions/cache@v2 with: diff --git a/.php_cs.dist b/.php_cs.dist index baaaf87dfa..675f179b75 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -56,7 +56,7 @@ $rules = [ 'static_lambda' => true, 'strict_comparison' => true, 'strict_param' => true, - 'void_return' => null, + 'void_return' => false, ];