Add Ftp Adapter

This commit is contained in:
Vincent 2011-12-06 14:42:01 +01:00
parent e1c7a3b06d
commit 9078e8e667
3 changed files with 63 additions and 0 deletions

View 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()
;
}
}

View File

@ -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>

View File

@ -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>