Add Ftp Adapter
This commit is contained in:
59
DependencyInjection/Factory/FtpAdapterFactory.php
Normal file
59
DependencyInjection/Factory/FtpAdapterFactory.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?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_BINARY)->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user