Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

update to use Pimple extended PricingContext

  • Loading branch information...
commit df2f9ad4a19ada964740d54d4ecced1728033872 1 parent 8da4a7b
@iampersistent iampersistent authored
View
73 lib/ImmersiveLabs/Pricing/Entity/PricingContext.php
@@ -1,73 +0,0 @@
-<?php
-
-namespace ImmersiveLabs\Pricing\Entity;
-
-/**
- * PricingContext implements a data container holding price variables needed for calculation
- *
- * @author Daniel Kucharski <daniel@xerias.be>
- */
-
-use Vespolina\Entity\Pricing\PricingContextInterface;
-
-class PricingContext implements PricingContextInterface
-{
- protected $data;
- protected $entities;
-
- public function __construct($data = array())
- {
- $this->data = $data;
- $this->entities = array();
-
- if ($this->getQuantity() === null) {
- $this->setQuantity(1);
- }
- }
-
- public function addEntity($entity)
- {
- $this->entities[] = $entity;
- }
-
- public function getEntities()
- {
- return $this->entities;
- }
-
- public function setEntities($entities)
- {
- $this->entities = $entities;
- }
-
- public function get($key, $default = null)
- {
- if (array_key_exists($key, $this->data)) {
- return $this->data[$key];
- } elseif ($default) {
- return $default;
- } else {
- return null;
- }
- }
-
- public function set($key, $value)
- {
- $this->data[$key] = $value;
- }
-
- public function getData()
- {
- return $this->data;
- }
-
- public function getQuantity()
- {
- return $this->get('quantity');
- }
-
- public function setQuantity($quantity)
- {
- $this->set('quantity', $quantity);
- }
-}
View
4 lib/ImmersiveLabs/Pricing/Provider/OrderPricingProvider.php
@@ -4,7 +4,7 @@
use Vespolina\Entity\Order\OrderInterface;
use ImmersiveLabs\Pricing\Entity\PricingSet;
-use ImmersiveLabs\Pricing\Entity\PricingContext;
+use Vespolina\Entity\Pricing\PricingContext;
use Vespolina\Entity\Pricing\PricingContextInterface;
use Vespolina\Entity\Order\ItemInterface;
use Vespolina\Order\Pricing\OrderPricingProviderInterface;
@@ -53,7 +53,7 @@ public function determineOrderPrices(OrderInterface $order, PricingContextInterf
// if pricing context has taxation enabled we calculate the taxes with the percentage set
// example taxRates : 0.10 for 10%, 0.25 for 25%
- if ($partner = $pricingContext->get('partner')) {
+ if ($partner = $pricingContext['partner']) {
/** @var $partner \Vespolina\Entity\Partner\Partner */
if (count($partner->getAddresses())) {
/** @var $address \Vespolina\Entity\Partner\AddressInterface */
View
2  tests/Entity/Element/RecurringElementTest.php
@@ -11,7 +11,7 @@ public function testDoProcess()
$recurringElement->setInterval('month');
$recurringElement->setRecurringCharge('30');
- $context = new \ImmersiveLabs\Pricing\Entity\PricingContext();
+ $context = new \Vespolina\Entity\Pricing\PricingContext();
$processed = $recurringElement->process($context, array());
$this->assertEquals(new \DateTime('today +1 month'), $processed['startsOn']);
Please sign in to comment.
Something went wrong with that request. Please try again.