private function parseDefinitions(array $definitions)
 {
     return array_map(function ($service) {
         if (preg_match('/^@/', $service)) {
             return \DI\link(preg_replace('/^@(.+)/', '$1', $service));
         } else {
             return \DI\object($service);
         }
     }, $definitions);
 }
Example #2
0
 public function __invoke()
 {
     $configuration = $this->configuration->toDiArray();
     $configuration[EntityManager::class] = \DI\factory(function () {
         $isDevMode = \DI\link('doctrine.debug');
         $metadataConfiguration = \DI\link('doctrine.metadata.configuration');
         $paths = $metadataConfiguration['paths'];
         switch ($metadataConfiguration['type']) {
             case 'xml':
                 $metadata = Setup::createXMLMetadataConfiguration($paths, $isDevMode);
                 break;
             case 'yml':
                 $metadata = Setup::createYAMLMetadataConfiguration($paths, $isDevMode);
                 break;
             case 'annotations':
                 $metadata = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
                 break;
             default:
                 throw new \InvalidArgumentException('Doctrine can only load its configuration using "xml", "yml" or "annotations" but "' . $metadataConfiguration['type'] . '" was provided as a means.');
         }
         return EntityManager::create(\DI\link('doctrine.connection'), $metadata);
     });
     return $configuration;
 }
Example #3
0
<?php

return array('Doctrine\\DBAL\\Connection' => \DI\link('db'), 'Doctrine\\DBAL\\Driver\\Connection' => \DI\link('db'), 'Psr\\Log\\LoggerInterface' => \DI\link('logger'), 'Monolog\\Logger' => \DI\link('monolog'), 'Symfony\\Component\\HttpFoundation\\Session\\Session' => \DI\link('session'), 'Symfony\\Component\\HttpFoundation\\Session\\SessionInterface' => \DI\link('session'), 'Swift_Mailer' => \DI\link('mailer'), 'Symfony\\Component\\Routing\\Generator\\UrlGenerator' => \DI\link('url_generator'), 'Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface' => \DI\link('url_generator'));
Example #4
0
<?php

use App\Resources\MySql\ConfigProxies\VXhostRead;
use App\Resources\Redis\Redis;
use App\Resources\Redis\RedisNonPrefixed;
use CBase\DB\Mysql\ServerConnection;
use DI\Container;
return ['redis.scheme' => 'tcp', 'redis.host' => 'localhost', 'redis.port' => 6379, 'redis.database' => 3, 'redis.options' => ['prefix' => 'homeservice:'], Redis::class => DI\factory(function (Container $c) {
    return new Redis(['scheme' => $c->get('redis.scheme'), 'host' => $c->get('redis.host'), 'port' => $c->get('redis.port'), 'database' => $c->get('redis.database')], $c->get('redis.options'));
}), RedisNonPrefixed::class => DI\factory(function (Container $c) {
    return new RedisNonPrefixed(['scheme' => $c->get('redis.scheme'), 'host' => $c->get('redis.host'), 'port' => $c->get('redis.port'), 'database' => $c->get('redis.database')], $c->get('redis.options'));
}), 'mongo.uri' => 'mongodb://localhost', 'mongo.db' => 'homeservice', 'mongo.options' => ['connectTimeoutMS' => 30000], MongoClient::class => DI\object()->constructor(DI\link('mongo.uri'), DI\link('mongo.options')), MongoDB::class => DI\factory(function (Container $c) {
    /** @var MongoClient $client */
    $client = $c->get(MongoClient::class);
    $db = $client->selectDB($c->get('mongo.db'));
    return $db;
})];
Example #5
0
<?php

use App\Cli\CliAppEnum;
use App\Cli\Command\Development\InitDevelopmentEnvironment;
use App\Services\PureFTPd\Auth;
use App\Services\PureFTPd\Command\AuthProvider;
use App\Services\PureFTPd\Command\ServerWrapper;
use App\Services\PureFTPd\Command\UploadScript;
use DI\Container;
use Symfony\Component\Console\Application;
return [CliAppEnum::INIT_DEVELOPMENT => DI\object(Application::class)->constructor('Init Development Environment', '0.1.0')->method('add', DI\link(InitDevelopmentEnvironment::class))->method('setDefaultCommand', InitDevelopmentEnvironment::NAME), 'pureftpd.config' => ['minuid' => 33, 'socket' => '/var/run/ftpd.sock', 'uploadscript' => ['uid' => 1000, 'gid' => 1000], 'log' => ['transfer' => APP_HOME . '/var/log/pureftpd/transfer.log', 'auth' => APP_HOME . '/var/log/pureftpd/auth.log', 'uploadscript' => APP_HOME . '/var/log/pureftpd/uploadscript.log'], 'auth' => ['users' => ['scan' => ['password' => 'scanpassword', 'dir' => APP_HOME . '/var/home/scan', 'uid' => 33, 'gid' => 33, 'throttlingBandwidthUl' => 0, 'throttlingBandwidthDl' => 0, 'userQuotaSize' => 0, 'perUserMax' => 0, 'fileHandler' => null], 'otr' => ['password' => 'otrpassword', 'dir' => APP_HOME . '/var/home/otr', 'uid' => 33, 'gid' => 33, 'throttlingBandwidthUl' => 0, 'throttlingBandwidthDl' => 0, 'userQuotaSize' => 0, 'perUserMax' => 0, 'fileHandler' => null]]]], Auth::class => DI\object()->constructor(DI\link('pureftpd.config')), ServerWrapper::class => DI\object()->constructor(DI\link('pureftpd.config')), AuthProvider::class => DI\object()->constructor(DI\link('pureftpd.config'), DI\link(Auth::class)), UploadScript::class => DI\object()->constructor(DI\link('pureftpd.config')), CliAppEnum::PUREFTPD_SERVER_WRAPPER => DI\object(Application::class)->constructor('PureFTPd Wrapper', '0.1.0')->method('add', DI\link(ServerWrapper::class))->method('setDefaultCommand', ServerWrapper::NAME), CliAppEnum::PUREFTPD_AUTH_PROVIDER => DI\object(Application::class)->constructor('PureFTPd Auth Provider', '0.1.0')->method('add', DI\link(AuthProvider::class))->method('setDefaultCommand', AuthProvider::NAME), CliAppEnum::PUREFTPD_UPLOAD_SCRIPT => DI\object(Application::class)->constructor('PureFTPd UploadScript', '0.1.0')->method('add', DI\link(UploadScript::class))->method('setDefaultCommand', UploadScript::NAME)];
<?php

use App\Resources\FileStorage\FileStorage;
return [FileStorage::class => DI\object()->constructor(DI\link(MongoDB::class))];
Example #7
0
    if (APC_ENABLED) {
        $cache = new Doctrine\Common\Cache\ApcCache();
    } else {
        $cache = new Doctrine\Common\Cache\ArrayCache();
    }
    $cache->setNamespace('Fraym_instance_' . FRAYM_INSTANCE);
    $builder->setDefinitionCache($cache);
    $builder->writeProxiesToFile(true, 'Cache/DI');
    $diContainer = $builder->build();
    define('GLOBAL_CACHING_ENABLED', true);
} else {
    error_reporting(-1);
    ini_set("display_errors", 1);
    $builder = new \DI\ContainerBuilder();
    if (APC_ENABLED && \Fraym\Core::ENV_TESTING === ENV) {
        $cache = new Doctrine\Common\Cache\ApcCache();
    } else {
        $cache = new Doctrine\Common\Cache\ArrayCache();
    }
    $builder->setDefinitionCache($cache);
    $diContainer = $builder->build();
    define('GLOBAL_CACHING_ENABLED', false);
}
$diContainer->set('db.options', array('driver' => DB_DRIVER, 'user' => DB_USER, 'password' => DB_PASS, 'host' => DB_HOST, 'dbname' => DB_NAME, 'charset' => DB_CHARSET));
if (defined('IMAGE_PROCESSOR') && IMAGE_PROCESSOR === 'Imagick') {
    $diContainer->set('Imagine', DI\link('Imagine\\Imagick\\Imagine'));
} elseif (defined('IMAGE_PROCESSOR') && IMAGE_PROCESSOR === 'Gmagick') {
    $diContainer->set('Imagine', DI\link('Imagine\\Gmagick\\Imagine'));
} else {
    $diContainer->set('Imagine', DI\link('Imagine\\Gd\\Imagine'));
}
Example #8
0
 public function __invoke()
 {
     return ['command.middlewares' => [\DI\link(CommandHandlerMiddleware::class)], CommandBus::class => \DI\object()->constructor(\DI\link('command.middlewares')), CommandNameExtractor::class => \DI\object(ClassNameExtractor::class), HandlerLocator::class => \DI\object(LazyLoadingPhpDiMessageHandlerMap::class), MethodNameInflector::class => \DI\object(InvokeInflector::class)];
 }
Example #9
0
<?php

use App\App;
use App\MVC\ControllerResolver;
use App\MVC\Response\RestResponse;
use App\MVC\Response\TwigResponse;
use App\Routing\Loader\ArrayFileLoader;
use DI\Container;
use Psr\Log\LoggerInterface;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpKernel\EventListener\RouterListener;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\Routing\Loader\PhpFileLoader;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\RouteCollection;
return ['routes.config' => './conf/routes.php', Request::class => DI\factory(function () {
    return Request::createFromGlobals();
}), RouteCollection::class => DI\factory(function (Container $c) {
    $locator = $c->get(FileLocator::class);
    $phpFileLoader = new ArrayFileLoader($locator);
    $routes = $phpFileLoader->load($c->get('routes.config'));
    return $routes;
}), RequestContext::class => DI\object()->method('fromRequest', DI\link(Request::class)), RequestStack::class => DI\object()->method('push', DI\link(Request::class)), UrlMatcher::class => DI\object()->constructor(DI\link(RouteCollection::class), DI\link(RequestContext::class)), RouterListener::class => DI\object()->constructor(DI\link(UrlMatcher::class), DI\link(RequestContext::class), DI\link(LoggerInterface::class), DI\link(RequestStack::class)), HttpKernel::class => DI\object()->constructor(DI\link(EventDispatcher::class), DI\link(ControllerResolver::class), DI\link(RequestStack::class)), TwigResponse::class => DI\object()->property('twig', DI\link(Twig_Environment::class)), RestResponse::class => DI\object(), ControllerResolver::class => DI\object()->property('container', DI\link(Container::class))->property('logger', DI\link(LoggerInterface::class)), App::class => DI\object()];
Example #10
0
<?php

use DI\Container;
return ['twig.templates' => APP_HOME . '/app/gui/twig', 'twig.options.cache' => APP_HOME . '/var/cache/twig', 'twig.options.debug' => true, Twig_Loader_Filesystem::class => DI\object()->constructor(DI\link('twig.templates')), Twig_Environment::class => DI\factory(function (Container $c) {
    $twig = new Twig_Environment($c->get(Twig_Loader_Filesystem::class), ['cache' => $c->get('twig.options.cache'), 'debug' => $c->get('twig.options.debug')]);
    $twig->addExtension(new Twig_Extension_Debug());
    return $twig;
})];