Automattic\WooCommerce\Internal\Email
DeferredEmailQueue::restore_arg_from_queue
Restore a queued argument after Action Scheduler storage.
Method of the class: DeferredEmailQueue{}
No Hooks.
Returns
mixed.
Usage
// private - for code of main (parent) class only $result = $this->restore_arg_from_queue( $arg );
- $arg(mixed) (required)
- The argument to restore.
DeferredEmailQueue::restore_arg_from_queue() DeferredEmailQueue::restore arg from queue code WC 11.0.1
private function restore_arg_from_queue( $arg ) {
if ( ! is_array( $arg ) ) {
return $arg;
}
if ( ! array_key_exists( self::QUEUED_OBJECT_KEY, $arg ) ) {
foreach ( $arg as $key => $value ) {
$arg[ $key ] = $this->restore_arg_from_queue( $value );
}
return $arg;
}
$reference = $arg[ self::QUEUED_OBJECT_KEY ];
if ( ! is_array( $reference ) || ! isset( $reference['type'], $reference['id'] ) ) {
throw new \UnexpectedValueException( 'Queued email object reference is invalid.' );
}
$id = $reference['id'];
if ( ! is_int( $id ) && ! is_string( $id ) ) {
throw new \UnexpectedValueException( 'Queued email object reference is invalid.' );
}
$object_type = $this->get_supported_object_types()[ (string) $reference['type'] ] ?? null;
if ( ! is_array( $object_type ) ) {
throw new \UnexpectedValueException( 'Queued email object reference is invalid.' );
}
$object = $object_type['fetch']( $id );
if ( ! is_object( $object ) ) {
throw new \UnexpectedValueException( 'Queued email object reference cannot be restored.' );
}
return $object;
}