protected function getIncrement($route)
    {

       // var_dump($route);

        $mapper = new ResultSetMapping();
        $mapper->addScalarResult('route', 'route');


        $builder = $this->manager->createNativeQuery(
            'SELECT route FROM node_route WHERE route REGEXP ?',
            $mapper
        )
        ->setParameter('1', $this->prepareMysqlRegexp($route));

        //var_dump($builder->getArrayResult());


        $i = 0;
        foreach($builder->getArrayResult() as $_route)
        {

            if(preg_match('#\(([0-9])*\)$#', $_route['route'], $matches)) {
                $i = (int) $matches[1] == $i  ? (int) $matches[1]+1 : $i;
            } else {
                $i++;
            }
        }

        return ($i ? "($i)" : '');
    }
protected function getIncrement($route)
    {

       // var_dump($route);

        $mapper = new ResultSetMapping();
        $mapper->addScalarResult('route', 'route');


        $builder = $this->manager->createNativeQuery(
            'SELECT route FROM node_route WHERE route REGEXP ?',
            $mapper
        )
        ->setParameter('1', $this->prepareMysqlRegexp($route));

        //var_dump($builder->getArrayResult());


        $i = 0;
        foreach($builder->getArrayResult() as $_route)
        {

            if(preg_match('#\(([0-9])*\)$#', $_route['route'], $matches)) {
                $i = (int) $matches[1] == $i  ? (int) $matches[1]+1 : $i;
            } else {
                $i++;
            }
        }

        return ($i ? "($i)" : '');
    }
protected function getIncrement ( $ route ) { // var_dump($route); $ mapper = new ResultSetMapping ( ) ; $ mapper -> addScalarResult ( 'route' , 'route' ) ; $ builder = $ this -> manager -> createNativeQuery ( 'SELECT route FROM node_route WHERE route REGEXP ?' , $ mapper ) -> setParameter ( '1' , $ this -> prepareMysqlRegexp ( $ route ) ) ; //var_dump($builder->getArrayResult()); $ i = 0 ; foreach ( $ builder -> getArrayResult ( ) as $ _route ) { if ( preg_match ( '#\(([0-9])*\)$#' , $ _route [ 'route' ] , $ matches ) ) { $ i = ( int ) $ matches [ 1 ] == $ i ? ( int ) $ matches [ 1 ] + 1 : $ i ; } else { $ i ++ ; } } return ( $ i ? "($i)" : '' ) ; }
check if the generated route already exists and return the count
@param string $route route string to check
@return string increment value in parenthesis
check if the generated route already exists and return the count