public function saveProduct(Product $product)
 {
     $fileData = $product->getDisplayImage();
     if (is_array($fileData) && !empty($fileData)) {
         $appBaseDir = $this->applicationConfig['app_base_dir'];
         $tmpFilePath = $appBaseDir . DIRECTORY_SEPARATOR . $fileData['tmp_name'];
         $tmpFileName = pathinfo($tmpFilePath, PATHINFO_BASENAME);
         if (file_exists($tmpFilePath)) {
             $fileName = $fileData['name'];
             $extension = pathinfo($fileName, PATHINFO_EXTENSION);
             if (is_string($extension) && strlen($extension) > 0) {
                 $newFileName = $tmpFileName . '.' . $extension;
             }
             $newFilePath = '/data/uploaded-files/products/images/' . $newFileName;
             $productImagePath = '/wwwup/products/images/' . $newFileName;
             $newFilePath = $appBaseDir . $newFilePath;
             $fileUploadSuccess = $this->moveFile($tmpFilePath, $newFilePath);
             if ($fileUploadSuccess) {
                 // @TODO should delete the old image file
                 $product->setDisplayImage($productImagePath);
             } else {
                 // @TODO App right now is not showing nice error messages/pages
                 // This should be caught, logged and user should see a
                 // better error/failure message
                 throw new \DomainException('File upload failed');
             }
         }
     }
     $displayImage = $product->getDisplayImage();
     if (is_array($displayImage)) {
         $product->setDisplayImage('');
     }
     $this->getObjectManager()->persist($product);
     $this->getObjectManager()->flush();
 }