Пример #1
0
 private function checkDuplicity(Product $product)
 {
     foreach ($product->getCategories() as $category) {
         foreach ($category->getProducts() as $duplicateCandidate) {
             $path = $product->getPath($category);
             if ($duplicateCandidate !== $product && $duplicateCandidate->getPath($category) === $path) {
                 throw new EntityDuplicateException(sprintf('Product with path %s already exists.', $path));
             }
         }
     }
 }