| | |
| | | <?php |
| | | namespace JVBase\integrations; |
| | | |
| | | use JVBase\managers\queue\executors\IntegrationExecutor; |
| | | use JVBase\managers\queue\mergers\DefaultMerger; |
| | | use JVBase\managers\queue\TypeConfig; |
| | | use JVBase\meta\Meta; |
| | | use WP_Query; |
| | | |
| | |
| | | protected static string $syncCustomer; |
| | | protected static string $import; |
| | | |
| | | |
| | | protected function setQueueTypes():void |
| | | { |
| | | self::$syncTo = $this->service_name.'_sync_to'; |
| | |
| | | ]); |
| | | return is_wp_error($get) || empty($get) ? false : [$get[0], 'user']; |
| | | } |
| | | |
| | | public function registerQueueTypes():void |
| | | { |
| | | if (empty($this->syncTaxonomies) && empty($this->syncPostTypes)) { |
| | | return; |
| | | } |
| | | $queue = JVB()->queue(); |
| | | $executor = new IntegrationExecutor(); |
| | | |
| | | $queue->registry()->register(self::$syncTo, new TypeConfig( |
| | | mergeable: new DefaultMerger('items'), |
| | | executor: $executor, |
| | | chunkKey: 'items', |
| | | chunkSize: 50, |
| | | maxRetries: 3, |
| | | )); |
| | | |
| | | if ($this->canSync['delete']) { |
| | | $queue->registry()->register(self::$deleteFrom, new TypeConfig( |
| | | mergeable: new DefaultMerger('external_ids'), |
| | | executor: $executor, |
| | | chunkKey: 'external_ids', |
| | | chunkSize: 200, |
| | | maxRetries: 2 |
| | | )); |
| | | } |
| | | |
| | | $queue->registry()->register(self::$syncFrom, new TypeConfig( |
| | | executor: $executor, |
| | | maxRetries: 3 |
| | | )); |
| | | |
| | | $this->registerAdditionalQueueTypes($executor); |
| | | } |
| | | |
| | | /** |
| | | * Empty. Integration extensions can register additional operation types here |
| | | * @param IntegrationExecutor $executor |
| | | * @return void |
| | | */ |
| | | protected function registerAdditionalQueueTypes(IntegrationExecutor $executor):void {} |
| | | |
| | | /** |
| | | * @return void Sets the $this->contentTypes, which is an array of TYPE => [$fields] |
| | | * Should probably set the endpoints here as well, which would be an array of [ TYPE => [ 'create' => '','update' =>'', 'delete'=>'', 'batchCreate'=>'','batchUpdate'=>'', 'batchDelete'=>''] endpoints |
| | | */ |
| | | abstract protected function setContentTypes():void; |
| | | } |