Fix "Cannot count query that uses a HAVING clause" (Doctrine >= 2.3.0) 

DoctrineCountWalker throws the following RuntimeException when the query being counted contains a HAVING clause.

    Cannot count query that uses a HAVING clause. Use the output walkers for pagination
    
    Stack Trace

    in vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Pagination\CountWalker.php at line 47
    at CountWalker ->walkSelectStatement (object(SelectStatement))
    in vendor\doctrine\orm\lib\Doctrine\ORM\Query\TreeWalkerChain.php at line 69
    at TreeWalkerChain ->walkSelectStatement (object(SelectStatement))
    in vendor\doctrine\orm\lib\Doctrine\ORM\Query\Parser.php at line 333
    at Parser ->parse ()
    in vendor\doctrine\orm\lib\Doctrine\ORM\Query.php at line 233
    at Query ->_parse ()
    in vendor\doctrine\orm\lib\Doctrine\ORM\Query.php at line 245
    at Query ->_doExecute ()
    in vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php at line 737
    at AbstractQuery ->execute (null, '2')
    in vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php at line 538
    at AbstractQuery ->getResult ('2')
    in vendor\knplabs\knp-components\src\Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\QuerySubscriber.php at line 45
    at QuerySubscriber ->items (object(ItemsEvent))
    at call_user_func (array(object(QuerySubscriber), 'items'), object(ItemsEvent))
    in vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher.php at line 139
    at ContainerAwareTraceableEventDispatcher ->doDispatch (array(array(object(QueryBuilderSubscriber), 'items'), array(object(QueryBuilderSubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(ElasticaQuerySubscriber), 'items'), array(object(PropelQuerySubscriber), 'items'), array(object(SolariumQuerySubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(QuerySubscriber), 'items'), array(object(CollectionSubscriber), 'items'), array(*DEEP NESTED ARRAY*), array(*DEEP NESTED ARRAY*), array(*DEEP NESTED ARRAY*), array(*DEEP NESTED ARRAY*)), 'knp_pager.items', object(ItemsEvent))
    in app\cache\dev\classes.php at line 4850
    at EventDispatcher ->dispatch ('knp_pager.items', object(ItemsEvent))
    in app\cache\dev\classes.php at line 5068
    at ContainerAwareEventDispatcher ->dispatch ('knp_pager.items', object(ItemsEvent))
    in vendor\symfony\symfony\src\Symfony\Component\HttpKernel\Debug\ContainerAwareTraceableEventDispatcher.php at line 78
    at ContainerAwareTraceableEventDispatcher ->dispatch ('knp_pager.items', object(ItemsEvent))
    in vendor\knplabs\knp-components\src\Knp\Component\Pager\Paginator.php at line 95
    at Paginator ->paginate (object(Query), '1', '5')
    in src\VisaMachine\OrderBundle\Doctrine\OrderManager.php at line 95
    at OrderManager ->findOrdersBy (array('archive' => null, 'promo' => null, 'voucher' => null, 'visaPaperStatus' => null, 'visaStatus' => 'awaiting', 'page' => '1', 'show' => '5'), object(Paginator))
    in src\VisaMachine\BackendBundle\Controller\OrderController.php at line 54
    at OrderController ->indexAction (object(Request))
    at call_user_func_array (array(object(OrderController), 'indexAction'), array(object(Request)))
    in app\bootstrap.php.cache at line 1426
    at HttpKernel ->handleRaw (object(Request), '1')
    in app\bootstrap.php.cache at line 1390
    at HttpKernel ->handle (object(Request), '1', true)
    in app\bootstrap.php.cache at line 1566
    at HttpKernel ->handle (object(Request), '1', true)
    in app\bootstrap.php.cache at line 617
    at Kernel ->handle (object(Request))
    in web\app_dev.php at line 30

This fix instructs Knp\Component\Pager\Event\Subscriber\Paginate\Doctrine\ORM\QuerySubscriber to use the CountOutputWalker if the Doctrine ORM version is >= 2.3.0.  CountOutputWalker can handle such queries as well as those handled by CountWalker.