Merge branch 'master' into loops

This commit is contained in:
Etienne Roudeix
2013-10-24 17:15:48 +02:00
76 changed files with 3432 additions and 2403 deletions

View File

@@ -32,6 +32,11 @@ use Thelia\Core\Event\ActionEvent;
*/
class NewsletterEvent extends ActionEvent
{
/**
* @var string email to save
*/
protected $id;
/**
* @var string email to save
*/
@@ -138,6 +143,22 @@ class NewsletterEvent extends ActionEvent
return $this->locale;
}
/**
* @param string $id
*/
public function setId($id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getId()
{
return $this->id;
}

View File

@@ -41,7 +41,8 @@ class ProductSaleElementUpdateEvent extends ProductSaleElementEvent
protected $isnew;
protected $isdefault;
protected $ean_code;
protected $taxrule;
protected $tax_rule_id;
protected $from_default_currency;
public function __construct(Product $product, $product_sale_element_id)
{
@@ -196,16 +197,27 @@ class ProductSaleElementUpdateEvent extends ProductSaleElementEvent
return $this;
}
public function getTaxrule()
public function getTaxRuleId()
{
return $this->taxrule;
return $this->tax_rule_id;
}
public function setTaxrule($taxrule)
public function setTaxRuleId($tax_rule_id)
{
$this->taxrule = $taxrule;
$this->tax_rule_id = $tax_rule_id;
return $this;
}
public function getFromDefaultCurrency()
{
return $this->from_default_currency;
}
public function setFromDefaultCurrency($from_default_currency)
{
$this->from_default_currency = $from_default_currency;
return $this;
}
}

View File

@@ -71,6 +71,11 @@ final class TheliaEvents
*/
const CUSTOMER_UPDATEACCOUNT = "action.updateCustomer";
/**
* sent on customer account update profil
*/
const CUSTOMER_UPDATEPROFIL = "action.updateProfilCustomer";
/**
* sent on customer removal
*/
@@ -695,6 +700,8 @@ final class TheliaEvents
* sent for subscribing to the newsletter
*/
const NEWSLETTER_SUBSCRIBE = 'thelia.newsletter.subscribe';
const NEWSLETTER_UPDATE = 'thelia.newsletter.update';
const NEWSLETTER_UNSUBSCRIBE = 'thelia.newsletter.unsubscribe';
/************ LANG MANAGEMENT ****************************/

View File

@@ -12,8 +12,11 @@ namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\CountryQuery;
use Thelia\Type;
use Thelia\Type\TypeCollection;
class Cart extends BaseLoop
{
@@ -40,7 +43,8 @@ class Cart extends BaseLoop
protected function getArgDefinitions()
{
return new ArgumentCollection(
Argument::createIntTypeArgument('limit'),
Argument::createAnyTypeArgument('position')
);
}
@@ -74,6 +78,7 @@ class Cart extends BaseLoop
{
$cart = $this->getCart($this->request);
$cartItems = $cart->getCartItems();
$result = new LoopResult($cartItems);
@@ -81,9 +86,32 @@ class Cart extends BaseLoop
return $result;
}
$limit = $this->getLimit();
$countCartItems = count($cartItems);
if($limit <= 0 || $limit >= $countCartItems){
$limit = $countCartItems;
}
$position = $this->getPosition();
if(isset($position)){
if($position == "first"){
$limit = 1;
$cartItems = array($cartItems[0]);
}else if($position == "last"){
$limit = 1;
$cartItems = array(end($cartItems));
}
// @TODO : if the position is a number
}
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic;
foreach ($cartItems as $cartItem) {
for ($i=0; $i<$limit; $i ++) {
$cartItem = $cartItems[$i];
$product = $cartItem->getProduct();
$productSaleElement = $cartItem->getProductSaleElements();

View File

@@ -1001,6 +1001,7 @@ class Product extends BaseI18nLoop
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
->set("NEXT" , $next != null ? $next->getId() : -1)
->set("DEFAULT_CATEGORY" , $default_category_id)
->set("TAX_RULE_ID" , $product->getTaxRuleId())
;

View File

@@ -8,6 +8,7 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface;
use \Smarty;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
@@ -139,7 +140,7 @@ class SmartyParser extends Smarty implements ParserInterface
try {
$templateFile = $this->getTemplateFilePath();
} catch (\RuntimeException $e) {
return new Response($e->getMessage(), "404");
return new Response($this->render(\Thelia\Model\ConfigQuery::getPageNotFoundView()), "404");
}
return $this->render($templateFile);