TracedArray Class Reference
[Lib]
This class traces access on its members. More...
Public Member Functions |
|
__construct ($arr) | |
Conctructor. |
|
contains ($key) | |
Returns true, if array contains item with
given key. |
|
count () | |
Returns numbers of elements in array.
|
|
get_array () | |
Returns original array. |
|
get_item ($key, $default_value= '') | |
Returns item from array, default value if
item is missing. |
|
has_unused () | |
Returns true, if this array contains
elements that gave not been accessed by get_item. |
|
mark_all_as_used () | |
Marks all array items as read. |
|
redirect_unused ($permanent=false) | |
Redirects to a page containing only unused
items as query parameters. |
|
redirect_used ($permanent=false) | |
Redirects to a page containing only used
items as query parameters. |
Detailed Description
This class traces access on its members.
Definition at line 8 of file tracedarray.cls.php.
Constructor & Destructor Documentation
TracedArray::__construct | ( | $ | arr | ) |
Member Function Documentation
TracedArray::contains | ( | $ | key | ) |
Returns true, if array contains item with given key.
- Parameters:
-
string $key
- Returns:
- bool
Definition at line 57 of file tracedarray.cls.php.
TracedArray::count | ( | ) |
Returns numbers of elements in array.
- Returns:
- int
Definition at line 38 of file tracedarray.cls.php.
00038 { 00039 return count($this->arr); 00040 }
TracedArray::get_array | ( | ) |
TracedArray::get_item | ( | $ | key, | |
$ | default_value = '' |
|||
) |
Returns item from array, default value if item is missing.
- Parameters:
-
string $key mixed $default_value
- Returns:
- mixed
Definition at line 28 of file tracedarray.cls.php.
00028 { 00029 $this->trace[$key] = true; 00030 return Arr::get_item($this->arr, $key, $default_value); 00031 }
TracedArray::has_unused | ( | ) |
Returns true, if this array contains elements that gave not been accessed by get_item.
- Returns:
- bool
Definition at line 66 of file tracedarray.cls.php.
TracedArray::mark_all_as_used | ( | ) |
Marks all array items as read.
Definition at line 78 of file tracedarray.cls.php.
00078 { 00079 foreach($this->arr as $key => $value) { 00080 $this->get_item($key); 00081 } 00082 00083 }
TracedArray::redirect_unused | ( | $ | permanent = false |
) |
Redirects to a page containing only unused items as query parameters.
- Parameters:
-
bool $permanent if true redierct is 301, else it is 302
Definition at line 90 of file tracedarray.cls.php.
00090 { 00091 $url = Url::current()->clear_query(); 00092 foreach($this->arr as $key => $value) { 00093 if (!array_key_exists($key, $this->trace)) { 00094 $url->replace_query_parameter($key, $value); 00095 } 00096 } 00097 $url->redirect($permanent ? Url::PERMANENT : Url::TEMPORARY); 00098 exit(); 00099 }
TracedArray::redirect_used | ( | $ | permanent = false |
) |
Redirects to a page containing only used items as query parameters.
- Parameters:
-
bool $permanent if true redierct is 301, else it is 302
Definition at line 106 of file tracedarray.cls.php.
00106 { 00107 $url = Url::current()->clear_query(); 00108 foreach($this->arr as $key => $value) { 00109 if (array_key_exists($key, $this->trace)) { 00110 $url->replace_query_parameter($key, $value); 00111 } 00112 } 00113 $url->redirect($permanent ? Url::PERMANENT : Url::TEMPORARY); 00114 exit(); 00115 }
The documentation for this class was generated from the following file:
- gyro/core/lib/helpers/tracedarray.cls.php