Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7edea6cfcc | ||
|
|
bf9652537f | ||
|
|
b6dbd93d12 | ||
|
|
b8596b4ca1 | ||
|
|
0536334f7c | ||
|
|
b928e97767 | ||
|
|
6878189ba2 | ||
|
|
5b1463cdc5 | ||
|
|
c88039e80c | ||
|
|
a075802e29 | ||
|
|
b6d58c99c3 | ||
|
|
ce0e00c554 | ||
|
|
b2a387580e | ||
|
|
d1eb6f2550 | ||
|
|
ef57204cd5 | ||
|
|
ae598e6114 |
@@ -20,6 +20,7 @@ class AwsS3AdapterFactory implements AdapterFactoryInterface
|
||||
->addArgument(new Reference($config['service_id']))
|
||||
->addArgument($config['bucket_name'])
|
||||
->addArgument($config['options'])
|
||||
->addArgument($config['detect_content_type'])
|
||||
;
|
||||
}
|
||||
|
||||
@@ -40,6 +41,7 @@ class AwsS3AdapterFactory implements AdapterFactoryInterface
|
||||
->children()
|
||||
->scalarNode('service_id')->isRequired()->cannotBeEmpty()->end()
|
||||
->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()
|
||||
->booleanNode('detect_content_type')->defaultFalse()->end()
|
||||
->arrayNode('options')
|
||||
->addDefaultsIfNotSet()
|
||||
->children()
|
||||
|
||||
49
DependencyInjection/Factory/PhpseclibSftpAdapterFactory.php
Normal file
49
DependencyInjection/Factory/PhpseclibSftpAdapterFactory.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;
|
||||
|
||||
/**
|
||||
* Phpseclib Sftp Adapter Factory
|
||||
*/
|
||||
class PhpseclibSftpAdapterFactory implements AdapterFactoryInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function create(ContainerBuilder $container, $id, array $config)
|
||||
{
|
||||
$container
|
||||
->setDefinition($id, new DefinitionDecorator('knp_gaufrette.adapter.phpseclib_sftp'))
|
||||
->addArgument(new Reference($config['phpseclib_sftp_id']))
|
||||
->addArgument($config['directory'])
|
||||
->addArgument($config['create'])
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function getKey()
|
||||
{
|
||||
return 'phpseclib_sftp';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
function addConfiguration(NodeDefinition $builder)
|
||||
{
|
||||
$builder
|
||||
->children()
|
||||
->scalarNode('phpseclib_sftp_id')->isRequired()->end()
|
||||
->scalarNode('directory')->defaultNull()->end()
|
||||
->booleanNode('create')->defaultFalse()->end()
|
||||
->end()
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -28,21 +28,15 @@ class KnpGaufretteExtension extends Extension
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$processor = new Processor();
|
||||
|
||||
// first assemble the adapter factories
|
||||
$factoryConfig = new FactoryConfiguration();
|
||||
$config = $processor->processConfiguration($factoryConfig, $configs);
|
||||
$factories = $this->createAdapterFactories($config, $container);
|
||||
|
||||
// then normalize the configs
|
||||
$mainConfig = new MainConfiguration($factories);
|
||||
$config = $processor->processConfiguration($mainConfig, $configs);
|
||||
$config = $processor->processConfiguration($this->getConfiguration($configs, $container), $configs);
|
||||
|
||||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
$loader->load('gaufrette.xml');
|
||||
|
||||
$adapters = array();
|
||||
|
||||
foreach ($config['adapters'] as $name => $adapter) {
|
||||
$adapters[$name] = $this->createAdapter($name, $adapter, $container, $factories);
|
||||
$adapters[$name] = $this->createAdapter($name, $adapter, $container, $this->factories);
|
||||
}
|
||||
|
||||
$map = array();
|
||||
@@ -59,6 +53,19 @@ class KnpGaufretteExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
public function getConfiguration(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
$processor = new Processor();
|
||||
|
||||
// first assemble the adapter factories
|
||||
$factoryConfig = new FactoryConfiguration();
|
||||
$config = $processor->processConfiguration($factoryConfig, $configs);
|
||||
$factories = $this->createAdapterFactories($config, $container);
|
||||
|
||||
// then normalize the configs
|
||||
return new MainConfiguration($factories);
|
||||
}
|
||||
|
||||
private function createAdapter($name, array $config, ContainerBuilder $container, array $factories)
|
||||
{
|
||||
$adapter = null;
|
||||
|
||||
@@ -18,56 +18,17 @@ Installation
|
||||
|
||||
As this bundle is an integration for Symfony of the [Gaufrette][gaufrette-homepage] library, it requires you to first install [Gaufrette][gaufrette-homepage] in a Symfony project.
|
||||
|
||||
## Download the bundle
|
||||
## With composer
|
||||
|
||||
You can download an archive of the bundle and unpack it in the `vendor/bundles/Knp/Bundle/GaufretteBundle` directory of your application.
|
||||
This bundle can be installed using [composer](http://getcomposer.org) by adding the following in the `require` section of your `composer.json` file:
|
||||
|
||||
### Standard Edition Style
|
||||
|
||||
If you are using the `deps` file to manage your project's dependencies,
|
||||
you must add the following lines to it:
|
||||
|
||||
[gaufrette]
|
||||
git=http://github.com/KnpLabs/Gaufrette.git
|
||||
|
||||
[KnpGaufretteBundle]
|
||||
git=http://github.com/KnpLabs/KnpGaufretteBundle.git
|
||||
target=/bundles/Knp/Bundle/GaufretteBundle
|
||||
|
||||
### Composer Style
|
||||
|
||||
This bundle can be installed using composer by adding the following in the `require` section of your `composer.json` file:
|
||||
|
||||
```
|
||||
``` json
|
||||
"require": {
|
||||
...
|
||||
"knplabs/knp-gaufrette-bundle": "dev-master"
|
||||
"knplabs/knp-gaufrette-bundle": "*@dev"
|
||||
},
|
||||
```
|
||||
|
||||
### Git Submodule Style
|
||||
|
||||
If you are versioning your project with git and making changes to this bundle you can embed it as a submodule:
|
||||
|
||||
$ git submodule add https://github.com/KnpLabs/KnpGaufretteBundle.git vendor/bundles/Knp/Bundle/GaufretteBundle
|
||||
|
||||
## Add the namespace in the autoloader
|
||||
|
||||
You must register both Gaufrette and the KnpGaufretteBundle in your autoloader:
|
||||
(You do not have to do this if you are using the composer autoload system.)
|
||||
|
||||
``` php
|
||||
<?php
|
||||
|
||||
// app/autoload.php
|
||||
|
||||
$loader->addClassMap(array(
|
||||
'Knp\Bundle' => __DIR__.'/../vendor/bundles',
|
||||
'Gaufrette' => __DIR__.'/../vendor/gaufrette/src',
|
||||
// ...
|
||||
));
|
||||
```
|
||||
|
||||
## Register the bundle
|
||||
|
||||
You must register the bundle in your kernel:
|
||||
@@ -414,6 +375,47 @@ services:
|
||||
arguments: [@acme_test.ssh.session]
|
||||
```
|
||||
|
||||
## Phpseclib Sftp (phpseclib_sftp)
|
||||
|
||||
Adapter for phpseclib SFTP (SSH-FTP).
|
||||
|
||||
### Parameters
|
||||
|
||||
* `phpseclib_sftp_id` The id of the service that provides SFTP access.
|
||||
* `directory` The remote 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:
|
||||
phpseclib_sftp:
|
||||
phpseclib_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.sftp:
|
||||
class: Net_SFTP
|
||||
arguments: [%acme_test.ssh.host%]
|
||||
calls:
|
||||
- [login, [%acme_test.ssh.username%, %acme_test.ssh.password%]]
|
||||
|
||||
```
|
||||
|
||||
## Apc (apc)
|
||||
|
||||
Adapter for APC.
|
||||
@@ -620,7 +622,7 @@ services:
|
||||
opencloud.object_store:
|
||||
class: OpenCloud\ObjectStoreBase
|
||||
factory_service: opencloud.connection
|
||||
factory_method: ObjectStore
|
||||
factory_method: objectStoreService
|
||||
arguments:
|
||||
- 'cloudFiles' # Object storage type
|
||||
- 'DFW' # Object storage region
|
||||
@@ -811,7 +813,7 @@ knp_gaufrette:
|
||||
|
||||
## Dropbox (dropbox)
|
||||
|
||||
Adapter for Dropbox.
|
||||
Adapter for Dropbox. In order to use it, you should add `dropbox-php/dropbox-php` as your composer dependency.
|
||||
|
||||
### Parameters
|
||||
|
||||
|
||||
@@ -47,6 +47,9 @@
|
||||
<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.phpseclib_sftp" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\PhpseclibSftpAdapterFactory">
|
||||
<tag name="gaufrette.adapter.factory" />
|
||||
</service>
|
||||
<service id="knp_gaufrette.adapter.factory.apc" class="Knp\Bundle\GaufretteBundle\DependencyInjection\Factory\ApcAdapterFactory">
|
||||
<tag name="gaufrette.adapter.factory" />
|
||||
</service>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
</service>
|
||||
<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.phpseclib_sftp" class="Gaufrette\Adapter\PhpseclibSftp" abstract="true" public="false" />
|
||||
<service id="knp_gaufrette.adapter.apc" class="Gaufrette\Adapter\Apc" abstract="true" public="false">
|
||||
<argument /><!-- prefix -->
|
||||
<argument /><!-- ttl -->
|
||||
|
||||
@@ -17,16 +17,16 @@
|
||||
],
|
||||
"require": {
|
||||
"symfony/framework-bundle": "2.*",
|
||||
"knplabs/gaufrette": "~0.1.7"
|
||||
"knplabs/gaufrette": "~0.1.7|0.2.*@dev"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/yaml": "2.*",
|
||||
"symfony/console": "2.*",
|
||||
"phpunit/phpunit": "3.7.*"
|
||||
"phpunit/phpunit": "~4.2"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Knp\\Bundle\\GaufretteBundle": ""
|
||||
"psr-4": {
|
||||
"Knp\\Bundle\\GaufretteBundle\\": ""
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
@@ -36,6 +36,5 @@
|
||||
},
|
||||
"config": {
|
||||
"bin-dir": "bin"
|
||||
},
|
||||
"target-dir": "Knp/Bundle/GaufretteBundle"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user