commit
2d7666a413
64
DependencyInjection/Factory/FtpAdapterFactory.php
Normal file
64
DependencyInjection/Factory/FtpAdapterFactory.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Knp\Bundle\GaufretteBundle\DependencyInjection\Factory;
|
||||||
|
|
||||||
|
use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
||||||
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ftp Adapter Factory
|
||||||
|
*/
|
||||||
|
class FtpAdapterFactory implements AdapterFactoryInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function create(ContainerBuilder $container, $id, array $config)
|
||||||
|
{
|
||||||
|
$container
|
||||||
|
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.ftp'))
|
||||||
|
->addArgument($config['directory'])
|
||||||
|
->addArgument($config['host'])
|
||||||
|
->addArgument($config['username'])
|
||||||
|
->addArgument($config['password'])
|
||||||
|
->addArgument($config['port'])
|
||||||
|
->addArgument($config['passive'])
|
||||||
|
->addArgument($config['create'])
|
||||||
|
->addArgument($config['mode'])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function getKey()
|
||||||
|
{
|
||||||
|
return 'ftp';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function addConfiguration(NodeDefinition $builder)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->children()
|
||||||
|
->scalarNode('directory')->isRequired()->end()
|
||||||
|
->scalarNode('host')->isRequired()->end()
|
||||||
|
->scalarNode('port')->defaultValue(21)->end()
|
||||||
|
->scalarNode('username')->defaultNull()->end()
|
||||||
|
->scalarNode('password')->defaultNull()->end()
|
||||||
|
->booleanNode('passive')->defaultFalse()->end()
|
||||||
|
->booleanNode('create')->defaultFalse()->end()
|
||||||
|
->scalarNode('mode')
|
||||||
|
->defaultValue(FTP_ASCII)
|
||||||
|
->beforeNormalization()
|
||||||
|
->ifString()
|
||||||
|
->then(function($v) { return constant($v); })
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
|
@ -284,3 +284,34 @@ knp_gaufrette:
|
||||||
```
|
```
|
||||||
|
|
||||||
[gaufrette-homepage]: https://github.com/KnpLabs/Gaufrette
|
[gaufrette-homepage]: https://github.com/KnpLabs/Gaufrette
|
||||||
|
|
||||||
|
## Ftp
|
||||||
|
|
||||||
|
Adapter for FTP.
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
* `directory` The directory of the filesystem *(required)*
|
||||||
|
* `host` FTP host *(required)*
|
||||||
|
* `username` FTP username *(default null)*
|
||||||
|
* `password` FTP password *(default null)*
|
||||||
|
* `port` FTP port *(default 21)*
|
||||||
|
* `passive` FTP passive mode *(default false)*
|
||||||
|
* `create` Whether to create the directory if it does not exist *(default false)*
|
||||||
|
* `mode` FTP transfer mode *(defaut FTP_ASCII)*
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
# app/config/config.yml
|
||||||
|
knp_gaufrette:
|
||||||
|
adapters:
|
||||||
|
foo:
|
||||||
|
ftp:
|
||||||
|
host: example.com
|
||||||
|
username: user
|
||||||
|
password: pass
|
||||||
|
directory: /example/ftp
|
||||||
|
create: true
|
||||||
|
mode: FTP_BINARY
|
||||||
|
```
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
<service id="knp_gaufrette.adapter.factory.mogilefs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\MogileFSAdapterFactory">
|
<service id="knp_gaufrette.adapter.factory.mogilefs" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\MogileFSAdapterFactory">
|
||||||
<tag name="gaufrette.adapter.factory" />
|
<tag name="gaufrette.adapter.factory" />
|
||||||
</service>
|
</service>
|
||||||
|
<service id="knp_gaufrette.adapter.factory.ftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\FtpAdapterFactory">
|
||||||
|
<tag name="gaufrette.adapter.factory" />
|
||||||
|
</service>
|
||||||
|
|
||||||
</services>
|
</services>
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
<argument /><!-- domain -->
|
<argument /><!-- domain -->
|
||||||
<argument /><!-- hosts -->
|
<argument /><!-- hosts -->
|
||||||
</service>
|
</service>
|
||||||
|
<service id="knp_gaufrette.adapter.ftp" class="Gaufrette\Adapter\Ftp" abstract="true" public="false" />
|
||||||
<service id="knp_gaufrette.filesystem_map" class="Knp\Bundle\GaufretteBundle\FilesystemMap">
|
<service id="knp_gaufrette.filesystem_map" class="Knp\Bundle\GaufretteBundle\FilesystemMap">
|
||||||
<argument /> <!-- map of filesystems -->
|
<argument /> <!-- map of filesystems -->
|
||||||
</service>
|
</service>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user