本文整理汇总了PHP中Silex\Application::flush方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::flush方法的具体用法?PHP Application::flush怎么用?PHP Application::flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* {@inheritDoc}
*/
public function register(Application $app)
{
$app['bing_wallpaper'] = $app->share(function (Application $app) {
$app->flush();
return new BingWallpaper();
});
}
示例2: register
public function register(Application $app)
{
$app['url_generator'] = $app->share(function () use($app) {
$app->flush();
return new UrlGenerator($app['routes'], $app['request_context']);
});
}
示例3: register
/**
* {@inheritdoc}
*
* @param \Silex\Application $app
*
* @return void
*/
public function register(Application $app)
{
$app['url_generator'] = $app->share(function ($app) {
$app->flush();
return $app['routers'];
});
}
示例4: register
/**
* {@inheritDoc}
*/
public function register(Application $app)
{
$app['slugify'] = $app->share(function (Application $app) {
$app->flush();
return new Slugify();
});
}
示例5: register
public function register(Application $app)
{
$app['sync_zmq'] = $app->share(function (Application $app) {
$app->flush();
return new \ZMQContext();
});
}
示例6: register
public function register(Application $app)
{
$app['request_api'] = $app->share(function (Application $app) {
$app->flush();
return new RequestApi($app['sync_zmq']);
});
}
示例7: register
public function register(\Silex\Application $app)
{
$app['url_generator'] = $app->share(function ($app) {
$app->flush();
return new services\UrlGenerator($app['routes'], $app['request_context']);
});
}
示例8: register
/**
* {@inheritdoc}
*/
public function register(Application $app)
{
$app['url_generator'] = $app->share(function ($app) {
$app->flush();
$configuration = array('preserve' => isset($app['url_generator.preserve']) ? $app['url_generator.preserve'] : array(), 'token' => isset($app['url_generator.token']) ? $app['url_generator.token'] : false, 'token_len' => isset($app['url_generator.token_length']) ? $app['url_generator.token_length'] : false);
return new EnhancedUrlGenerator($app['routes'], $app['request_context'], $app['request'], $configuration);
});
}
示例9: getRouter
/**
* @param RequestContext $context
*
* @return SilexRouter
*/
protected function getRouter(RequestContext $context)
{
$app = new Application();
$app->register(new RoutingServiceProvider());
$app->get('/hello', 'test')->bind('hello1');
$app->get('/hello2', 'test')->bind('hello2');
$app->flush();
$app['request_context'] = $context;
return new SilexRouter($app);
}
示例10: setUp
/**
* {@inheritdoc}
*/
public function setUp()
{
$app = new SilexApplication();
$app->register(new ConsoleServiceProvider(), ['console.name' => 'Awesome name', 'console.version' => '1.2.3', 'console.request' => ['host' => 'example.com', 'scheme' => 'https', 'httpsPort' => 443, 'url' => 'hello']]);
$app->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/Resources/views', 'twig.options' => ['cache' => false]]);
$app->get('/test.html', function () {
return '';
})->bind('test');
$app->flush();
$this->console = $app['console'];
}
示例11: register
public function register(Application $app)
{
$configFile = $this->configFile;
//configuration
$app['dump_provider.config'] = $app->share(function ($app) use($configFile) {
$app->flush();
$config = Yaml::parse($configFile);
$config = new Configuration($config);
return $config;
});
// dumper-registry
$app['dump_provider.dumper_registry'] = $app->share(function ($app) {
$app->flush();
$registry = new DumperRegistry($app['dump_provider.config']);
return $registry;
});
$app['dump_provider.dump_repository'] = $app->share(function ($app) {
$app->flush();
$repository = new DumpRepository($app['dump_provider.config'], $app['url_generator']);
return $repository;
});
}
示例12: testBind
public function testBind()
{
$app = new Application();
$app->get('/', function () {
return 'hello';
})->bind('homepage');
$app->get('/foo', function () {
return 'foo';
})->bind('foo_abc');
$app->flush();
$routes = $app['routes'];
$this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('homepage'));
$this->assertInstanceOf('Symfony\\Component\\Routing\\Route', $routes->get('foo_abc'));
}
示例13: testGetRoutesWithRoutes
public function testGetRoutesWithRoutes()
{
$app = new Application();
$app->get('/foo', function () {
return 'foo';
});
$app->get('/bar', function () {
return 'bar';
});
$routes = $app['routes'];
$this->assertInstanceOf('Symfony\\Component\\Routing\\RouteCollection', $routes);
$this->assertEquals(0, count($routes->all()));
$app->flush();
$this->assertEquals(2, count($routes->all()));
}
示例14: register
public function register(Application $app)
{
// Options
if (!isset($app['router.resource'])) {
$app['router.resource'] = null;
}
if (!isset($app['router.cache_dir'])) {
$app['router.cache_dir'] = null;
}
// Router
$app['router'] = $app->share(function () use($app) {
$options = array('cache_dir' => $app['router.cache_dir'], 'debug' => $app['debug']);
return new Router($app['router.loader'], $app['router.resource'], $options, $app['request_context'], $app['logger']);
});
// Annotation loader
$app['router.annotation.loader'] = $app->share(function () use($app) {
$reader = $app['doctrine.common.annotation_reader'];
return new AnnotatedRouteControllerLoader($reader);
});
$app['router.file.locator'] = $app->share(function () {
return new FileLocator();
});
$app['router.loader'] = $app->share(function () use($app) {
return new AnnotationDirectoryLoader($app['router.file.locator'], $app['router.annotation.loader']);
});
// Override matcher and generator.
$app['url_matcher'] = $app->share(function () use($app) {
/** @var $router Router */
$router = $app['router'];
$matcher = $router->getMatcher();
if ($matcher instanceof UrlMatcherDecorator) {
// Important to set routes by link. On security service does not working.
$matcher->setRoutes($app['routes']);
}
return $matcher;
});
$app['url_generator'] = $app->share(function () use($app) {
$app->flush();
/** @var $router Router */
$router = $app['router'];
$generator = $router->getGenerator();
if ($generator instanceof UrlGeneratorDecorator) {
// Important to set routes by link. On security service does not working.
$generator->setRoutes($app['routes']);
}
return $generator;
});
}
示例15: boot
/**
* (non-PHPdoc)
* @see \Silex\ServiceProviderInterface::boot()
*/
public function boot(Application $app)
{
$app->flush();
/* @var $routes \Symfony\Component\Routing\RouteCollection */
$routes = $app['routes'];
/* @var $route \Silex\Route */
foreach ($routes->getIterator() as $id => $route) {
$path = $route->getPath();
$headers = implode(',', ['Authorization', 'Accept', 'X-Request-With', 'Content-Type', 'X-Session-Token', 'X-Hmac-Hash', 'X-Time', 'X-Url']);
/* @var $controller \Silex\Controller */
$controller = $app->match($path, function () use($headers) {
return new Response(null, 204, ["Allow" => "GET,POST,PUT,DELETE", "Access-Control-Max-Age" => 84600, "Access-Control-Allow-Origin" => "*", "Access-Control-Allow-Credentials" => "false", "Access-Control-Allow-Methods" => "GET,POST,PUT,DELETE", "Access-Control-Allow-Headers" => $headers]);
});
$controller->method('OPTIONS');
/* @var $controllerRoute \Silex\Route */
$controllerRoute = $controller->getRoute();
$controllerRoute->setCondition($route->getCondition());
$controllerRoute->setSchemes($route->getSchemes());
$controllerRoute->setMethods('OPTIONS');
}
}