Skip to content

Instantly share code, notes, and snippets.

@makasim
Forked from vatson/gist:1171992
Created August 26, 2011 06:31
Show Gist options
  • Save makasim/1172832 to your computer and use it in GitHub Desktop.
Save makasim/1172832 to your computer and use it in GitHub Desktop.
chain prototype
<?php
$exceptionFilter = new ExceptionFilterHandler();
$exceptionFilter->allow('MyBundle\AbstractException')
->ignore('MyBundle\ConcreteException');
$errorFilter = new ErrorFilterHandler();
$errorFilter->allow(UniversalErrorCatcher_ErrorCode::E_CORE_ERROR)
->ignore(UniversalErrorCatcher_ErrorCode::E_ERROR);
$senderClient = new Swift();
$senderAdapter = new SwiftAdapter($senderClient);
// OR
$senderClient = new Stomp();
$senderAdapter = new JMSAdapter($senderClient);
$encoder = new HtmlEncoder();
$sender = new SenderHandler($senderAdapter, $encoder);
$exceptionFilter->nextDestination($errorFilter)->nextDestination($sender);
instend of it
array_walk(array($exceptionFilter, $errorFilter, $sender), function($chainNode) use($dataHolder) {
$chainNode->execute($dataHolder);
});
//to broke the execution we can throw a spesific exception.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment