protected function addSuffixNumber($slug, Page $page, $number = 0)
    {
        $slugTmp = $number > 0 ? $slug . $this->slugSuffixSeparator . $number : $slug;
        $parentFullpath = $page->getParent()->getFullpath();
        $foundedPage = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findOneBy(array(
                'fullpath' => ($parentFullpath !== '' ? ($parentFullpath . '/') : '') . $slugTmp
        ));
        if ($foundedPage && $foundedPage != $page)
        {
            return $this->addSuffixNumber($slug, $page, $number + 1);
        }
        return $slugTmp;
    }
protected function addSuffixNumber($slug, Page $page, $number = 0)
    {
        $slugTmp = $number > 0 ? $slug . $this->slugSuffixSeparator . $number : $slug;
        $parentFullpath = $page->getParent()->getFullpath();
        $foundedPage = $this->doctrine->getRepository('FulgurioLightCMSBundle:Page')->findOneBy(array(
                'fullpath' => ($parentFullpath !== '' ? ($parentFullpath . '/') : '') . $slugTmp
        ));
        if ($foundedPage && $foundedPage != $page)
        {
            return $this->addSuffixNumber($slug, $page, $number + 1);
        }
        return $slugTmp;
    }
protected function addSuffixNumber ( $ slug , Page $ page , $ number = 0 ) { $ slugTmp = $ number > 0 ? $ slug . $ this -> slugSuffixSeparator . $ number : $ slug ; $ parentFullpath = $ page -> getParent ( ) -> getFullpath ( ) ; $ foundedPage = $ this -> doctrine -> getRepository ( 'FulgurioLightCMSBundle:Page' ) -> findOneBy ( array ( 'fullpath' => ( $ parentFullpath !== '' ? ( $ parentFullpath . '/' ) : '' ) . $ slugTmp ) ) ; if ( $ foundedPage && $ foundedPage != $ page ) { return $ this -> addSuffixNumber ( $ slug , $ page , $ number + 1 ) ; } return $ slugTmp ; }
Add suffix number if page exists

@param string $slug
@param Page $page
@param number $number
@return string
Add suffix number if page exists