Merge pull request #16 from Romain-Geissler/master
Add SftpAdapterFactory
This commit is contained in:
commit
790652531f
49
DependencyInjection/Factory/SftpAdapterFactory.php
Normal file
49
DependencyInjection/Factory/SftpAdapterFactory.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sftp Adapter Factory
|
||||||
|
*/
|
||||||
|
class SftpAdapterFactory implements AdapterFactoryInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function create(ContainerBuilder $container, $id, array $config)
|
||||||
|
{
|
||||||
|
$container
|
||||||
|
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.sftp'))
|
||||||
|
->addArgument(new Reference($config['sftp_id']))
|
||||||
|
->addArgument($config['directory'])
|
||||||
|
->addArgument($config['create'])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function getKey()
|
||||||
|
{
|
||||||
|
return 'sftp';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
function addConfiguration(NodeDefinition $builder)
|
||||||
|
{
|
||||||
|
$builder
|
||||||
|
->children()
|
||||||
|
->scalarNode('sftp_id')->isRequired()->end()
|
||||||
|
->scalarNode('directory')->defaultNull()->end()
|
||||||
|
->booleanNode('create')->defaultFalse()->end()
|
||||||
|
->end()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
|
@ -321,6 +321,56 @@ knp_gaufrette:
|
||||||
mode: FTP_BINARY
|
mode: FTP_BINARY
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Sftp
|
||||||
|
|
||||||
|
Adapter for SFTP (SSH-FTP).
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
|
||||||
|
* `sftp_id` The id of the service that provides SFTP access.
|
||||||
|
* `directory* The distant directory *(default null)*.
|
||||||
|
* `create` Whether to create the directory if it does not exist *(default false)*.
|
||||||
|
|
||||||
|
### Example
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
# app/config/config.yml
|
||||||
|
knp_gaufrette:
|
||||||
|
adapters:
|
||||||
|
foo:
|
||||||
|
sftp:
|
||||||
|
sftp_id: acme_test.sftp
|
||||||
|
directory: /example/sftp
|
||||||
|
create: true
|
||||||
|
```
|
||||||
|
|
||||||
|
In your AcmeTestBundle, add following service definitions:
|
||||||
|
|
||||||
|
``` yaml
|
||||||
|
# src/Acme/TestBundle/Resources/config/services.yml
|
||||||
|
parameters:
|
||||||
|
acme_test.ssh.host: my_host_name
|
||||||
|
acme_test.ssh.username: user_name
|
||||||
|
acme_test.ssh.password: some_secret
|
||||||
|
|
||||||
|
services:
|
||||||
|
acme_test.ssh.configuration:
|
||||||
|
class: Ssh\Configuration
|
||||||
|
arguments: [%acme_test.ssh.host%]
|
||||||
|
|
||||||
|
acme_test.ssh.authentication:
|
||||||
|
class: Ssh\Authentication\Password
|
||||||
|
arguments: [%acme_test.ssh.username%, %acme_test.ssh.password%]
|
||||||
|
|
||||||
|
acme_test.ssh.session:
|
||||||
|
class: Ssh\Session
|
||||||
|
arguments: [@acme_test.ssh.configuration, @acme_test.ssh.authentication]
|
||||||
|
|
||||||
|
acme_test.sftp:
|
||||||
|
class: Ssh\Sftp
|
||||||
|
arguments: [@acme_test.ssh.session]
|
||||||
|
```
|
||||||
|
|
||||||
## Apc
|
## Apc
|
||||||
|
|
||||||
Adapter for APC.
|
Adapter for APC.
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
<service id="knp_gaufrette.adapter.factory.ftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\FtpAdapterFactory">
|
<service id="knp_gaufrette.adapter.factory.ftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\FtpAdapterFactory">
|
||||||
<tag name="gaufrette.adapter.factory" />
|
<tag name="gaufrette.adapter.factory" />
|
||||||
</service>
|
</service>
|
||||||
|
<service id="knp_gaufrette.adapter.factory.sftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\SftpAdapterFactory">
|
||||||
|
<tag name="gaufrette.adapter.factory" />
|
||||||
|
</service>
|
||||||
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
|
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
|
||||||
<tag name="gaufrette.adapter.factory" />
|
<tag name="gaufrette.adapter.factory" />
|
||||||
</service>
|
</service>
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
<argument /><!-- hosts -->
|
<argument /><!-- hosts -->
|
||||||
</service>
|
</service>
|
||||||
<service id="knp_gaufrette.adapter.ftp" class="Gaufrette\Adapter\Ftp" abstract="true" public="false" />
|
<service id="knp_gaufrette.adapter.ftp" class="Gaufrette\Adapter\Ftp" abstract="true" public="false" />
|
||||||
|
<service id="knp_gaufrette.adapter.sftp" class="Gaufrette\Adapter\Sftp" abstract="true" public="false" />
|
||||||
<service id="knp_gaufrette.adapter.apc" class="Gaufrette\Adapter\Apc" abstract="true" public="false">
|
<service id="knp_gaufrette.adapter.apc" class="Gaufrette\Adapter\Apc" abstract="true" public="false">
|
||||||
<argument /><!-- prefix -->
|
<argument /><!-- prefix -->
|
||||||
<argument /><!-- ttl -->
|
<argument /><!-- ttl -->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user