/** * @param Pages $page * @param Images $image * @param string $url */ private function performFsOperations(Pages $page, Images $image, $url) { try { $image = $this->generateFromRemote($url, $image); $page->addImage($image); } catch (\Exception $e) { $this->entityManager->remove($image); } }