BillingScheduleManager.php in Commerce Recurring Framework 8
File
src/BillingScheduleManager.php
View source
<?php
namespace Drupal\commerce_recurring;
use Drupal\commerce_recurring\Annotation\CommerceBillingSchedule;
use Drupal\commerce_recurring\Plugin\Commerce\BillingSchedule\BillingScheduleInterface;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
class BillingScheduleManager extends DefaultPluginManager {
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/Commerce/BillingSchedule', $namespaces, $module_handler, BillingScheduleInterface::class, CommerceBillingSchedule::class);
$this
->alterInfo('commerce_billing_schedule_info');
$this
->setCacheBackend($cache_backend, 'commerce_billing_schedule_plugins');
}
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
foreach ([
'id',
'label',
] as $required_property) {
if (empty($definition[$required_property])) {
throw new PluginException(sprintf('The billing schedule "%s" must define the "%s" property.', $plugin_id, $required_property));
}
}
}
}