Transformers
1 year ago
BaseLocationCountryRuleProcessor.php
2 years ago
BaseLocationStateRuleProcessor.php
2 years ago
ComparisonOperation.php
2 years ago
ContextPluginsRuleProcessor.php
1 year ago
EvaluateAndGetStatus.php
2 years ago
EvaluateOverrides.php
1 year ago
EvaluationLogger.php
1 year ago
FailRuleProcessor.php
2 years ago
GetRuleProcessor.php
2 years ago
GetRuleProcessorForContext.php
1 year ago
IsEcommerceRuleProcessor.php
2 years ago
IsWooExpressRuleProcessor.php
2 years ago
NotRuleProcessor.php
2 years ago
NoteStatusRuleProcessor.php
2 years ago
OnboardingProfileRuleProcessor.php
2 years ago
OptionRuleProcessor.php
2 years ago
OrRuleProcessor.php
2 years ago
OrderCountRuleProcessor.php
2 years ago
OrdersProvider.php
2 years ago
PassRuleProcessor.php
2 years ago
PluginVersionRuleProcessor.php
2 years ago
PluginsActivatedRuleProcessor.php
2 years ago
ProductCountRuleProcessor.php
1 year ago
PublishAfterTimeRuleProcessor.php
2 years ago
PublishBeforeTimeRuleProcessor.php
2 years ago
RuleEvaluator.php
1 year ago
RuleProcessorInterface.php
2 years ago
StoredStateRuleProcessor.php
2 years ago
StoredStateSetupForProducts.php
2 years ago
TotalPaymentsVolumeProcessor.php
1 year ago
WCAdminActiveForProvider.php
2 years ago
WCAdminActiveForRuleProcessor.php
2 years ago
WooCommerceAdminUpdatedRuleProcessor.php
2 years ago
GetRuleProcessorForContext.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors; |
| 6 | |
| 7 | /** |
| 8 | * A custom GetRuleProcessor class to support context_vars and context_plugins rule types. |
| 9 | * |
| 10 | * GetRuleProcessor class. |
| 11 | */ |
| 12 | class GetRuleProcessorForContext { |
| 13 | /** |
| 14 | * Contains the context variables. |
| 15 | * |
| 16 | * @var array $context The context variables. |
| 17 | */ |
| 18 | protected array $context; |
| 19 | |
| 20 | /** |
| 21 | * Constructor. |
| 22 | * |
| 23 | * @param array $context The context variables. |
| 24 | */ |
| 25 | public function __construct( array $context = array() ) { |
| 26 | $this->context = $context; |
| 27 | } |
| 28 | /** |
| 29 | * Get the processor for the specified rule type. |
| 30 | * |
| 31 | * @param string $rule_type The rule type. |
| 32 | * |
| 33 | * @return RuleProcessorInterface The matching processor for the specified rule type, or a FailRuleProcessor if no matching processor is found. |
| 34 | */ |
| 35 | public function get_processor( $rule_type ) { |
| 36 | switch ( $rule_type ) { |
| 37 | case 'context_plugins': |
| 38 | return new ContextPluginsRuleProcessor( $this->context['plugins'] ?? array() ); |
| 39 | } |
| 40 | |
| 41 | return GetRuleProcessor::get_processor( $rule_type ); |
| 42 | } |
| 43 | } |
| 44 |