Skip to content

Commit 7ada616

Browse files
committed
Update for Symfony 6
1 parent d303b2e commit 7ada616

File tree

19 files changed

+81
-194
lines changed

19 files changed

+81
-194
lines changed

Authentication/Authentication.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt

Authentication/AuthenticationInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt

CKSourceCKFinderBundle.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt
@@ -12,6 +12,7 @@
1212
namespace CKSource\Bundle\CKFinderBundle;
1313

1414
use CKSource\Bundle\CKFinderBundle\DependencyInjection\CKSourceCKFinderExtension;
15+
use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
1516
use Symfony\Component\HttpKernel\Bundle\Bundle;
1617

1718
/**
@@ -22,7 +23,7 @@ class CKSourceCKFinderBundle extends Bundle
2223
/**
2324
* {@inheritdoc}
2425
*/
25-
public function getContainerExtension()
26+
public function getContainerExtension(): ?ExtensionInterface
2627
{
2728
return new CKSourceCKFinderExtension();
2829
}

Command/CKFinderDownloadCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt
@@ -26,8 +26,7 @@
2626
*/
2727
class CKFinderDownloadCommand extends Command
2828
{
29-
const LATEST_VERSION = '3.5.3';
30-
const FALLBACK_VERSION = '3.5.1';
29+
const LATEST_VERSION = '3.6.0';
3130

3231
/**
3332
* {@inheritdoc}
@@ -45,7 +44,7 @@ protected function configure()
4544
*/
4645
protected function buildPackageUrl()
4746
{
48-
$packageVersion = Kernel::MAJOR_VERSION >= 5 ? self::LATEST_VERSION : self::FALLBACK_VERSION;
47+
$packageVersion = self::LATEST_VERSION;
4948

5049
return "http://download.cksource.com/CKFinder/CKFinder%20for%20PHP/$packageVersion/ckfinder_php_$packageVersion.zip";
5150
}

Config/Definition/Builder/VariableArrayNodeDefinition.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt
@@ -29,7 +29,7 @@ class VariableArrayNodeDefinition extends VariableNodeDefinition
2929
/**
3030
* {@inheritdoc}
3131
*/
32-
protected function instantiateNode()
32+
protected function instantiateNode(): VariableArrayNode
3333
{
3434
return new VariableArrayNode($this->name, $this->parent, $this->requiredKeys);
3535
}

Config/Definition/VariableArrayNode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt
@@ -64,7 +64,7 @@ protected function validateType($value)
6464
/**
6565
* {@inheritdoc}
6666
*/
67-
protected function finalizeValue($value)
67+
protected function finalizeValue($value): mixed
6868
{
6969
foreach ($this->requiredKeys as $requiredKey) {
7070
if (!array_key_exists($requiredKey, $value)) {
@@ -82,7 +82,7 @@ protected function finalizeValue($value)
8282
/**
8383
* {@inheritdoc}
8484
*/
85-
protected function mergeValues($leftSide, $rightSide)
85+
protected function mergeValues($leftSide, $rightSide): mixed
8686
{
8787
return array_replace_recursive($leftSide, $rightSide);
8888
}

Controller/CKFinderController.php

Lines changed: 22 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt
@@ -12,59 +12,33 @@
1212
namespace CKSource\Bundle\CKFinderBundle\Controller;
1313

1414
use CKSource\Bundle\CKFinderBundle\Form\Type\CKFinderFileChooserType;
15+
use CKSource\CKFinder\CKFinder;
1516
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
16-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
17-
use Symfony\Component\DependencyInjection\ContainerInterface;
1817
use Symfony\Component\Form\Extension\Core\Type\DateType;
19-
use Symfony\Component\Form\Extension\Core\Type\FormType;
2018
use Symfony\Component\Form\Extension\Core\Type\TextType;
2119
use Symfony\Component\HttpFoundation\Request;
2220
use Symfony\Component\HttpFoundation\Response;
2321

2422
/**
2523
* Controller for handling requests to CKFinder connector.
2624
*/
27-
class CKFinderController implements ContainerAwareInterface
25+
class CKFinderController extends AbstractController
2826
{
29-
/**
30-
* @var ContainerInterface
31-
*/
32-
protected $container;
33-
34-
/**
35-
* {@inheritDoc}
36-
*/
37-
public function setContainer(ContainerInterface $container = null)
38-
{
39-
$this->container = $container;
40-
}
41-
4227
/**
4328
* Action that handles all CKFinder requests.
44-
*
45-
* @param Request $request
46-
*
47-
* @return \Symfony\Component\HttpFoundation\Response
4829
*/
49-
public function requestAction(Request $request)
30+
public function requestAction(Request $request): Response
5031
{
51-
/* @var \CKSource\CKFinder\CKFinder $ckfinder */
52-
$ckfinder = $this->container->get('ckfinder.connector');
53-
54-
return $ckfinder->handle($request);
32+
return $this->container->get('ckfinder.connector')->handle($request);
5533
}
5634

5735
/**
5836
* Action for CKFinder usage examples.
5937
*
60-
* To browse examples, please uncomment ckfinder_examplesroute in
61-
* Resources/config/routing.yml and navigate to the /ckfinder/examples path.
62-
*
63-
* @param string|null $example
64-
*
65-
* @return \Symfony\Component\HttpFoundation\Response
38+
* To browse examples, please uncomment ckfinder_examples route in
39+
* Resources/config/routing.yaml and navigate to the /ckfinder/examples path.
6640
*/
67-
public function examplesAction($example = null)
41+
public function examplesAction(?string $example = null): Response
6842
{
6943
switch ($example) {
7044
case 'fullpage':
@@ -80,47 +54,37 @@ public function examplesAction($example = null)
8054
case 'ckeditor5':
8155
return $this->render('@CKSourceCKFinder/examples/ckeditor5.html.twig');
8256
case 'filechooser':
83-
$formBuilder = $this->container->get('form.factory')->createBuilder(FormType::class);
57+
$formBuilder = $this->container->get('form.factory')->createBuilder();
8458
$form = $formBuilder
8559
->add('foo', TextType::class)
8660
->add('bar', DateType::class)
87-
->add('ckf1', CKFinderFileChooserType::class, array(
61+
->add('ckf1', CKFinderFileChooserType::class, [
8862
'label' => 'File Chooser 1',
8963
'button_text' => 'Browse files (popup)',
90-
'button_attr' => array(
64+
'button_attr' => [
9165
'class' => 'my-class'
92-
)
93-
))
94-
->add('ckf2', CKFinderFileChooserType::class, array(
66+
]
67+
])
68+
->add('ckf2', CKFinderFileChooserType::class, [
9569
'label' => 'File Chooser 2',
9670
'mode' => 'modal',
9771
'button_text' => 'Browse files (modal)',
98-
))
72+
])
9973
->getForm();
10074

101-
return $this->render('@CKSourceCKFinder/examples/filechooser.html.twig', array(
75+
return $this->render('@CKSourceCKFinder/examples/filechooser.html.twig', [
10276
'form' => $form->createView()
103-
));
77+
]);
10478
}
10579

10680
return $this->render('@CKSourceCKFinder/examples/index.html.twig');
10781
}
10882

109-
/**
110-
* @param $viewName
111-
* @param array $parameters
112-
* @return Response
113-
*/
114-
protected function render($viewName, $parameters = [])
83+
public static function getSubscribedServices(): array
11584
{
116-
if (!$this->container->has('twig')) {
117-
throw new \LogicException('Twig Bundle is not available. Try running "composer require symfony/twig-bundle".');
118-
}
119-
120-
$twig = $this->container->get('twig');
121-
122-
$content = $twig->render($viewName, $parameters);
123-
124-
return new Response($content);
85+
return [
86+
'ckfinder.connector' => 'CKSource\CKFinder\CKFinder',
87+
...parent::getSubscribedServices()
88+
];
12589
}
12690
}

DependencyInjection/CKSourceCKFinderExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt
@@ -64,7 +64,7 @@ public function load(array $configs, ContainerBuilder $container)
6464
/**
6565
* @return string
6666
*/
67-
public function getAlias()
67+
public function getAlias(): string
6868
{
6969
return 'ckfinder';
7070
}

DependencyInjection/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt

Form/Type/CKFinderFileChooserType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* This file is a part of the CKFinder bundle for Symfony.
44
*
5-
* Copyright (C) 2016, CKSource - Frederico Knabben. All rights reserved.
5+
* Copyright (c) 2022, CKSource Holding sp. z o.o. All rights reserved.
66
*
77
* Licensed under the terms of the MIT license.
88
* For the full copyright and license information, please view the LICENSE.txt

0 commit comments

Comments
 (0)