Skip to content

Commit 4fcf580

Browse files
authored
Symfony5 (#379)
Symfony 5 Compatibility
1 parent cd377c6 commit 4fcf580

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+885
-968
lines changed

.travis.yml

+10-25
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,24 @@ cache:
66
- $HOME/.composer/cache
77
- $HOME/symfony-bridge/.phpunit
88

9-
env:
10-
global:
11-
- COMPOSER_PREFER_LOWEST=false
12-
- SYMFONY_DEPRECATIONS_HELPER=weak_vendors
13-
- SYMFONY_PHPUNIT_BRIDGE_VERSION=4.0.*
14-
- SYMFONY_VERSION=3.4.*
15-
- PHPUNIT_FLAGS="-v"
16-
- SYMFONY_PHPUNIT_DIR="$HOME/symfony-bridge/.phpunit"
179
matrix:
1810
fast_finish: true
1911
include:
20-
- php: 7.2
21-
env: SYMFONY_VERSION=4.1.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.1.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
22-
- php: 7.3
23-
env: SYMFONY_VERSION=4.1.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.1.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
24-
- php: 7.1
25-
env: SYMFONY_VERSION=4.2.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.2.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
26-
- php: 7.2
27-
env: SYMFONY_VERSION=4.2.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.2.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
28-
- php: 7.3
29-
env: SYMFONY_VERSION=4.2.* SYMFONY_PHPUNIT_BRIDGE_VERSION=4.2.* SYMFONY_DEPRECATIONS_HELPER=weak_vendors LEVEL=0
12+
- php: 7.2
13+
env: SYMFONY_VERSION="^4.4.0"
14+
- php: 7.3
15+
env: SYMFONY_VERSION="^5.0.0"
3016

3117
before_install:
32-
- echo "memory_limit=2G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
18+
- echo "memory_limit=4G" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
19+
- phpenv config-rm xdebug.ini || true
20+
- composer global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
21+
- if [ "$SYMFONY_VERSION" != "" ]; then composer require --no-update "symfony/framework-bundle:${SYMFONY_VERSION}"; fi;
3322

34-
install:
35-
- composer require --no-update symfony/symfony:${SYMFONY_VERSION}
36-
- composer require --no-update symfony/form:${SYMFONY_VERSION}
37-
- composer require --dev --no-update symfony/phpunit-bridge:${SYMFONY_PHPUNIT_BRIDGE_VERSION}
38-
- composer update --prefer-source `if [[ $COMPOSER_PREFER_LOWEST = true ]]; then echo "--prefer-lowest --prefer-stable"; fi`
23+
install: php -d memory_limit=-1 $(phpenv which composer) update $COMPOSER_FLAGS --no-suggest
3924

4025
script:
41-
- SYMFONY_PHPUNIT_VERSION=6.5 ./vendor/bin/simple-phpunit $PHPUNIT_FLAGS
26+
- ./vendor/bin/phpunit --coverage-text --colors
4227

4328
notifications:
4429

README.md

+6-29
Original file line numberDiff line numberDiff line change
@@ -65,44 +65,22 @@ For Symfony Flex installation you need to enable community recipes:
6565
composer config extra.symfony.allow-contrib true
6666
```
6767

68-
And install
68+
Install
6969

7070
```sh
7171
composer require helios-ag/fm-elfinder-bundle
7272
```
7373

74-
Other way (non flex way) is to add FMElFinderBundle to your composer.json
75-
76-
```json
77-
{
78-
"require": {
79-
"helios-ag/fm-elfinder-bundle": "~9",
80-
}
81-
}
82-
```
83-
84-
also add **component-dir** under **config** node of composer.json
85-
86-
(also you can manually copy assets to this directory)
87-
88-
```json
89-
{
90-
"config": {
91-
"component-dir": "public/assets"
92-
}
93-
}
94-
```
95-
96-
Now tell composer to download the bundle by running the command:
97-
74+
Copy elfinder assets to public folder
9875

9976
```sh
100-
composer update helios-ag/fm-elfinder-bundle
77+
bin/console elfinder:install
10178
```
10279

103-
### Step 2: Enable the bundle
10480

105-
Enable the bundle in the kernel:
81+
### Step 2: Enable the bundle (Optional)
82+
83+
Enable the bundle in the kernel (not needed with symfony flex):
10684

10785
```php
10886
<?php
@@ -169,7 +147,6 @@ fm_elfinder:
169147
#attributes: example of setting attributes permission
170148
# - { pattern: '/(.*?)/', read: true, write: false, locked: true }
171149
```
172-
* **assets_path** - this is where css/js files of the bundle are, this options should be the same as composers `component-dir` option.
173150
* **default** - instance of elfinder, can be used to define multiple configurations of ElFinder, allows simultaneous configuration for different types of WYSIWYG editors in your project
174151
* **path** - define root directory for the files inside web/ directory, default is "uploads". Make sure to set proper write/read and owner permissions to this directory.
175152
* **url** - url to be prefixed to image path, for displaying. Can be either `absolute` or `relative`. If absolute, you can use `{homeFolder}` string as placeholder which will be replaced automatically. If relative, it will be prefixed with the applications base-url. If left blank, url will be the base-url, append with the value of the 'path' parameter

composer.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
"exclude": ["/tests", "./github"]
2121
},
2222
"require": {
23-
"php": "^5.6|^7.0",
24-
"symfony/framework-bundle": "~2.8|~3.0|~4.0",
25-
"symfony/twig-bundle": "~2.8|~3.0|~4.0",
26-
"symfony/form": "~2.8|~3.0|~4.0",
27-
"symfony/asset": "~2.8|~3.0|~4.0",
28-
"components/elfinder": "~3",
29-
"studio-42/elfinder": "~2.1",
30-
"robloach/component-installer": "~0.2"
23+
"php": "^7.2",
24+
"ext-json": "*",
25+
"symfony/framework-bundle": "^4.4 || ^5.0",
26+
"symfony/twig-bundle": "^4.4 || ^5.0",
27+
"symfony/form": "^4.4 || ^5.0",
28+
"symfony/asset": "^4.4 || ^5.0",
29+
"studio-42/elfinder": "~2.1"
3130
},
3231
"require-dev" : {
33-
"symfony/phpunit-bridge": "^4.0",
34-
"matthiasnoback/symfony-config-test": "^3.0",
35-
"matthiasnoback/symfony-dependency-injection-test": "^2",
36-
"symfony/finder": "~3.0|~4.0",
37-
"satooshi/php-coveralls": "~2"
32+
"symfony/phpunit-bridge": "^4.1 || ^5.0",
33+
"matthiasnoback/symfony-config-test": "^4.0",
34+
"matthiasnoback/symfony-dependency-injection-test": "^4.1",
35+
"symfony/finder": "^4.4 || ^5.0",
36+
"php-coveralls/php-coveralls": "^2.0",
37+
"phpunit/phpunit": "^8.5"
3838
},
3939
"suggest": {
4040
"helios-ag/fm-tinymce-bundle": "FMTinyMCEBundle WYSIWYG Editor Bundle",
@@ -51,7 +51,7 @@
5151
},
5252
"extra": {
5353
"branch-alias": {
54-
"dev-master": "9.0-dev"
54+
"dev-master": "10.0-dev"
5555
}
5656
}
5757
}

phpunit.xml.dist

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</listeners>
1818

1919
<testsuites>
20-
<testsuite name="FMRFMBundle test suite">
20+
<testsuite name="FMElfinderBundle test suite">
2121
<directory suffix="Test.php">./tests</directory>
2222
</testsuite>
2323
</testsuites>

src/Bridge/ElFinderBridge.php

-8
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,11 @@
66
use FM\ElfinderBundle\ElFinder\ElFinder;
77
use elFinderVolumeDriver;
88

9-
/**
10-
* Class ElFinderBridge.
11-
*/
129
class ElFinderBridge extends ElFinder
1310
{
1411
/** @var SessionInterface */
1512
protected $session;
1613

17-
/**
18-
* ElFinderBridge constructor.
19-
*
20-
* @param $opts
21-
*/
2214
public function __construct($opts)
2315
{
2416
if ($this->session) {
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace FM\ElfinderBundle\Command;
6+
7+
use Symfony\Component\Console\Command\Command;
8+
use Symfony\Component\Console\Input\InputInterface;
9+
use Symfony\Component\Console\Output\OutputInterface;
10+
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
11+
use Symfony\Component\Filesystem\Filesystem;
12+
13+
final class ElFinderInstallerCommand extends Command
14+
{
15+
private const ELFINDER_CSS_DIR = 'vendor/studio-42/elfinder/css';
16+
17+
private const ELFINDER_JS_DIR = 'vendor/studio-42/elfinder/js';
18+
19+
private const ELFINDER_SOUNDS_DIR = 'vendor/studio-42/elfinder/sounds';
20+
21+
private const ELFINDER_IMG_DIR = 'vendor/studio-42/elfinder/img';
22+
23+
protected static $defaultName = 'elfinder:install';
24+
25+
protected $fileSystem;
26+
27+
protected $parameterBag;
28+
29+
public function __construct(Filesystem $filesystem, ParameterBagInterface $parameterBag)
30+
{
31+
$this->fileSystem = $filesystem;
32+
$this->parameterBag = $parameterBag;
33+
parent::__construct();
34+
}
35+
36+
protected function configure(): void
37+
{
38+
$this
39+
->setDescription('Copies elfinder assets to public directory')
40+
;
41+
}
42+
43+
protected function execute(InputInterface $input, OutputInterface $output): int
44+
{
45+
$publicDir = $this->parameterBag->get('kernel.project_dir').'/public/bundles/fmelfinder';
46+
47+
$this->fileSystem->mirror(self::ELFINDER_CSS_DIR, $publicDir.'/css');
48+
$this->fileSystem->mirror(self::ELFINDER_IMG_DIR, $publicDir.'/img');
49+
$this->fileSystem->mirror(self::ELFINDER_JS_DIR, $publicDir.'/js');
50+
$this->fileSystem->mirror(self::ELFINDER_SOUNDS_DIR, $publicDir.'/sounds');
51+
52+
$output->writeln('elFinder assets successfully installed');
53+
54+
return 0;
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace FM\ElfinderBundle\Configuration;
6+
7+
/**
8+
* Interface ElFinderConfigurationProviderInterface.
9+
*/
10+
interface ElFinderConfigurationProviderInterface
11+
{
12+
public function getConfiguration(string $instance): array;
13+
}

src/Configuration/ElFinderConfigurationReader.php

+11-49
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace FM\ElfinderBundle\Configuration;
44

5-
use FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface;
65
use FM\ElfinderBundle\Security\ElfinderSecurityInterface;
76
use League\Flysystem\AdapterInterface;
87
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -32,46 +31,26 @@
3231
*/
3332
class ElFinderConfigurationReader implements ElFinderConfigurationProviderInterface
3433
{
35-
/**
36-
* @var array
37-
*/
38-
protected $options = array();
34+
/** @var array */
35+
protected $options = [];
3936

40-
/**
41-
* @var array
42-
*/
37+
/** @var array */
4338
protected $parameters;
4439

45-
/**
46-
* @var RequestStack
47-
*/
40+
/** @var RequestStack */
4841
protected $requestStack;
4942

50-
/**
51-
* @var ContainerInterface
52-
*/
43+
/** @var ContainerInterface */
5344
protected $container;
5445

55-
/**
56-
* @param $parameters
57-
* @param \Symfony\Component\HttpFoundation\RequestStack $requestStack
58-
* @param ContainerInterface $container
59-
*/
60-
public function __construct($parameters, RequestStack $requestStack, ContainerInterface $container)
46+
public function __construct(array $parameters, RequestStack $requestStack, ContainerInterface $container)
6147
{
6248
$this->parameters = $parameters;
6349
$this->requestStack = $requestStack;
6450
$this->container = $container;
6551
}
6652

67-
/**
68-
* @param $instance
69-
*
70-
* @return array
71-
*
72-
* @throws \Exception
73-
*/
74-
public function getConfiguration($instance)
53+
public function getConfiguration(string $instance): array
7554
{
7655
$request = $this->requestStack->getCurrentRequest();
7756
$efParameters = $this->parameters;
@@ -166,15 +145,7 @@ public function getConfiguration($instance)
166145
return $options;
167146
}
168147

169-
/**
170-
* @param $parameter
171-
* @param $request
172-
* @param $homeFolder
173-
* @param $path
174-
*
175-
* @return string
176-
*/
177-
private function getURL($parameter, Request $request, $homeFolder, $path)
148+
private function getURL(array $parameter, Request $request, string $homeFolder, string $path): string
178149
{
179150
if (isset($parameter['url']) && $parameter['url']) {
180151
if (0 === strpos($parameter['url'], 'http')) {
@@ -195,8 +166,6 @@ private function getURL($parameter, Request $request, $homeFolder, $path)
195166
* @param $serviceName
196167
*
197168
* @return Filesystem
198-
*
199-
* @throws \MongoConnectionException
200169
*/
201170
private function configureFlysystem($opt, $adapter, $serviceName)
202171
{
@@ -316,7 +285,7 @@ private function configureFlysystem($opt, $adapter, $serviceName)
316285
return $filesystem;
317286
}
318287

319-
private function getFlysystemFilesystem($serviceName)
288+
private function getFlysystemFilesystem(string $serviceName)
320289
{
321290
$filesystem = $this->container->get($serviceName);
322291
if (!is_object($filesystem) || (!$filesystem instanceof Filesystem)) {
@@ -326,14 +295,9 @@ private function getFlysystemFilesystem($serviceName)
326295
return $filesystem;
327296
}
328297

329-
/**
330-
* @param array $parameter
331-
*
332-
* @return array
333-
*/
334-
private function configureDriver(array $parameter)
298+
private function configureDriver(array $parameter): array
335299
{
336-
$settings = array();
300+
$settings = [];
337301

338302
switch (strtolower($parameter['driver'])) {
339303
case 'ftp':
@@ -428,8 +392,6 @@ public function access($attr, $path, $data, $volume)
428392
* @param ElfinderSecurityInterface $voter
429393
*
430394
* @return array
431-
*
432-
* @throws \Exception
433395
*/
434396
protected function parseSecurityConfiguration(ElfinderSecurityInterface $voter)
435397
{

src/Connector/ElFinderConnector.php

-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44

55
use elFinder;
66

7-
/**
8-
* Class ElFinderConnector.
9-
*/
107
class ElFinderConnector extends \elFinderConnector
118
{
129
public function run($queryParameters = null)

0 commit comments

Comments
 (0)