PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.17
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.17
1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 1.10.1 1.10.0 1.9.17 1.9.15 1.9.16 1.9.14 All 163 releases
woocommerce-pos / includes / API / V2 / Writers / Collection_Writer_Resolver.php

Collection_Writer_Resolver.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.17, at includes/API/V2/Writers/Collection_Writer_Resolver.php

41 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Collection writer resolver.
4 *
5 * @package WCPOS\WooCommercePOS\API\V2\Writers
6 */
7
8 // phpcs:disable Squiz.Commenting, Generic.Commenting -- Lifecycle docblocks are intentionally concise.
9
10 namespace WCPOS\WooCommercePOS\API\V2\Writers;
11
12 use WCPOS\WooCommercePOS\Interfaces\Collection_Writer_Interface;
13 use WCPOS\WooCommercePOS\Sync\Mutation_Store;
14 use WCPOS\WooCommercePOS\Sync\Order_Write_Payload;
15
16 /** Resolves registry metadata to one collection writer. */
17 final class Collection_Writer_Resolver {
18 /** @var object Mutation store for order audit persistence. */
19 private $store;
20
21 /** Construct the resolver. */
22 public function __construct( ?object $store = null ) {
23 $this->store = $store ?? new Mutation_Store();
24 }
25
26 /** Resolve with the variation post-type override before the shared post id type. */
27 public function resolve( array $meta ): Collection_Writer_Interface {
28 if ( 'product_variation' === ( $meta['post_type'] ?? '' ) ) {
29 return new Variation_Writer();
30 }
31 switch ( $meta['id_type'] ?? '' ) {
32 case 'order':
33 return new Order_Writer( $this->store, new Order_Write_Payload() );
34 case 'user':
35 return new Customer_Writer();
36 default:
37 return new Null_Writer();
38 }
39 }
40 }
41