/**
  * Throws exception if page duplicate is found
  * @param PageLocalization $pageData
  * @param Path $newPath
  */
 protected function checkForDuplicates(PageLocalization $pageData, Path $newPath)
 {
     $page = $pageData->getMaster();
     $locale = $pageData->getLocale();
     $repo = $this->em->getRepository(PageLocalizationPath::CN());
     $newPathString = $newPath->getFullPath();
     // Duplicate path validation
     $criteria = array('locale' => $locale, 'path' => $newPath);
     $duplicate = $repo->findOneBy($criteria);
     /* @var $duplicate PageLocalizationPath */
     if (!is_null($duplicate) && !$pageData->getPathEntity()->equals($duplicate)) {
         throw new DuplicatePagePathException(sprintf('Page with path [%s] already exists.', $newPathString), $pageData);
     }
 }