Refactor removing Manager notion

This commit is contained in:
gmorel
2013-11-23 20:18:04 +01:00
parent 8ce1030178
commit 90b5fbde05
34 changed files with 442 additions and 411 deletions

View File

@@ -24,14 +24,14 @@
namespace Thelia\Condition;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Thelia\Condition\ConditionManagerInterface;
use Thelia\Condition\ConditionInterface;
/**
* Created by JetBrains PhpStorm.
* Date: 8/19/13
* Time: 3:24 PM
*
* Manage a set of ConditionManagerInterface
* Manage a set of ConditionInterface
*
* @package Condition
* @author Guillaume MOREL <gmorel@openstudio.fr>
@@ -39,13 +39,13 @@ use Thelia\Condition\ConditionManagerInterface;
*/
class ConditionCollection
{
/** @var array Array of ConditionManagerInterface */
/** @var array Array of ConditionInterface */
protected $conditions = array();
/**
* Get Conditions
*
* @return array Array of ConditionManagerInterface
* @return array Array of ConditionInterface
*/
public function getConditions()
{
@@ -53,13 +53,13 @@ class ConditionCollection
}
/**
* Add a ConditionManagerInterface to the Collection
* Add a ConditionInterface to the Collection
*
* @param ConditionManagerInterface $condition Condition
* @param ConditionInterface $condition Condition
*
* @return $this
*/
public function add(ConditionManagerInterface $condition)
public function add(ConditionInterface $condition)
{
$this->conditions[] = $condition;
@@ -84,7 +84,7 @@ class ConditionCollection
public function __toString()
{
$arrayToSerialize = array();
/** @var ConditionManagerInterface $condition */
/** @var ConditionInterface $condition */
foreach ($this->getConditions() as $condition) {
$arrayToSerialize[] = $condition->getSerializableCondition();
}

View File

@@ -51,7 +51,7 @@ class ConditionEvaluator
public function isMatching(ConditionCollection $conditions)
{
$isMatching = true;
/** @var ConditionManagerInterface $condition */
/** @var ConditionInterface $condition */
foreach ($conditions->getConditions() as $condition) {
if (!$condition->isMatching()) {
$isMatching = false;

View File

@@ -71,7 +71,7 @@ class ConditionFactory
public function serializeConditionCollection(ConditionCollection $collection)
{
if ($collection->isEmpty()) {
/** @var ConditionManagerInterface $conditionNone */
/** @var ConditionInterface $conditionNone */
$conditionNone = $this->container->get(
'thelia.condition.match_for_everyone'
);
@@ -80,7 +80,7 @@ class ConditionFactory
$serializableConditions = array();
$conditions = $collection->getConditions();
if ($conditions !== null) {
/** @var $condition ConditionManagerInterface */
/** @var $condition ConditionInterface */
foreach ($conditions as $condition) {
$serializableConditions[] = $condition->getSerializableCondition();
}
@@ -106,7 +106,7 @@ class ConditionFactory
/** @var SerializableCondition $condition */
foreach ($unserializedConditions as $condition) {
if ($this->container->has($condition->conditionServiceId)) {
/** @var ConditionManagerInterface $conditionManager */
/** @var ConditionInterface $conditionManager */
$conditionManager = $this->build(
$condition->conditionServiceId,
(array) $condition->operators,
@@ -129,7 +129,7 @@ class ConditionFactory
* @param array $values Values setting this Condition
*
* @throws \InvalidArgumentException
* @return ConditionManagerInterface Ready to use Condition or false
* @return ConditionInterface Ready to use Condition or false
*/
public function build($conditionServiceId, array $operators, array $values)
{
@@ -137,7 +137,7 @@ class ConditionFactory
return false;
}
/** @var ConditionManagerInterface $condition */
/** @var ConditionInterface $condition */
$condition = $this->container->get($conditionServiceId);
$condition->setValidatorsFromForm($operators, $values);
@@ -157,7 +157,7 @@ class ConditionFactory
return false;
}
/** @var ConditionManagerInterface $condition */
/** @var ConditionInterface $condition */
$condition = $this->container->get($conditionServiceId);
return $condition->getValidators();

View File

@@ -37,11 +37,11 @@ namespace Thelia\Condition;
class ConditionOrganizer implements ConditionOrganizerInterface
{
/**
* Organize ConditionManagerInterface
* Organize ConditionInterface
*
* @param array $conditions Array of ConditionManagerInterface
* @param array $conditions Array of ConditionInterface
*
* @return array Array of ConditionManagerInterface sorted
* @return array Array of ConditionInterface sorted
*/
public function organize(array $conditions)
{

View File

@@ -37,11 +37,11 @@ namespace Thelia\Condition;
interface ConditionOrganizerInterface
{
/**
* Organize ConditionManagerInterface
* Organize ConditionInterface
*
* @param array $conditions Array of ConditionManagerInterface
* @param array $conditions Array of ConditionInterface
*
* @return array Array of ConditionManagerInterface sorted
* @return array Array of ConditionInterface sorted
*/
public function organize(array $conditions);
}

View File

@@ -41,7 +41,7 @@ use Thelia\Type\FloatType;
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
abstract class ConditionManagerAbstract implements ConditionManagerInterface
abstract class ConditionAbstract implements ConditionInterface
{
/** @var string Service Id from Resources/config.xml */

View File

@@ -37,7 +37,7 @@ use Thelia\Coupon\FacadeInterface;
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
interface ConditionManagerInterface
interface ConditionInterface
{
/**
* Constructor

View File

@@ -24,7 +24,7 @@
namespace Thelia\Condition\Implementation;
use InvalidArgumentException;
use Thelia\Condition\ConditionManagerAbstract;
use Thelia\Condition\ConditionAbstract;
/**
* Created by JetBrains PhpStorm.
@@ -37,7 +37,7 @@ use Thelia\Condition\ConditionManagerAbstract;
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class MatchForEveryoneManager extends ConditionManagerAbstract
class MatchForEveryone extends ConditionAbstract
{
/** @var string Service Id from Resources/config.xml */
protected $serviceId = 'thelia.condition.match_for_everyone';

View File

@@ -24,7 +24,7 @@
namespace Thelia\Condition\Implementation;
use Symfony\Component\Intl\Exception\NotImplementedException;
use Thelia\Condition\ConditionManagerAbstract;
use Thelia\Condition\ConditionAbstract;
use Thelia\Condition\Operators;
use Thelia\Exception\InvalidConditionOperatorException;
use Thelia\Model\Currency;
@@ -42,7 +42,7 @@ use Thelia\Model\CurrencyQuery;
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class MatchForTotalAmountManager extends ConditionManagerAbstract
class MatchForTotalAmount extends ConditionAbstract
{
/** Condition 1st parameter : price */
CONST INPUT1 = 'price';

View File

@@ -24,7 +24,7 @@
namespace Thelia\Condition\Implementation;
use InvalidArgumentException;
use Thelia\Condition\ConditionManagerAbstract;
use Thelia\Condition\ConditionAbstract;
use Thelia\Condition\Operators;
use Thelia\Exception\InvalidConditionOperatorException;
use Thelia\Exception\InvalidConditionValueException;
@@ -40,7 +40,7 @@ use Thelia\Exception\InvalidConditionValueException;
* @author Guillaume MOREL <gmorel@openstudio.fr>
*
*/
class MatchForXArticlesManager extends ConditionManagerAbstract
class MatchForXArticles extends ConditionAbstract
{
/** Condition 1st parameter : quantity */
CONST INPUT1 = 'quantity';