Files
sterivein/core/lib/Thelia/Coupon/CouponRuleCollection.php
gmorel 49be95a2e7 Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (18) and others
# Via franck (9) and others
* 'master' of https://github.com/thelia/thelia: (39 commits)
  Working :
  Working :
  Working :
  Working :
  Fixed minor visual glitches
  Working : Resize countries flag + Add bootstrap-switch
  fix test suite
  clear asset cache in cache:cler command
  Added a 'development mode' to assetic smarty plugin
  rewriting router
  use good Request object
  Added Tools\URL test case, and a test case superclass for initializing Tools\URL
  remove unused UrlWritin controller
  create router for rewriting matching
  customer substitutions
  fix typo in front id
  Working : For attributes on labels
  Working : For attributes on labels
  add label_attr attribute to form smarty plugin
  start refactorin rewriting routing
  ...

Conflicts:
	core/lib/Thelia/Config/Resources/routing/front.xml
	templates/admin/default/assets/less/thelia/bootstrap-editable.less
	templates/admin/default/categories.html
2013-09-06 19:38:08 +02:00

105 lines
3.3 KiB
PHP

<?php
/**********************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/**********************************************************************************/
namespace Thelia\Coupon;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Constraint\Rule\SerializableRule;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
* Time: 3:24 PM
*
* Manage a set of CouponRuleInterface
*
* @package Coupon
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class CouponRuleCollection
{
/** @var array Array of CouponRuleInterface */
protected $rules = array();
/**
* Constructor
*/
function __construct()
{
}
/**
* Get Rules
*
* @return array Array of CouponRuleInterface
*/
public function getRules()
{
return $this->rules;
}
/**
* Add a CouponRuleInterface to the Collection
*
* @param CouponRuleInterface $rule Rule
*
* @return $this
*/
public function add(CouponRuleInterface $rule)
{
$this->rules[] = $rule;
return $this;
}
/**
* Check if there is at least one rule in the collection
*
* @return bool
*/
public function isEmpty()
{
return isEmpty($this->rules);
}
/**
* Allow to compare 2 set of rules
*
* @return string Jsoned data
*/
public function __toString()
{
$arrayToSerialize = array();
/** @var CouponRuleInterface $rule */
foreach ($this->getRules() as $rule) {
$arrayToSerialize[] = $rule->getSerializableRule();
}
return json_encode($arrayToSerialize);
}
}