update smarty

This commit is contained in:
Manuel Raynaud
2013-07-29 15:47:05 +02:00
parent 0738104f52
commit fd15934b65
4 changed files with 47 additions and 40 deletions

View File

@@ -26,9 +26,9 @@
"symfony-cmf/routing": "1.0.0",
"symfony/form": "2.2.*",
"symfony/validator": "2.2.*",
"symfony/validator": "2.3.*",
"smarty/smarty": "v3.1.13",
"smarty/smarty": "v3.1.14",
"kriswallsmith/assetic": "1.2.*@dev",
"leafo/lessphp": "0.3.*@dev",
"ptachoire/cssembed": "dev-master",

56
composer.lock generated
View File

@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "af923b61425810eacdb86a41df529feb",
"hash": "33bb1107329387cdebe95d5793cc191b",
"packages": [
{
"name": "ezyang/htmlpurifier",
@@ -11,12 +11,12 @@
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "af7107e8304e0ac0ad6fc2dfbecc9062d90e0b17"
"reference": "19eee1489965d9bc6eded80f847ced2382127261"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/af7107e8304e0ac0ad6fc2dfbecc9062d90e0b17",
"reference": "af7107e8304e0ac0ad6fc2dfbecc9062d90e0b17",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/19eee1489965d9bc6eded80f847ced2382127261",
"reference": "19eee1489965d9bc6eded80f847ced2382127261",
"shasum": ""
},
"require": {
@@ -47,7 +47,7 @@
"keywords": [
"html"
],
"time": "2013-07-18 17:22:45"
"time": "2013-07-27 04:54:53"
},
{
"name": "ircmaxell/password-compat",
@@ -395,11 +395,11 @@
},
{
"name": "smarty/smarty",
"version": "v3.1.13",
"version": "v3.1.14",
"source": {
"type": "svn",
"url": "http://smarty-php.googlecode.com/svn",
"reference": "/tags/v3.1.13/@4699"
"reference": "/tags/v3.1.14/@4752"
},
"require": {
"php": ">=5.2"
@@ -408,7 +408,8 @@
"autoload": {
"classmap": [
"distribution/libs/Smarty.class.php",
"distribution/libs/SmartyBC.class.php"
"distribution/libs/SmartyBC.class.php",
"distribution/libs/sysplugins/smarty_security.php"
]
},
"notification-url": "https://packagist.org/downloads/",
@@ -434,7 +435,7 @@
"keywords": [
"templating"
],
"time": "2013-01-26 12:03:52"
"time": "2013-07-02 16:38:47"
},
{
"name": "symfony-cmf/routing",
@@ -1012,20 +1013,21 @@
},
{
"name": "symfony/icu",
"version": "v1.0.0",
"version": "v1.2.0",
"target-dir": "Symfony/Component/Icu",
"source": {
"type": "git",
"url": "https://github.com/symfony/Icu.git",
"reference": "v1.0.0"
"reference": "v1.2.0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Icu/zipball/v1.0.0",
"reference": "v1.0.0",
"url": "https://api.github.com/repos/symfony/Icu/zipball/v1.2.0",
"reference": "v1.2.0",
"shasum": ""
},
"require": {
"lib-icu": ">=4.4",
"php": ">=5.3.3",
"symfony/intl": ">=2.3,<3.0"
},
@@ -1055,7 +1057,7 @@
"icu",
"intl"
],
"time": "2013-06-03 18:32:07"
"time": "2013-06-03 18:32:58"
},
{
"name": "symfony/intl",
@@ -1454,17 +1456,17 @@
},
{
"name": "symfony/validator",
"version": "v2.2.4",
"version": "v2.3.2",
"target-dir": "Symfony/Component/Validator",
"source": {
"type": "git",
"url": "https://github.com/symfony/Validator.git",
"reference": "v2.2.4"
"reference": "v2.3.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Validator/zipball/v2.2.4",
"reference": "v2.2.4",
"url": "https://api.github.com/repos/symfony/Validator/zipball/v2.3.2",
"reference": "v2.3.2",
"shasum": ""
},
"require": {
@@ -1472,22 +1474,22 @@
"symfony/translation": "~2.0"
},
"require-dev": {
"symfony/config": ">=2.2,<2.3-dev",
"symfony/config": "~2.2",
"symfony/http-foundation": "~2.1",
"symfony/locale": "~2.0",
"symfony/intl": "~2.3",
"symfony/yaml": "~2.0"
},
"suggest": {
"doctrine/common": "~2.2",
"symfony/config": "2.2.*",
"symfony/http-foundation": "2.2.*",
"symfony/locale": "2.2.*",
"symfony/yaml": "2.2.*"
"doctrine/common": "",
"symfony/config": "",
"symfony/http-foundation": "",
"symfony/intl": "",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
"dev-master": "2.3-dev"
}
},
"autoload": {
@@ -1511,7 +1513,7 @@
],
"description": "Symfony Validator Component",
"homepage": "http://symfony.com",
"time": "2013-07-02 07:41:45"
"time": "2013-07-08 13:36:15"
},
{
"name": "symfony/yaml",

View File

@@ -24,7 +24,7 @@
namespace Thelia\Action\Exception;
class CombinationNotFoundException extends ActionException
class StockNotFoundException extends ActionException
{
}

View File

@@ -25,7 +25,7 @@ namespace Thelia\Form;
use Propel\Runtime\ActiveQuery\Criteria;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Action\Exception\CombinationNotFoundException;
use Thelia\Action\Exception\StockNotFoundException;
use Thelia\Action\Exception\ProductNotFoundException;
use Thelia\Model\Base\StockQuery;
use Thelia\Model\ProductQuery;
@@ -77,7 +77,8 @@ class CartAdd extends BaseForm
new Constraints\NotBlank(),
new Constraints\Callback(array(
"methods" => array($this, "checkStock")
))
)),
new
)
))
->add("append", "hidden")
@@ -99,10 +100,13 @@ class CartAdd extends BaseForm
if ($value) {
$data = $context->getRoot()->getData();
$stock = StockQuery::create()->findPk($value);
$stock = StockQuery::create()
->filterById($value)
->filterByProductId($data["product"])
->count();
if (is_null($stock)) {
throw new CombinationNotFoundException(sprintf("This stock_id does not exists for this product : %d", $value));
if ($stock == 0) {
throw new StockNotFoundException(sprintf("This stock_id does not exists for this product : %d", $value));
}
}
}
@@ -111,12 +115,13 @@ class CartAdd extends BaseForm
{
$data = $context->getRoot()->getData();
$product = ProductQuery::create()->findPk($data["product"]);
$stock = StockQuery::create()
->filterById($data["stock_id"])
->filterByProductId($data["product"])
->findOne();
if ($product) {
if(false === $product->stockIsValid($value, $data["combination"])) {
$context->addViolation("quantity value is not valid");
}
if ($stock->getQuantity() < $value) {
$context->addViolation("quantity value is not valid");
}
}