33namespace CKSource \Bundle \CKFinderBundle \Factory ;
44
55use CKSource \Bundle \CKFinderBundle \Authentication \AuthenticationInterface ;
6- use CKSource \Bundle \CKFinderBundle \Polyfill \CommandResolver ;
76use CKSource \CKFinder \CKFinder ;
8- use Symfony \Component \HttpKernel \HttpKernel ;
9- use Symfony \Component \HttpKernel \Kernel ;
107
118class ConnectorFactory
129{
1310 /**
1411 * @var array
1512 */
16- protected $ connectorConfig ;
13+ protected array $ connectorConfig ;
1714
1815 /**
1916 * @var AuthenticationInterface
2017 */
21- protected $ authenticationService ;
18+ protected AuthenticationInterface $ authenticationService ;
2219
2320 /**
24- * @var CKFinder
21+ * @var ? CKFinder
2522 */
26- protected $ connectorInstance ;
23+ protected ? CKFinder $ connectorInstance = null ;
2724
2825 /**
2926 * ConnectorFactory constructor.
3027 *
31- * @param $connectorConfig
32- * @param $authenticationService
28+ * @param array $connectorConfig
29+ * @param AuthenticationInterface $authenticationService
3330 */
34- public function __construct ($ connectorConfig , $ authenticationService )
31+ public function __construct (array $ connectorConfig , AuthenticationInterface $ authenticationService )
3532 {
3633 $ this ->connectorConfig = $ connectorConfig ;
3734 $ this ->authenticationService = $ authenticationService ;
@@ -40,7 +37,7 @@ public function __construct($connectorConfig, $authenticationService)
4037 /**
4138 * @return CKFinder
4239 */
43- public function getConnector ()
40+ public function getConnector (): CKFinder
4441 {
4542 if ($ this ->connectorInstance ) {
4643 return $ this ->connectorInstance ;
@@ -50,36 +47,8 @@ public function getConnector()
5047
5148 $ connector ['authentication ' ] = $ this ->authenticationService ;
5249
53- if (Kernel::MAJOR_VERSION === 4 ) {
54- $ this ->setupForV4Kernel ($ connector );
55- }
56-
5750 $ this ->connectorInstance = $ connector ;
5851
5952 return $ connector ;
6053 }
61-
62- /**
63- * Prepares the internal CKFinder's DI container to use the version 4+ of HttpKernel.
64- *
65- * @param \CKSource\CKFinder\CKFinder $ckfinder
66- */
67- protected function setupForV4Kernel ($ ckfinder )
68- {
69- $ ckfinder ['resolver ' ] = function () use ($ ckfinder ) {
70- $ commandResolver = new CommandResolver ($ ckfinder );
71- $ commandResolver ->setCommandsNamespace (CKFinder::COMMANDS_NAMESPACE );
72- $ commandResolver ->setPluginsNamespace (CKFinder::PLUGINS_NAMESPACE );
73- return $ commandResolver ;
74- };
75-
76- $ ckfinder ['kernel ' ] = function () use ($ ckfinder ) {
77- return new HttpKernel (
78- $ ckfinder ['dispatcher ' ],
79- $ ckfinder ['resolver ' ],
80- $ ckfinder ['request_stack ' ],
81- $ ckfinder ['resolver ' ]
82- );
83- };
84- }
8554}
0 commit comments