forked from dawehner/commerce_recurring
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,015 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
entity.commerce_recurring_engine.add_form: | ||
route_name: entity.commerce_recurring_engine.add_form | ||
title: 'Add recurring engine' | ||
appears_on: | ||
- entity.commerce_recurring_engine.collection | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
commerce_recurring.configuration: | ||
title: 'Recurring' | ||
route_name: 'commerce_recurring.configuration' | ||
parent: 'commerce.configuration' | ||
weight: -10 | ||
|
||
entity.commerce_recurring_engine.collection: | ||
title: 'Recurring engines' | ||
route_name: 'entity.commerce_recurring_engine.collection' | ||
parent: 'commerce_recurring.configuration' | ||
description: 'Configure the recurring engines that manage recurring orders and subscriptions.' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# @TODO: Subscriptions collections/canonical? | ||
# | ||
|
||
entity.commerce_recurring_engine.edit_form: | ||
route_name: entity.commerce_recurring_engine.edit_form | ||
base_route: entity.commerce_recurring_engine.edit_form | ||
title: Edit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
administer commerce_recurring_engine: | ||
title: 'Administer recurring engines' | ||
'restrict access': TRUE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
commerce_recurring.recurring_engine: | ||
label: Commerce recurring engine | ||
provider: commerce_recurring | ||
plugin_manager_service_id: plugin.manager.commerce_recurring_engine | ||
plugin_definition_decorator_class: Drupal\plugin\PluginDefinition\ArrayPluginDefinitionDecorator | ||
|
||
commerce_recurring.subscription_type: | ||
label: Commerce subscription type | ||
provider: commerce_recurring | ||
plugin_manager_service_id: plugin.manager.commerce_subscription_type | ||
plugin_definition_decorator_class: Drupal\plugin\PluginDefinition\ArrayPluginDefinitionDecorator | ||
|
||
commerce_recurring.usage_type: | ||
label: Commerce usage type | ||
provider: commerce_recurring | ||
plugin_manager_service_id: plugin.manager.commerce_usage_type | ||
plugin_definition_decorator_class: Drupal\plugin\PluginDefinition\ArrayPluginDefinitionDecorator |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,199 @@ | ||
<?php | ||
|
||
namespace Drupal\commerce_recurring\Entity; | ||
|
||
use Drupal\commmerce\CommerceSinglePluginCollection; | ||
use Drupal\Core\Config\Entity\ConfigEntityBase; | ||
|
||
/** | ||
* Defines the recurring engine entity class. | ||
* | ||
* @ConfigEntityType( | ||
* id = "commerce_recurring_engine", | ||
* label = @Translation("Recurring engine"), | ||
* label_collection = @Translation("Recurring engines"), | ||
* label_singular = @Translation("recurring engine"), | ||
* label_plural = @Translation("recurring engines"), | ||
* label_count = @PluralTranslation( | ||
* singular = "@countrecurring engines", | ||
* plural = "@count recurring engines", | ||
* ), | ||
* handlers = { | ||
* "list_builder" = "Drupal\commerce_recurring\RecurringEngineListBuilder", | ||
* "storage" = "Drupal\commerce_recurring\RecurringEngineStorage", | ||
* "form" = { | ||
* "add" = "Drupal\commerce_recurring\Form\RecurringEngineForm", | ||
* "edit" = "Drupal\commerce_recurring\Form\RecurringEngineForm", | ||
* "delete" = "Drupal\Core\Entity\EntityDeleteForm" | ||
* }, | ||
* "route_provider" = { | ||
* "default" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider", | ||
* }, | ||
* }, | ||
* admin_permission = "administer commerce_recurring_engine", | ||
* config_prefix = "commerce_recurring_engine", | ||
* entity_keys = { | ||
* "id" = "id", | ||
* "label" = "label", | ||
* "uuid" = "uuid", | ||
* "weight" = "weight", | ||
* "status" = "status", | ||
* }, | ||
* config_export = { | ||
* "id", | ||
* "label", | ||
* "weight", | ||
* "status", | ||
* "plugin", | ||
* "configuration", | ||
* }, | ||
* links = { | ||
* "add-form" = "/admin/commerce/config/recurring-engines/add", | ||
* "edit-form" = "/admin/commerce/config/recurring-engines/manage/{commerce_recurring_engine}", | ||
* "delete-form" = "/admin/commerce/config/recurring-engines/manage/{commerce_recurring_engine}/delete", | ||
* "collection" = "/admin/commerce/config/recurring-engines" | ||
* } | ||
* ) | ||
*/ | ||
class RecurringEngine extends ConfigEntityBase implements RecurringEngineInterface { | ||
|
||
/** | ||
* The recurring engine ID. | ||
* | ||
* @var string | ||
*/ | ||
protected $id; | ||
|
||
/** | ||
* The recurring engine label. | ||
* | ||
* @var string | ||
*/ | ||
protected $label; | ||
|
||
/** | ||
* The recurring engine weight. | ||
* | ||
* @var int | ||
*/ | ||
protected $weight; | ||
|
||
/** | ||
* The plugin ID. | ||
* | ||
* @var string | ||
*/ | ||
protected $plugin; | ||
|
||
/** | ||
* The plugin configuration. | ||
* | ||
* @var array | ||
*/ | ||
protected $configuration = []; | ||
|
||
/** | ||
* The plugin collection that holds the recurring engine plugin. | ||
* | ||
* @var \Drupal\commerce\CommerceSinglePluginCollection | ||
*/ | ||
protected $pluginCollection; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getWeight() { | ||
return $this->weight; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setWeight($weight) { | ||
$this->weight = $weight; | ||
return $weight; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPlugin() { | ||
return $this->getPluginCollection()->get($this->plugin); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPluginId() { | ||
return $this->plugin; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setPluginId($plugin_id) { | ||
$this->plugin = $plugin_id; | ||
$this->configuration = []; | ||
$this->pluginCollection = NULL; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPluginConfiguration() { | ||
return $this->configuration; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function setPluginConfiguration(array $configuration) { | ||
$this->configuration = $configuration; | ||
$this->pluginCollection = NULL; | ||
return $this; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getPluginCollections() { | ||
return [ | ||
'configuration' => $this->getPluginCollection(), | ||
]; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function set($property_name, $value) { | ||
// Invoke the setters to clear related properties. | ||
if ($property_name == 'plugin') { | ||
$this->setPluginId($value); | ||
} | ||
elseif ($property_name == 'configuration') { | ||
$this->setPluginConfiguration($value); | ||
} | ||
else { | ||
return parent::set($property_name, $value); | ||
} | ||
} | ||
|
||
/** | ||
* Gets the plugin collection that holds the recurring engine plugin. | ||
* | ||
* Ensures the plugin collection is initialized before returning it. | ||
* | ||
* @return \Drupal\commerce\CommerceSinglePluginCollection | ||
* The plugin collection. | ||
*/ | ||
protected function getPluginCollection() { | ||
if (!$this->pluginCollection) { | ||
$plugin_manager = \Drupal::service('plugin.manager.commerce_recurring_engine'); | ||
$this->pluginCollection = new CommerceSinglePluginCollection($plugin_manager, $this->plugin, $this->configuration, $this->id); | ||
} | ||
return $this->pluginCollection; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
|
||
namespace Drupal\commerce_recurring\Entity; | ||
|
||
use Drupal\commerce_order\Entity\OrderInterface; | ||
use Drupal\Core\Config\Entity\ConfigEntityInterface; | ||
use Drupal\Core\Entity\EntityWithPluginCollectionInterface; | ||
|
||
/** | ||
* Defines the interface for recurring engine configuration entities. | ||
* | ||
* Stores configuration for recurring engine plugins. | ||
*/ | ||
interface RecurringEngineInterface extends ConfigEntityInterface, EntityWithPluginCollectionInterface { | ||
|
||
/** | ||
* Gets the recurring engine weight. | ||
* | ||
* @return string | ||
* The recurring engine weight. | ||
*/ | ||
public function getWeight(); | ||
|
||
/** | ||
* Sets the recurring engine weight. | ||
* | ||
* @param int $weight | ||
* The recurring engine weight. | ||
* | ||
* @return $this | ||
*/ | ||
public function setWeight($weight); | ||
|
||
/** | ||
* Gets the recurring engine plugin. | ||
* | ||
* @return \Drupal\commerce_recurring\Plugin\Commerce\RecurringEngine\RecurringEngineInterface | ||
* The recurring engine plugin. | ||
*/ | ||
public function getPlugin(); | ||
|
||
/** | ||
* Gets the recurring engine plugin ID. | ||
* | ||
* @return string | ||
* The recurring engine plugin ID. | ||
*/ | ||
public function getPluginId(); | ||
|
||
/** | ||
* Sets the recurring engine plugin ID. | ||
* | ||
* @param string $plugin_id | ||
* The recurring engine plugin ID. | ||
* | ||
* @return $this | ||
*/ | ||
public function setPluginId($plugin_id); | ||
|
||
/** | ||
* Gets the recurring engine plugin configuration. | ||
* | ||
* @return string | ||
* The recurring engine plugin configuration. | ||
*/ | ||
public function getPluginConfiguration(); | ||
|
||
/** | ||
* Sets the recurring engine plugin configuration. | ||
* | ||
* @param array $configuration | ||
* The recurring engine plugin configuration. | ||
* | ||
* @return $this | ||
*/ | ||
public function setPluginConfiguration(array $configuration); | ||
|
||
// @TODO: Figure out what other methods (from the plugin?) we might | ||
// want to have on the config entity itself, probably for the sake | ||
// of convenience? Not sure why gateways wrap those functions exactly. | ||
|
||
} | ||
|
Oops, something went wrong.