Elcodi\Admin\ProductBundle\Controller\ProductController::editAction PHP Method

editAction() public method

Edit and Saves product
public editAction ( Symfony\Component\Form\FormInterface $form, Elcodi\Component\Product\Entity\Interfaces\ProductInterface $product, boolean $isValid ) : RedirectResponse
$form Symfony\Component\Form\FormInterface Form
$product Elcodi\Component\Product\Entity\Interfaces\ProductInterface Product
$isValid boolean Is valid
return Symfony\Component\HttpFoundation\RedirectResponse Redirect response
    public function editAction(FormInterface $form, ProductInterface $product, $isValid)
    {
        if ($isValid) {
            $firstImage = $product->getSortedImages()->first();
            if ($firstImage instanceof ImageInterface) {
                $product->setPrincipalImage($firstImage);
            }
            $this->flush($product);
            $this->addFlash('success', $this->get('translator')->trans('admin.product.saved'));
            return $this->redirectToRoute('admin_product_list');
        }
        return ['product' => $product, 'form' => $form->createView()];
    }