1111
1212namespace League \FlysystemBundle \Adapter \Builder ;
1313
14- use League \Flysystem \PhpseclibV2 \SftpAdapter ;
15- use League \Flysystem \PhpseclibV2 \SftpConnectionProvider ;
14+ use League \Flysystem \PhpseclibV2 \SftpAdapter as SftpAdapterLegacy ;
15+ use League \Flysystem \PhpseclibV2 \SftpConnectionProvider as SftpConnectionProviderLegacy ;
16+ use League \Flysystem \PhpseclibV3 \SftpAdapter ;
17+ use League \Flysystem \PhpseclibV3 \SftpConnectionProvider ;
1618use Symfony \Component \DependencyInjection \Definition ;
1719use Symfony \Component \OptionsResolver \OptionsResolver ;
1820
@@ -30,8 +32,19 @@ public function getName(): string
3032
3133 protected function getRequiredPackages (): array
3234 {
35+ $ adapterFqcn = SftpAdapter::class;
36+ $ packageRequire = 'league/flysystem-sftp-v3 ' ;
37+
38+ // Prevent BC
39+ if (class_exists (SftpAdapterLegacy::class)) {
40+ trigger_deprecation ('league/flysystem-bundle ' , '2.2 ' , '"league/flysystem-sftp" is deprecated, use "league/flysystem-sftp-v3" instead. ' );
41+
42+ $ adapterFqcn = SftpAdapterLegacy::class;
43+ $ packageRequire = 'league/flysystem-sftp ' ;
44+ }
45+
3346 return [
34- SftpAdapter::class => ' league/flysystem-sftp ' ,
47+ $ adapterFqcn => $ packageRequire ,
3548 ];
3649 }
3750
@@ -70,10 +83,18 @@ protected function configureOptions(OptionsResolver $resolver)
7083
7184 protected function configureDefinition (Definition $ definition , array $ options )
7285 {
73- $ definition ->setClass (SftpAdapter::class);
86+ // Prevent BC
87+ $ adapterFqcn = SftpAdapter::class;
88+ $ connectionFqcn = SftpConnectionProvider::class;
89+ if (class_exists (SftpAdapterLegacy::class)) {
90+ $ adapterFqcn = SftpAdapterLegacy::class;
91+ $ connectionFqcn = SftpConnectionProviderLegacy::class;
92+ }
93+
94+ $ definition ->setClass ($ adapterFqcn );
7495 $ definition ->setArgument (0 ,
75- (new Definition (SftpConnectionProvider::class ))
76- ->setFactory ([SftpConnectionProvider::class , 'fromArray ' ])
96+ (new Definition ($ connectionFqcn ))
97+ ->setFactory ([$ connectionFqcn , 'fromArray ' ])
7798 ->addArgument ($ options )
7899 ->setShared (false )
79100 );
0 commit comments