GravityView  2.5
The best, easiest way to display Gravity Forms entries on your website.
class-gv-settings.php
Go to the documentation of this file.
1 <?php
2 namespace GV;
3 
4 /** If this file is called directly, abort. */
5 if ( ! defined( 'GRAVITYVIEW_DIR' ) ) {
6  die();
7 }
8 
9 /**
10  * A generic Settings base class.
11  */
12 class Settings {
13  /**
14  * @var array Main storage for key-values in this collection.
15  */
16  private $settings = array();
17 
18  /**
19  * Create with new.
20  *
21  * @api
22  * @since 2.0
23  *
24  * @param array $settings Initial settings. Default: none.
25  * @return \GV\Settings
26  */
27  public function __construct( $settings = array() ) {
28  if ( is_array( $settings ) && ! empty( $settings ) ) {
29  $this->update( $settings );
30  }
31  }
32 
33  /**
34  * Mass update values from the allowed ones.
35  *
36  * @api
37  * @since 2.0
38  *
39  * @param array $settings An array of settings to update.
40  * @return \GV\Settings self chain.
41  */
42  public function update( $settings ) {
43  foreach ( $settings as $key => $value ) {
44  $this->set( $key, $value );
45  }
46  return $this;
47  }
48 
49  /**
50  * Set a setting.
51  *
52  * @param mixed $key The key the value should be added under.
53  * @param mixed $value The value to be added to the key.
54  *
55  * @api
56  * @since 2.0
57  * @return void
58  */
59  public function set( $key, $value ) {
60  $this->settings[ $key ] = $value;
61  }
62 
63  /**
64  * Set an setting.
65  *
66  * @param mixed $key The key in this setting to retrieve.
67  * @param mixed $default A default in case the key is not set.
68  *
69  * @api
70  * @since 2.0
71  * @return mixed|null
72  */
73  public function get( $key, $default = null ) {
74  return Utils::get( $this->settings, $key, $default );
75  }
76 
77  /**
78  * Returns all the objects in this collection as an an array.
79  *
80  * @api
81  * @since 2.0
82  * @return array The objects in this collection.
83  */
84  public function all() {
85  return $this->settings;
86  }
87 }
If this file is called directly, abort.
all()
Returns all the objects in this collection as an an array.
update( $settings)
Mass update values from the allowed ones.
get( $key, $default=null)
Retrieve a setting.
__construct( $settings=array())
Create with new.
update( $settings)
Updates settings.