2011-12-06 13:42:01 +00:00
|
|
|
<?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'])
|
2012-11-20 09:15:40 +00:00
|
|
|
->addArgument($config)
|
2011-12-06 13:42:01 +00:00
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@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()
|
2011-12-07 09:42:40 +00:00
|
|
|
->scalarNode('mode')
|
2012-08-01 15:36:59 +00:00
|
|
|
->defaultValue(defined('FTP_ASCII') ? FTP_ASCII : null)
|
2011-12-07 09:42:40 +00:00
|
|
|
->beforeNormalization()
|
|
|
|
->ifString()
|
|
|
|
->then(function($v) { return constant($v); })
|
|
|
|
->end()
|
2011-12-06 13:42:01 +00:00
|
|
|
->end()
|
|
|
|
;
|
|
|
|
}
|
2011-12-06 16:21:01 +00:00
|
|
|
}
|