PluginProbe
Depicter — Popup & Slider Builder / 1.2.0
Depicter — Popup & Slider Builder v1.2.0
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / vendor / htmlburger / wpemerge / src / Input / OldInput.php

OldInput.php in Depicter — Popup & Slider Builder 1.2.0, at vendor/htmlburger/wpemerge/src/Input/OldInput.php

83 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package WPEmerge
4 * @author Atanas Angelov <hi@atanas.dev>
5 * @copyright 2017-2019 Atanas Angelov
6 * @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0
7 * @link https://wpemerge.com/
8 */
9
10 namespace WPEmerge\Input;
11
12 use WPEmerge\Flash\Flash;
13 use WPEmerge\Support\Arr;
14
15 /**
16 * Provide a way to get values from the previous request.
17 */
18 class OldInput {
19 /**
20 * Flash service.
21 *
22 * @var Flash
23 */
24 protected $flash = null;
25
26 /**
27 * Key to store the flashed data with.
28 *
29 * @var string
30 */
31 protected $flash_key = '';
32
33 /**
34 * Constructor.
35 *
36 * @codeCoverageIgnore
37 * @param Flash $flash
38 * @param string $flash_key
39 */
40 public function __construct( Flash $flash, $flash_key = '__wpemergeOldInput' ) {
41 $this->flash = $flash;
42 $this->flash_key = $flash_key;
43 }
44
45 /**
46 * Get whether the old input service is enabled.
47 *
48 * @return boolean
49 */
50 public function enabled() {
51 return $this->flash->enabled();
52 }
53
54 /**
55 * Get request value for key from the previous request.
56 *
57 * @param string $key
58 * @param mixed $default
59 * @return mixed
60 */
61 public function get( $key, $default = null ) {
62 return Arr::get( $this->flash->get( $this->flash_key, [] ), $key, $default );
63 }
64
65 /**
66 * Set input for the next request.
67 *
68 * @param array $input
69 */
70 public function set( $input ) {
71 $this->flash->add( $this->flash_key, $input );
72 }
73
74 /**
75 * Clear input for the next request.
76 *
77 * @return void
78 */
79 public function clear() {
80 $this->flash->clear( $this->flash_key );
81 }
82 }
83