本文整理汇总了PHP中Symfony\Component\EventDispatcher\EventDispatcher::filter方法的典型用法代码示例。如果您正苦于以下问题:PHP EventDispatcher::filter方法的具体用法?PHP EventDispatcher::filter怎么用?PHP EventDispatcher::filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\EventDispatcher\EventDispatcher
的用法示例。
在下文中一共展示了EventDispatcher::filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFilterWhenThereIsNoEsiIncludes
public function testFilterWhenThereIsNoEsiIncludes()
{
$dispatcher = new EventDispatcher();
$listener = new EsiListener(new Esi());
$dispatcher->connect('core.response', array($listener, 'filter'));
$event = new Event(null, 'core.response', array('request_type' => HttpKernelInterface::MASTER_REQUEST));
$dispatcher->filter($event, $response = new Response('foo'));
$this->assertEquals('', $response->headers->get('Surrogate-Control'));
}
示例2: testFilter
public function testFilter()
{
$listener = new Listener();
$dispatcher = new EventDispatcher();
$dispatcher->connect('foo', array($listener, 'filterFoo'));
$dispatcher->connect('foo', array($listener, 'filterFooBis'));
$ret = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo');
$this->assertEquals('-*foo*-', $ret, '->filter() returns the filtered value');
$listener->reset();
$dispatcher = new EventDispatcher();
$dispatcher->connect('foo', array($listener, 'filterFooBis'));
$dispatcher->connect('foo', array($listener, 'filterFoo'));
$ret = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo');
$this->assertEquals('*-foo-*', $ret, '->filter() returns the filtered value');
}
示例3: testFilter
public function testFilter()
{
$listener = new Listener();
$dispatcher = new EventDispatcher();
$dispatcher->connect('foo', array($listener, 'filterFoo'));
$dispatcher->connect('foo', array($listener, 'filterFooBis'));
$e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo');
$this->assertEquals('-*foo*-', $e->getReturnValue(), '->filter() filters a value');
$this->assertEquals($event, $e, '->filter() returns the event object');
$listener->reset();
$dispatcher = new EventDispatcher();
$dispatcher->connect('foo', array($listener, 'filterFooBis'));
$dispatcher->connect('foo', array($listener, 'filterFoo'));
$e = $dispatcher->filter($event = new Event(new \stdClass(), 'foo'), 'foo');
$this->assertEquals('*-foo-*', $e->getReturnValue(), '->filter() filters a value');
}