Skip to content

Instantly share code, notes, and snippets.

@wodCZ
Created December 1, 2014 08:47
Show Gist options
  • Save wodCZ/f4bd25a2fac1d903736b to your computer and use it in GitHub Desktop.
Save wodCZ/f4bd25a2fac1d903736b to your computer and use it in GitHub Desktop.
extensions:
flysystem: wodCZ\Flysystem\DI\FlysystemExtension
flysystem:
storages:
remoteFiles:
adapter: League\Flysystem\Adapter\Ftp
host: ftp.example.com
username: john
password: letMeIn
<?php
namespace wodCZ\Flysystem\DI;
use Nette;
use Nette\DI\CompilerExtension;
class FlysystemExtension extends CompilerExtension
{
public function loadConfiguration()
{
$config = $this->getConfig();
$builder = $this->getContainerBuilder();
if(empty($config["storages"])){
return;
}
foreach ($config["storages"] as $service => $settings) {
$adapter = $settings["adapter"];
unset($settings["adapter"]);
$builder->addDefinition($this->prefix($service . "Adapter"))
->setClass($adapter, [$settings]);
$builder->addDefinition($this->prefix($service))
->setClass('League\\Flysystem\\Filesystem', [$this->prefix('@' . $service . "Adapter")]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment