| @@ -1,37 +1,36 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * Class WpdbAdapterFactory | |
| 4 | - * | |
| 5 | - * @package Packetery | |
| 6 | - */ | |
| 7 | 2 | |
| 8 | 3 | declare( strict_types=1 ); |
| 9 | 4 | |
| 10 | 5 | namespace Packetery\Module; |
| 11 | 6 | |
| 12 | -/** | |
| 13 | - * Class WpdbAdapterFactory | |
| 14 | - * | |
| 15 | - * @package Packetery | |
| 16 | - */ | |
| 7 | +use Packetery\Module\Framework\WcAdapter; | |
| 8 | + | |
| 17 | 9 | class WpdbAdapterFactory { |
| 18 | 10 | |
| 19 | 11 | /** |
| 20 | - * Creates WpdbAdapter instance | |
| 21 | - * | |
| 22 | - * @return WpdbAdapter | |
| 12 | + * @var WcAdapter | |
| 23 | 13 | */ |
| 14 | + private $wcAdapter; | |
| 15 | + | |
| 16 | + public function __construct( WcAdapter $wcAdapter ) { | |
| 17 | + $this->wcAdapter = $wcAdapter; | |
| 18 | + } | |
| 19 | + | |
| 24 | 20 | public function create(): WpdbAdapter { |
| 25 | 21 | global $wpdb; |
| 26 | 22 | |
| 27 | - $instance = new WpdbAdapter( $wpdb ); | |
| 28 | - $instance->packetery_carrier = sprintf( '%scarrier', $instance->getPacketeryPrefix() ); | |
| 29 | - $instance->packetery_order = sprintf( '%sorder', $instance->getPacketeryPrefix() ); | |
| 30 | - $instance->packetery_log = sprintf( '%slog', $instance->getPacketeryPrefix() ); | |
| 31 | - $instance->posts = $wpdb->posts; | |
| 32 | - $instance->options = $wpdb->options; | |
| 33 | - $instance->postmeta = $wpdb->postmeta; | |
| 23 | + $instance = new WpdbAdapter( $wpdb, $this->wcAdapter ); | |
| 24 | + $instance->packeteryCarrier = sprintf( '%scarrier', $instance->getPacketeryPrefix() ); | |
| 25 | + $instance->packeteryOrder = sprintf( '%sorder', $instance->getPacketeryPrefix() ); | |
| 26 | + $instance->packeteryLog = sprintf( '%slog', $instance->getPacketeryPrefix() ); | |
| 27 | + $instance->packeteryCustomsDeclaration = sprintf( '%scustoms_declaration', $instance->getPacketeryPrefix() ); | |
| 28 | + $instance->packeteryCustomsDeclarationItem = sprintf( '%scustoms_declaration_item', $instance->getPacketeryPrefix() ); | |
| 29 | + $instance->wcOrders = sprintf( '%swc_orders', $wpdb->prefix ); | |
| 30 | + $instance->posts = $wpdb->posts; | |
| 31 | + $instance->options = $wpdb->options; | |
| 32 | + $instance->postmeta = $wpdb->postmeta; | |
| 34 | 33 | |
| 35 | 34 | return $instance; |
| 36 | 35 | } |
| 37 | 36 | } |