Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dead (?) code in ShoppingListBundle/Form/Handler/LineItemHandler #135

Open
jankulma-turbine opened this issue Apr 23, 2021 · 0 comments
Open

Comments

@jankulma-turbine
Copy link

Summary
In LineItemHandler there is a part where case for new ShoppingList creation is seemingly covered, but it's never called, and looks like dead code to me:

https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/ShoppingListBundle/Form/Handler/LineItemHandler.php#L82-L89

        // handle case for new shopping list creation
        $formName = $this->form->getName();
        $formData = $this->request->request->get($formName, []);
        if (empty($formData['shoppingList']) && !empty($formData['shoppingListLabel'])) {
            $shoppingList = $this->currentShoppingListManager->createCurrent($formData['shoppingListLabel']);
            $formData['shoppingList'] = $shoppingList->getId();
            $this->request->request->set($formName, $formData);
        }

This handler is called only in

  1. \Oro\Bundle\ShoppingListBundle\Controller\Frontend\AjaxLineItemController::addProductFromViewAction where ShoppingList is always created before, if it didn't exist:
    https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/ShoppingListBundle/Controller/Frontend/AjaxLineItemController.php#L59
$shoppingList = $currentShoppingListManager->getForCurrentUser($request->get('shoppingListId'));

https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/ShoppingListBundle/Controller/Frontend/Api/Rest/LineItemController.php#L144
\Oro\Bundle\ShoppingListBundle\Controller\Frontend\Api\Rest\LineItemController::putAction
which is responsible for updating a LineItem, so it must be assigned to a ShoppingList already.

JK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant