/**
  * Now we will replace the context with a new context and break the chain
  * @return null
  */
 public function testApplyFiltersChainReplaceContextBreakChain()
 {
     $input = $this->getMock('Appfuel\\Kernel\\Mvc\\AppInputInterface');
     $detail = $this->getMock('Appfuel\\Kernel\\Mvc\\MvcRouteDetailInterface');
     $context = new MvcContext('html', 'my-route', $detail, $input);
     $replaceContext = new MvcContext('json', 'new-route', $detail, $input);
     $cback1 = function ($myContext, $builder) {
         $myContext->add('filter1', 'filter-result-1');
     };
     $filter1 = new InterceptFilter($cback1);
     $cback2 = function ($myContext, $builder) use($replaceContext) {
         $replaceContext->add('filter2', 'filter-result-2');
         return array('is-break-chain' => true, 'replace-context' => $replaceContext);
     };
     $filter2 = new InterceptFilter($cback2);
     $cback3 = function ($myContext, $builder) {
         $myContext->add('filter3', 'filter-result-3');
     };
     $filter3 = new InterceptFilter($cback3);
     $this->chain->setFilters(array($filter1, $filter2, $filter3));
     $result = $this->chain->applyFilters($context);
     $this->assertNotSame($context, $result);
     $this->assertSame($replaceContext, $result);
     $this->assertNull($replaceContext->get('filter1'));
     $this->assertEquals('filter-result-2', $replaceContext->get('filter2'));
     $this->assertNull($replaceContext->get('filter3'));
 }
 /**
  * @param	MvcActionDispatcherInterface $dispatch,
  * @param	FilterManagerInterface $filterManager,
  * @param	OutputInterface $output
  * @return	MvcFront
  */
 public function buildFront(MvcDispatcherInterface $dispatcher = null, InterceptChainInterface $preChain = null, InterceptChainInterface $postChain = null)
 {
     $preList = KernelRegistry::getParam('pre-filters', array());
     if (null === $preChain) {
         $preChain = new InterceptChain();
     }
     if (is_array($preList) && !empty($preList)) {
         $preChain->loadFilters($preList);
     }
     $postList = KernelRegistry::getParam('post-filters', array());
     if (null === $postChain) {
         $postChain = new InterceptChain();
     }
     if (is_array($postList) && !empty($postList)) {
         $postChain->loadFilters($postList);
     }
     if (null === $dispatcher) {
         $dispatcher = new MvcDispatcher();
     }
     return new MvcFront($dispatcher, $preChain, $postChain);
 }