| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace Jet_Form_Builder\Actions; |
| 5 |
|
| 6 |
// If this file is called directly, abort. |
| 7 |
use JFB_Modules\Block_Parsers\Field_Data_Parser; |
| 8 |
|
| 9 |
if ( ! defined( 'WPINC' ) ) { |
| 10 |
die; |
| 11 |
} |
| 12 |
|
| 13 |
class Legacy_Request_Data implements \Iterator, \ArrayAccess { |
| 14 |
|
| 15 |
/** |
| 16 |
* @return mixed |
| 17 |
*/ |
| 18 |
#[\ReturnTypeWillChange] |
| 19 |
public function current() { |
| 20 |
$parser = current( jet_fb_context()->parsers ); |
| 21 |
|
| 22 |
return ( $parser instanceof Field_Data_Parser ) ? $parser->get_value() : $parser; |
| 23 |
} |
| 24 |
|
| 25 |
#[\ReturnTypeWillChange] |
| 26 |
public function next() { |
| 27 |
next( jet_fb_context()->parsers ); |
| 28 |
} |
| 29 |
|
| 30 |
/** |
| 31 |
* @return bool|float|int|string|null |
| 32 |
*/ |
| 33 |
#[\ReturnTypeWillChange] |
| 34 |
public function key() { |
| 35 |
return key( jet_fb_context()->parsers ); |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* @return bool |
| 40 |
*/ |
| 41 |
public function valid(): bool { |
| 42 |
return $this->key() !== null; |
| 43 |
} |
| 44 |
|
| 45 |
#[\ReturnTypeWillChange] |
| 46 |
public function rewind() { |
| 47 |
reset( jet_fb_context()->parsers ); |
| 48 |
} |
| 49 |
|
| 50 |
/* |
| 51 |
* \ArrayAccess |
| 52 |
*/ |
| 53 |
|
| 54 |
/** |
| 55 |
* @param mixed $offset |
| 56 |
* |
| 57 |
* @return bool |
| 58 |
*/ |
| 59 |
public function offsetExists( $offset ): bool { |
| 60 |
return jet_fb_context()->has_field( $offset ); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* @param mixed $offset |
| 65 |
* |
| 66 |
* @return mixed |
| 67 |
*/ |
| 68 |
#[\ReturnTypeWillChange] |
| 69 |
public function offsetGet( $offset ) { |
| 70 |
return jet_fb_context()->get_value( $offset ); |
| 71 |
} |
| 72 |
|
| 73 |
/** |
| 74 |
* @param mixed $offset |
| 75 |
* @param mixed $value |
| 76 |
*/ |
| 77 |
#[\ReturnTypeWillChange] |
| 78 |
public function offsetSet( $offset, $value ) { |
| 79 |
if ( is_null( $offset ) ) { |
| 80 |
return; |
| 81 |
} |
| 82 |
|
| 83 |
jet_fb_context()->update_request( $value, $offset ); |
| 84 |
} |
| 85 |
|
| 86 |
/** |
| 87 |
* @param mixed $offset |
| 88 |
*/ |
| 89 |
#[\ReturnTypeWillChange] |
| 90 |
public function offsetUnset( $offset ) { |
| 91 |
jet_fb_context()->remove( $offset ); |
| 92 |
} |
| 93 |
|
| 94 |
} |
| 95 |
|