Files
sterivein/local/modules/Colissimo/Controller/FreeShipping.php
2014-04-18 09:36:41 +02:00

37 lines
1.7 KiB
PHP

<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace Colissimo\Controller;
use Colissimo\Model\ColissimoFreeshipping;
use Symfony\Component\HttpFoundation\JsonResponse;
use Thelia\Controller\Admin\BaseAdminController;
use Thelia\Core\HttpFoundation\Response;
class FreeShipping extends BaseAdminController {
public function set() {
$form = new \Colissimo\Form\FreeShipping($this->getRequest());
$response=null;
try {
$vform = $this->validateForm($form);
$data = $vform->get('freeshipping')->getData();
$save = new ColissimoFreeshipping();
$save->setActive(!empty($data))->save();
$response = Response::create('');
} catch (\Exception $e) {
$response = JsonResponse::create(array("error"=>$e->getMessage()), 500);
}
return $response;
}
}