# ali2woo-lite/trunk/includes/classes/factory/BackgroundProcessFactory.php

AliNext – WooCommerce Dropshipping Plugin for AliExpress, version trunk. 75 lines.

- Page: https://pluginprobe.com/plugins/ali2woo-lite/trunk/code/includes/classes/factory/BackgroundProcessFactory.php
- Raw: https://pluginprobe.com/plugins/ali2woo-lite/trunk/raw/includes/classes/factory/BackgroundProcessFactory.php
- Modified: 2026-09-07T19:12:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/ali2woo-lite/trunk/code/includes/classes/factory/BackgroundProcessFactory.php#L10-L20`.

```php
<?php
/**
 * Description of ProcessFactory
 *
 * @author Ali2Woo Team
 *
 */
// phpcs:ignoreFile WordPress.Security.EscapeOutput.OutputNotEscaped
namespace AliNext_Lite;;

use Exception;
use DI\Container;
use Throwable;

class BackgroundProcessFactory
{
    public function __construct(
        protected Container $Container
    ){}

    /**
     * @param string $actionCode
     * @return ImportJobInterface
     * @throws Exception
     */
    public function createProcessByCode(string $actionCode): BaseJobInterface
    {
        if ($actionCode == ApplyPricingRulesProcess::ACTION_CODE) {
            return new ApplyPricingRulesProcess();
        }

        if ($actionCode == ImportProcess::ACTION_CODE) {
            return new ImportProcess();
        }

        if ($actionCode == AddProductToImportListProcess::ACTION_CODE) {
            return $this->Container->get(AddProductToImportListProcess::class);
        }

        if ($actionCode == AffiliateCheckProcess::ACTION_CODE) {
            return $this->Container->get(AffiliateCheckProcess::class);
        }

        if ($actionCode == MigrateAlicdnUrlProcess::ACTION_CODE) {
            return $this->Container->get(MigrateAlicdnUrlProcess::class);
        }

        

        throw new Exception('Unknown process given: ' . $actionCode);
    }

    public function getAll(): array
    {
        $codes = [
            ApplyPricingRulesProcess::ACTION_CODE,
            ImportProcess::ACTION_CODE,
            AddProductToImportListProcess::ACTION_CODE,
            AffiliateCheckProcess::ACTION_CODE,
            
        ];

        $jobs = [];

        foreach ($codes as $code) {
            try {
                $jobs[] = $this->createProcessByCode($code);
            } catch (Throwable $e) {
                a2wl_info_log("[BackgroundProcessFactory] Failed to resolve '{$code}': " . $e->getMessage());
            }
        }

        return $jobs;
    }
}
```
