| 1 |
<?php |
| 2 |
|
| 3 |
namespace StoreEngine\Classes\OrderStatus; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
use StoreEngine\Classes\Exceptions\StoreEngineInvalidArgumentException; |
| 10 |
use StoreEngine\Classes\OrderContext; |
| 11 |
use StoreEngine\Interfaces\OrderStatus; |
| 12 |
|
| 13 |
class Trash implements OrderStatus { |
| 14 |
const STATUS = 'trash'; |
| 15 |
|
| 16 |
public function proceed_to_next_status( OrderContext $context, string $trigger = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
| 17 |
switch ( $trigger ) { |
| 18 |
case 'restore': |
| 19 |
$context->set_order_status( new Draft() ); |
| 20 |
break; |
| 21 |
default: |
| 22 |
throw new StoreEngineInvalidArgumentException( |
| 23 |
sprintf( |
| 24 |
/* translators: %1$s. Requested status transition, %2$s. Current Status */ |
| 25 |
esc_html__( 'Invalid trigger (%1$s) for next status from %2$s', 'storeengine' ), |
| 26 |
esc_html( self::STATUS ), |
| 27 |
esc_html( $trigger ) |
| 28 |
), |
| 29 |
'invalid-trigger' |
| 30 |
); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
public function get_status(): string { |
| 35 |
return self::STATUS; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_status_title(): string { |
| 39 |
return __( 'Trash', 'storeengine' ); |
| 40 |
} |
| 41 |
|
| 42 |
public function get_possible_next_statuses(): array { |
| 43 |
return [ Draft::STATUS ]; |
| 44 |
} |
| 45 |
|
| 46 |
public function get_possible_triggers(): array { |
| 47 |
return [ 'restore' ]; |
| 48 |
} |
| 49 |
} |
| 50 |
|