0
在狂飲5.3,你可以在下面的例子中使用event subscribers爲:Guzzle 6中的GuzzleHttp Event SubscriberInterface相當於什麼?
use GuzzleHttp\Event\EmitterInterface;
use GuzzleHttp\Event\SubscriberInterface;
use GuzzleHttp\Event\BeforeEvent;
use GuzzleHttp\Event\CompleteEvent;
class SimpleSubscriber implements SubscriberInterface
{
public function getEvents()
{
return [
// Provide name and optional priority
'before' => ['onBefore', 100],
'complete' => ['onComplete'],
// You can pass a list of listeners with different priorities
'error' => [['beforeError', 'first'], ['afterError', 'last']]
];
}
public function onBefore(BeforeEvent $event, $name)
{
echo 'Before!';
}
public function onComplete(CompleteEvent $event, $name)
{
echo 'Complete!';
}
}
什麼是在狂飲6等價的例子嗎?
因爲我phpunit
正在使用onBefore
/onComplete
和onError
事件訂戶和文件需要升級的測試。