Commit 8352e6fb authored by pcambra's avatar pcambra

Moved Availability Manager and Checker to commerce core

parent 6ed8055a
......@@ -28,3 +28,8 @@ services:
arguments: ['@language_manager', '@commerce.country_context']
tags:
- { name: commerce.locale_resolver, priority: -100 }
commerce.availability_manager:
class: Drupal\commerce\AvailabilityManager
tags:
- { name: service_collector, tag: commerce.availability_checker, call: addChecker }
services:
commerce_order.availability_manager:
class: Drupal\commerce_order\AvailabilityManager
tags:
- { name: service_collector, tag: commerce_order.availability_checker, call: addChecker }
......@@ -2,12 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_order\AvailabilityCheckerInterface.
* Contains \Drupal\commerce\AvailabilityCheckerInterface.
*/
namespace Drupal\commerce_order;
use Drupal\commerce\PurchasableEntityInterface;
namespace Drupal\commerce;
/**
* Defines the interface for availability checkers.
......
......@@ -2,12 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_order\AvailabilityManager.
* Contains \Drupal\commerce\AvailabilityManager.
*/
namespace Drupal\commerce_order;
use Drupal\commerce\PurchasableEntityInterface;
namespace Drupal\commerce;
/**
* Default implementation of the availability manager.
......@@ -17,7 +15,7 @@ class AvailabilityManager implements AvailabilityManagerInterface {
/**
* The checkers.
*
* @var \Drupal\commerce_order\AvailabilityCheckerInterface[]
* @var \Drupal\commerce\AvailabilityCheckerInterface[]
*/
protected $checkers = [];
......
......@@ -2,12 +2,10 @@
/**
* @file
* Contains \Drupal\commerce_order\AvailabilityManagerInterface.
* Contains \Drupal\commerce\AvailabilityManagerInterface.
*/
namespace Drupal\commerce_order;
use Drupal\commerce\PurchasableEntityInterface;
namespace Drupal\commerce;
/**
* Runs the added checkers to determine the availability of a purchasable entity.
......@@ -17,14 +15,14 @@ use Drupal\commerce\PurchasableEntityInterface;
* - Whether the entity is in stock.
* - Whether the entity's "available on" date is before the current date.
*
* @see \Drupal\commerce_order\AvailabilityCheckerInterface
* @see \Drupal\commerce\AvailabilityCheckerInterface
*/
interface AvailabilityManagerInterface {
/**
* Adds a checker.
*
* @param \Drupal\commerce_order\AvailabilityCheckerInterface $checker
* @param \Drupal\commerce\AvailabilityCheckerInterface $checker
* The checker.
*/
public function addChecker(AvailabilityCheckerInterface $checker);
......@@ -32,7 +30,7 @@ interface AvailabilityManagerInterface {
/**
* Gets all added checkers.
*
* @return \Drupal\commerce_order\AvailabilityCheckerInterface[]
* @return \Drupal\commerce\AvailabilityCheckerInterface[]
* The checkers.
*/
public function getCheckers();
......
......@@ -2,22 +2,22 @@
/**
* @file
* Contains \Drupal\commerce_order\Tests\AvailabilityManagerTest.
* Contains \Drupal\commerce\Tests\AvailabilityManagerTest.
*/
namespace Drupal\commerce_order\Tests;
namespace Drupal\commerce\Tests;
use Drupal\commerce_order\AvailabilityManager;
use Drupal\commerce\AvailabilityManager;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\commerce_order\AvailabilityManager
* @coversDefaultClass \Drupal\commerce\AvailabilityManager
* @group commerce
*/
class AvailabilityManagerTest extends UnitTestCase {
/**
* @var \Drupal\commerce_order\AvailabilityManager
* @var \Drupal\commerce\AvailabilityManager
*/
protected $availabilityManager;
......@@ -35,7 +35,7 @@ class AvailabilityManagerTest extends UnitTestCase {
* ::covers check
*/
public function testCheck() {
$mockCheckerBuilder = $this->getMockBuilder('Drupal\commerce_order\AvailabilityCheckerInterface')
$mockCheckerBuilder = $this->getMockBuilder('Drupal\commerce\AvailabilityCheckerInterface')
->disableOriginalConstructor();
$mockEntity = $this->getMock('Drupal\commerce_product\ProductVariationInterface');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment