Skip to content

Commit

Permalink
Merge pull request #88 from matchory/feature/add-missing-options
Browse files Browse the repository at this point in the history
Added missing options to FTP adapter
  • Loading branch information
tgalopin authored Apr 22, 2022
2 parents 10b726c + b07d18b commit 9c3f823
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/Adapter/Builder/FtpAdapterDefinitionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,36 @@ protected function configureOptions(OptionsResolver $resolver)

$resolver->setDefault('utf8', false);
$resolver->setAllowedTypes('utf8', 'scalar');

$resolver->setDefault('transfer_mode', null);
$resolver->setAllowedTypes('transfer_mode', ['null', 'scalar']);
$resolver->setAllowedValues('transfer_mode', [null, FTP_ASCII, FTP_BINARY]);

$resolver->setDefault('system_type', null);
$resolver->setAllowedTypes('system_type', ['null', 'string']);
$resolver->setAllowedValues('system_type', [null, 'windows', 'unix']);

$resolver->setDefault('timestamps_on_unix_listings_enabled', false);
$resolver->setAllowedTypes('timestamps_on_unix_listings_enabled', 'bool');

$resolver->setDefault('recurse_manually', true);
$resolver->setAllowedTypes('recurse_manually', 'bool');
}

protected function configureDefinition(Definition $definition, array $options)
{
$options['transferMode'] = $options['transfer_mode'];
$options['systemType'] = $options['system_type'];
$options['timestampsOnUnixListingsEnabled'] = $options['timestamps_on_unix_listings_enabled'];
$options['ignorePassiveAddress'] = $options['ignore_passive_address'];
unset($options['ignore_passive_address']);
$options['recurseManually'] = $options['recurse_manually'];
unset(
$options['transfer_mode'],
$options['system_type'],
$options['timestamps_on_unix_listings_enabled'],
$options['ignore_passive_address'],
$options['recurse_manually']
);

$definition->setClass(FtpAdapter::class);
$definition->setArgument(0,
Expand Down
4 changes: 4 additions & 0 deletions tests/Adapter/Builder/FtpAdapterDefinitionBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ public function testOptionsBehavior()
'host' => 'ftp.example.com',
'username' => 'username',
'password' => 'password',
'transferMode' => null,
'systemType' => null,
'timestampsOnUnixListingsEnabled' => false,
'ignorePassiveAddress' => true,
'recurseManually' => true,
];

$this->assertSame(FtpAdapter::class, $definition->getClass());
Expand Down

0 comments on commit 9c3f823

Please sign in to comment.