Пример #1
0
 protected function getLcn_WeatherForecast_CacheService()
 {
     $this->services['lcn.weather_forecast.cache'] = $instance = new \Doctrine\Common\Cache\PhpFileCache(__DIR__);
     $instance->setNamespace('lcn_weather_forecast');
     return $instance;
 }
Пример #2
0
$di = new Pimple\Container();
$di['router'] = function ($di) {
    return new Socrate\Router($di);
};
$di['slugify'] = function ($di) {
    return new Cocur\Slugify\Slugify();
};
$di['db'] = function ($di) {
    return new Socrate\Pdo('sqlite:' . DOCUMENT_ROOT . '/data/db.sqlite');
};
$di['cache'] = function ($di) {
    // @todo: find an alternative to doctrine cache
    if (IS_DEV) {
        $cache = new Doctrine\Common\Cache\ArrayCache();
    } else {
        $cache = new Doctrine\Common\Cache\PhpFileCache(DOCUMENT_ROOT . '/data/cache');
    }
    $cache->setNamespace(@$_SERVER['HTTP_HOST']);
    return $cache;
};
$di['mailer'] = function ($di) {
    if (IS_DEV) {
        $transport = Swift_NullTransport::newInstance();
    } else {
        $transport = Swift_MailTransport::newInstance();
    }
    return Swift_Mailer::newInstance($transport);
};
/**
 * Interlinking functions
 */
Пример #3
0
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\Routing\Loader\YamlFileLoader;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
$locator = new FileLocator(__DIR__ . '/config');
$loader = new YamlFileLoader($locator);
if (function_exists('apc_add')) {
    $cache = new \Doctrine\Common\Cache\ApcCache();
} else {
    $cache = new \Doctrine\Common\Cache\PhpFileCache(__DIR__ . '/../cache/routes');
}
if (!$app['debug'] && $cache->contains($app['app.runconfig']['routing']['cachename'])) {
    $routes = $cache->fetch($app['app.runconfig']['routing']['cachename']);
    foreach ($routes as $name => $route) {
        $r = new \Silex\Route();
        $r->unserialize($route);
        $app['routes']->add($name, $r);
    }
} else {
    $routes = $loader->load('routes.yml');
    $array = array();
    foreach ($routes->all() as $name => $route) {
        $array[$name] = $route->serialize();
    }
    $cache->save($app['app.runconfig']['routing']['cachename'], $array, $app['app.runconfig']['routing']['cachettl']);