本文整理汇总了PHP中Silex\Application::terminate方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::terminate方法的具体用法?PHP Application::terminate怎么用?PHP Application::terminate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Silex\Application
的用法示例。
在下文中一共展示了Application::terminate方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run react.
*
* @param int $port
* @param string $host
*/
public function run($port, $host)
{
$request_handler = function (Request $request, Response $response) {
echo $request->getMethod() . ' ' . $request->getPath() . PHP_EOL;
$sf_request = $this->request_bridge->convertRequest($request);
$sf_response = $this->app->handle($sf_request);
$this->app->terminate($sf_request, $sf_response);
$this->response_bridge->send($response, $sf_response);
};
$this->http->on('request', $request_handler);
$this->socket->listen($port, $host);
$this->loop->run();
}
示例2: testModelManagerServiceIsAvailable
/**
* test model service is available
*/
public function testModelManagerServiceIsAvailable()
{
$app = new Application();
$app->register(new ModelProvider(), array('model.finder.namespace' => 'Fake\\NameSpace', 'model.finder.path' => '/tmp/fake'));
$mockStorage = $this->getMock('Skip\\Model\\ModelStorageHandlerInterface');
$app['model.storage.handlers'] = array('mock.storage' => $mockStorage);
$modelManager = $app['model'];
$this->assertInstanceOf('Skip\\Model\\Manager', $modelManager);
$request = Request::createFromGlobals();
$response = $app->handle($request);
$app->terminate($request, $response);
}
示例3: eventHelpersShouldDirectlyAddListenersAfterBoot
/** @test */
public function eventHelpersShouldDirectlyAddListenersAfterBoot()
{
$app = new Application();
$fired = false;
$app->get("/", function () use($app, &$fired) {
$app->finish(function () use(&$fired) {
$fired = true;
});
});
$request = Request::create('/');
$response = $app->handle($request);
$app->terminate($request, $response);
$this->assertTrue($fired, 'Event was not fired');
}
示例4: testSwiftMailerSendsMailsOnFinish
public function testSwiftMailerSendsMailsOnFinish()
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider());
$app->boot();
$app['swiftmailer.spool'] = $app->share(function () {
return new SpoolStub();
});
$app->get('/', function () use($app) {
$app['mailer']->send(\Swift_Message::newInstance());
});
$this->assertCount(0, $app['swiftmailer.spool']->getMessages());
$request = Request::create('/');
$response = $app->handle($request);
$this->assertCount(1, $app['swiftmailer.spool']->getMessages());
$app->terminate($request, $response);
$this->assertCount(0, $app['swiftmailer.spool']->getMessages());
}
示例5: testSwiftMailerAvoidsFlushesIfMailerIsUnused
public function testSwiftMailerAvoidsFlushesIfMailerIsUnused()
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider());
$app->boot();
$app['swiftmailer.spool'] = $app->share(function () {
return new SpoolStub();
});
$app->get('/', function () use($app) {
});
$request = Request::create('/');
$response = $app->handle($request);
$this->assertCount(0, $app['swiftmailer.spool']->getMessages());
$app->terminate($request, $response);
$this->assertFalse($app['swiftmailer.spool']->hasFlushed);
}
示例6: testSwiftMailerSendsMailsOnFinish
public function testSwiftMailerSendsMailsOnFinish()
{
$app = new Application();
$app->register(new SwiftmailerServiceProvider(), array('swiftmailer.class_path' => __DIR__ . '/../../../../vendor/swiftmailer/swiftmailer/lib/classes'));
$spool = new SpoolStub();
$app['swiftmailer.spooltransport'] = new \Swift_SpoolTransport($spool);
$app->get('/', function () use($app) {
$app['mailer']->send(\Swift_Message::newInstance());
});
$this->assertCount(0, $spool->getMessages());
$request = Request::create('/');
$response = $app->handle($request);
$this->assertCount(1, $spool->getMessages());
$app->terminate($request, $response);
$this->assertCount(0, $spool->getMessages());
}
示例7: testCallbacksAsServices
public function testCallbacksAsServices()
{
$app = new Application();
$app['service'] = $app->share(function () {
return new self();
});
$app->before('service:beforeApp');
$app->after('service:afterApp');
$app->finish('service:finishApp');
$app->error('service:error');
$app->on('kernel.request', 'service:onRequest');
$app->match('/', 'service:controller')->convert('foo', 'service:convert')->before('service:before')->after('service:after');
$request = Request::create('/');
$response = $app->handle($request);
$app->terminate($request, $response);
$this->assertEquals(array('CONVERT', 'BEFORE APP', 'ON REQUEST', 'BEFORE', 'ERROR', 'AFTER', 'AFTER APP', 'FINISH APP'), $app['service']->called);
}