public function removeCountries()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
            return $response;
        }

        $areaDeleteCountriesForm = $this->createForm(AdminForm::AREA_DELETE_COUNTRY);

        try {
            $form = $this->validateForm($areaDeleteCountriesForm);

            $data = $form->getData();

            foreach ($data['country_id'] as $countryId) {
                $country = explode('-', $countryId);
                $this->removeOneCountryFromArea($data['area_id'], $country[0], $country[1]);
            }
            // Redirect to the success URL
            return $this->generateSuccessRedirect($areaDeleteCountriesForm);
        } catch (FormValidationException $ex) {
            // Form cannot be validated
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
        } catch (\Exception $ex) {
            // Any other error
            $error_msg = $ex->getMessage();
        }

        $this->setupFormErrorContext(
            $this->getTranslator()->trans("Failed to delete selected countries"),
            $error_msg,
            $areaDeleteCountriesForm
        );

        // At this point, the form has errors, and should be redisplayed.
        return $this->renderEditionTemplate();
    }
public function removeCountries()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
            return $response;
        }

        $areaDeleteCountriesForm = $this->createForm(AdminForm::AREA_DELETE_COUNTRY);

        try {
            $form = $this->validateForm($areaDeleteCountriesForm);

            $data = $form->getData();

            foreach ($data['country_id'] as $countryId) {
                $country = explode('-', $countryId);
                $this->removeOneCountryFromArea($data['area_id'], $country[0], $country[1]);
            }
            // Redirect to the success URL
            return $this->generateSuccessRedirect($areaDeleteCountriesForm);
        } catch (FormValidationException $ex) {
            // Form cannot be validated
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
        } catch (\Exception $ex) {
            // Any other error
            $error_msg = $ex->getMessage();
        }

        $this->setupFormErrorContext(
            $this->getTranslator()->trans("Failed to delete selected countries"),
            $error_msg,
            $areaDeleteCountriesForm
        );

        // At this point, the form has errors, and should be redisplayed.
        return $this->renderEditionTemplate();
    }
public function removeCountries ( ) { // Check current user authorization if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ areaDeleteCountriesForm = $ this -> createForm ( AdminForm :: AREA_DELETE_COUNTRY ) ; try { $ form = $ this -> validateForm ( $ areaDeleteCountriesForm ) ; $ data = $ form -> getData ( ) ; foreach ( $ data [ 'country_id' ] as $ countryId ) { $ country = explode ( '-' , $ countryId ) ; $ this -> removeOneCountryFromArea ( $ data [ 'area_id' ] , $ country [ 0 ] , $ country [ 1 ] ) ; } // Redirect to the success URL return $ this -> generateSuccessRedirect ( $ areaDeleteCountriesForm ) ; } catch ( FormValidationException $ ex ) { // Form cannot be validated $ error_msg = $ this -> createStandardFormValidationErrorMessage ( $ ex ) ; } catch ( \ Exception $ ex ) { // Any other error $ error_msg = $ ex -> getMessage ( ) ; } $ this -> setupFormErrorContext ( $ this -> getTranslator ( ) -> trans ( "Failed to delete selected countries" ) , $ error_msg , $ areaDeleteCountriesForm ) ; // At this point, the form has errors, and should be redisplayed. return $ this -> renderEditionTemplate ( ) ; }
delete several countries from a shipping zone
delete several countries from a shipping zone