tangra logo
   
[ class tree: tangra_lib ] [ index: tangra_lib ] [ all elements ]
 

Class: Vars_Manager

Source Location: /core/vars_manager.class.php

Class Vars_Manager

Class Overview

Container for values that provides unified access.

Class Vars_Manager and it's descendants are used to provide container for variables. Objects of class Vars_Manager are intended to be stored in $_SESSION that is way they have garbage_collector() - to clean up old data.

Located in /core/vars_manager.class.php [line 32]

Tangra_Class
   |
   --Vars_Manager
Author(s):
API Tags:
See:  Session_Vars_Manager, Thread_Vars_Manager

Properties

Methods

[ Top ]
Descendants
Child Class Description
Session_Vars_Manager Session Variables Manager
Thread_Vars_Manager Thread Vars Manager (TVM)

[ Top ]
Inherited Properties, Constants, and Methods
Inherited Properties Inherited Methods Inherited Constants

Inherited From Tangra_Class

Tangra_Class::get_class_name()
Alias of get_class(). Exist because of historical reasons.
Tangra_Class::__set()
Overides PHP built-in method and just throws exception if called. Purpose - to "forbid" autosetting of nonexisting class properties.

[ Top ]
Property Summary
array   $atimes   Holds last access time for each variable
unknown_type   $gc_maxlifetime   Maximum life time for the variables. If (time() - $atime) > $gc_maxlifetime variable will be seen as garbage.
array   $vars   Storage for the values

[ Top ]
Method Summary
Vars_Manager   __construct()   Constructor
void   add_var()   Adds new variable. Shortcut for register_var() and set_var()
void   garbage_collector()   Collects the garbage.
any   &get_var()   Gets variable as reference. Use this function if you intend to change the value.
boolean   is_var_registered()   Checks if variable with name provided by $var_name exists.
any   query_var()   Query variable. Similar to get_var() but returns copy of the variable, not reference. Use this function instead of get_var() if you are not intending to change the value.
void   register_var()   Registers variable. You have first to register variable before using Vars_Manager::set_var()
void   remove_var()   Removes/unregisters variable.
void   set_var()   Sets variable.

[ Top ]
Properties
array   $atimes = array() [line 45]

Holds last access time for each variable

API Tags:
Access:  private


[ Top ]
unknown_type   $gc_maxlifetime [line 52]

Maximum life time for the variables. If (time() - $atime) > $gc_maxlifetime variable will be seen as garbage.

API Tags:
Access:  private


[ Top ]
array   $vars = array() [line 38]

Storage for the values

API Tags:
Access:  private


[ Top ]
Methods
Constructor __construct  [line 60]

  Vars_Manager __construct( [integer $gc_maxlifetime = 1440]  )

Constructor

Parameters:
integer   $gc_maxlifetime:  Maximum life time for variables after which will be seen as garbage.


[ Top ]
add_var  [line 92]

  void add_var( string $var_name, &$value, any $value  )

Adds new variable. Shortcut for register_var() and set_var()

Parameters:
string   $var_name: 
any   $value:  must be a variable not reference. Use temporary variables if needed.
   &$value: 

API Tags:
Access:  public


[ Top ]
garbage_collector  [line 196]

  void garbage_collector( )

Collects the garbage.

Normally this function is not called directly by the user.


API Tags:
Access:  public


[ Top ]
get_var  [line 128]

  any &get_var( string $var_name  )

Gets variable as reference. Use this function if you intend to change the value.

If variable is not found - throws exception.

Parameters:
string   $var_name: 

API Tags:
Return:  rvalue is eturned as reference
Access:  public

Information Tags:
Throws:  TE_Var_Not_Exists

[ Top ]
is_var_registered  [line 185]

  boolean is_var_registered( string $var_name  )

Checks if variable with name provided by $var_name exists.

Parameters:
string   $var_name: 

API Tags:
Access:  public


[ Top ]
query_var  [line 149]

  any query_var( string $var_name  )

Query variable. Similar to get_var() but returns copy of the variable, not reference. Use this function instead of get_var() if you are not intending to change the value.

If variable is not found - throws exception.

Parameters:
string   $var_name: 

API Tags:
Access:  public

Information Tags:
Throws:  TE_Var_Not_Exists

[ Top ]
register_var  [line 72]

  void register_var( string $var_name, [boolean $expires = true]  )

Registers variable. You have first to register variable before using Vars_Manager::set_var()

Parameters:
string   $var_name: 
boolean   $expires:  - if false variable will be never seen as garbage. Default is true.

API Tags:
Access:  public


[ Top ]
remove_var  [line 169]

  void remove_var( string $var_name  )

Removes/unregisters variable.

If variable is not found - throws exception.

Parameters:
string   $var_name: 

API Tags:
Access:  public

Information Tags:
Throws:  TE_Var_Not_Exists

[ Top ]
set_var  [line 107]

  void set_var( string $var_name, &$value, any $value  )

Sets variable.

Variable must be already registered - if not - throws exception.

Parameters:
string   $var_name: 
any   $value: 
   &$value: 

API Tags:
Access:  public

Information Tags:
Throws:  TE_Var_Not_Exists

[ Top ]