| | |
| | | |
| | | use JVBase\managers\queue\{Executor, Operation, Progress, Result}; |
| | | use Exception; |
| | | use JVBase\integrations\ServiceMap; |
| | | use JVBase\managers\Errors; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | * {integration}_sync_from, {integration}_sync_customer, etc. |
| | | * |
| | | * Registration (in Integrations::registerAdditionalHooks): |
| | | * $queue = JVB()->queue(); |
| | | * $queue = Queue::getInstance(); |
| | | * $queue->registry()->register('helcim_sync_to', new TypeConfig( |
| | | * executor: new IntegrationExecutor(), |
| | | * chunkKey: 'items', |
| | |
| | | */ |
| | | final class IntegrationExecutor implements Executor |
| | | { |
| | | /** |
| | | * Map of integration service names to class identifiers. |
| | | * Populated on first use from JVB()->connect(). |
| | | */ |
| | | private array $integrationCache = []; |
| | | use ServiceMap; |
| | | |
| | | |
| | | public function execute(Operation $operation, Progress $progress): Result |
| | | { |
| | |
| | | }; |
| | | |
| | | } catch (Exception $e) { |
| | | JVB()->error()->log( |
| | | Errors::getInstance()->log( |
| | | '[IntegrationExecutor]:execute', |
| | | $e->getMessage(), |
| | | [ |
| | |
| | | if ($userId === 0) { |
| | | $userId = null; |
| | | } |
| | | return JVB()->connect($serviceName, $userId); |
| | | return $this->getServiceUser($serviceName, $userId); |
| | | } |
| | | |
| | | /***************************************************************** |