PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.1
ووسلام – همگام سازی ووکامرس و باسلام v1.10.1
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
sync-basalam / includes / Admin / Product / Operations / ProductOperationFactory.php

ProductOperationFactory.php in ووسلام – همگام سازی ووکامرس و باسلام 1.10.1, at includes/Admin/Product/Operations/ProductOperationFactory.php

47 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SyncBasalam\Admin\Product\Operations;
4
5 use SyncBasalam\Admin\Product\Operations\ProductOperationInterface;
6 use SyncBasalam\Admin\Product\Operations\UpdateProduct;
7 use SyncBasalam\Admin\Product\Operations\CreateProduct;
8 use SyncBasalam\Admin\Product\Operations\ArchiveProduct;
9 use SyncBasalam\Admin\Product\Operations\RestoreProduct;
10
11 defined('ABSPATH') || exit;
12
13 class ProductOperationFactory
14 {
15 private const OPERATIONS = [
16 'update' => UpdateProduct::class,
17 'create' => CreateProduct::class,
18 'archive' => ArchiveProduct::class,
19 'restore' => RestoreProduct::class,
20 ];
21
22 public static function create(string $type): ProductOperationInterface
23 {
24 if (!isset(self::OPERATIONS[$type])) {
25 throw new \InvalidArgumentException(
26 esc_html(sprintf('Operation type "%s" is not supported. Available types: %s',
27 $type,
28 implode(', ', array_keys(self::OPERATIONS))
29 ))
30 );
31 }
32
33 $operationClass = self::OPERATIONS[$type];
34 return syncBasalamContainer()->get($operationClass);
35 }
36
37 public static function getAvailableOperations(): array
38 {
39 return array_keys(self::OPERATIONS);
40 }
41
42 public static function isSupported(string $type): bool
43 {
44 return isset(self::OPERATIONS[$type]);
45 }
46 }
47