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

Class: GForm_Ctrl_With_Object

Source Location: /form/gform_ctrl_with_obj.class.php

Class GForm_Ctrl_With_Object

Descendants
Child Class Description
GForm_Ctrl_With_Object_EP Controller for Guarded_Form with I_DB_Storable Object with extra_param

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

Inherited From GForm_Ctrl

GForm_Ctrl::$form_guard
GForm_Ctrl::$form_guarded_pairs
GForm_Ctrl::$permanent_external_params
GForm_Ctrl::$processed_states
GForm_Ctrl::$vm

Inherited From Form_Ctrl

Form_Ctrl::$exports
Form_Ctrl::$form
Form_Ctrl::$form_view
Form_Ctrl::$system_name

Inherited From GForm_Ctrl

GForm_Ctrl::__construct()
Constructor
GForm_Ctrl::add_processed_state()
Adds new processed state
GForm_Ctrl::compose_external_params_var_name()
Composes string with external parameters vars name.
GForm_Ctrl::get_permanent_external_param()
Returns value of previosly set external parameter
GForm_Ctrl::get_processed_state()
Returns processed state for submit identified with $form_id
GForm_Ctrl::get_tple_exports()
Gets TPLE_Exports for the form
GForm_Ctrl::get_vm()
Returns reference to used Vars_Mananger
GForm_Ctrl::handle_fresh_submit()
Handles fresh submit of the form.
GForm_Ctrl::handle_repeated_submit()
Handles repeated submit.
GForm_Ctrl::init_guard_vars()
Initialization of guard pairs array and permanent variable
GForm_Ctrl::is_already_processed()
Checks if this submit is already processed
GForm_Ctrl::on_accepted_submit()
Called right after submit is accepted.
GForm_Ctrl::on_process_submit()
Place for your own processing of the validated form data.
GForm_Ctrl::prepare_for_show()
Prepares form for show
GForm_Ctrl::process_submit()
Processes submit
GForm_Ctrl::query_vm()
Returns copy of used Vars_Mananger
GForm_Ctrl::retrieve_permanent_external_params()
Retrieves stored external parameters
GForm_Ctrl::set_permanent_external_param()
Sets parameter that will be stored in vars manager and automatically retrieved after each submit
GForm_Ctrl::set_permanent_external_params()
Stores external parameters in vars manager.
GForm_Ctrl::set_vm()
Sets Vars_Manager that will be used

Inherited From Form_Ctrl

Form_Ctrl::__construct()
Constructor
Form_Ctrl::create_form()
User have to define this method and to return instance of Form
Form_Ctrl::create_form_view()
User have to define this method and to return instance of Form_View
Form_Ctrl::export()
Alias of $this->exports->add_pair()
Form_Ctrl::get_form()
Returns reference to Form object
Form_Ctrl::get_form_submit_event()
Returns form's submit event
Form_Ctrl::get_form_submit_events()
Returns events of form submission both for <input type="submit" and <input type="image"
Form_Ctrl::get_form_view()
Return reference to Form_View object
Form_Ctrl::get_system_name()
Gets name
Form_Ctrl::get_tple_exports()
Gets TPLE_Exports for the form
Form_Ctrl::on_bad_submit()
This method will be called when form submit is not good, i.e. Form_Ctrl::SUBMIT_RESULT_ERROR
Form_Ctrl::on_good_submit()
This method is called when submit is OK.
Form_Ctrl::prepare_for_show()
Descendants of Form_Ctrl may use this method to prepare the form
Form_Ctrl::process_submit()
Processes submit of the form
Form_Ctrl::query_form()
Returns copy of Form object
Form_Ctrl::query_form_view()
Returns copy of Form_View object
Form_Ctrl::set_system_name()
Sets this object's name
Form_Ctrl::_create_form()
Internally called method which sole purpose is to verify that value returned by create_form method is really a instance of Form
Form_Ctrl::_create_form_view()
Internally called method which sole purpose is to verify that value returned by create_form method is really a instance of Form_View

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.

Inherited From Form_Ctrl

Form_Ctrl::SUBMIT_RESULT_ERROR
Form_Ctrl::SUBMIT_RESULT_OK

[ Top ]
Property Summary
unknown_type   $dbc   DB_Connection object
unknown_type   $object   Object that will be controlled. It must be instance of I_DB_Storable
string   $object_id_capture   This string will be searched in $_GET to capture object id
array   $object_to_form_id_links   array that holds Object to form_ids links

[ Top ]
Method Summary
GForm_Ctrl_With_Object   __construct()   Conctructor
void   after_save()   Called right after object is saved.
string   compose_add_new_event_name()   Composes name for add new event
string   compose_object_id_event_name()   Composes name for receiving object id event
void   create_object()   Creates and returns I_DB_Storable object.
Web_Event_Simple   get_add_new_event()   Returns the event for adding new record
DB_Connection   get_dbc()  
I_DB_Storable   get_object()   Returns I_DB_Storable object
Web_Event_Simple   get_object_id_event()   Returns the event for receiving object id
void   init_object_to_form_id_links()   Initializes array that will hold object to form_id links
void   on_accepted_submit()  
void   on_bad_submit()  
void   on_process_submit()   Transfers data from form to object. Saves the object into DB
void   on_trans_ending()   This method will be called just after saving the object and before db transaction end
void   on_trans_started()   This method will be called just before saving the object and after db transaction is stared
void   prepare_for_show()   Prepares form for show
void   process_add_new()   Called when receives command to show "empty" form that will be used to add new record
boolean   process_object_id()   Loads object from the DB, transfers data to form, prepares for show
string   query_object_id_capture()   Returns string for capture of the object id
void   save_object()   Save the object into DB
void   transfer_form2obj()   Transfers data from object to form
void   transfer_obj2form()   Transfers date from object to form
void   _create_object()   Ensures that create_object() returns object that is instance of I_DB_Storable
void   _save_object()   Actual save is called here.

[ Top ]
Properties
unknown_type   $dbc [line 68]

DB_Connection object

API Tags:
Internal:  
Access:  private


[ Top ]
unknown_type   $object [line 60]

Object that will be controlled. It must be instance of I_DB_Storable

API Tags:
Internal:  
Access:  private


[ Top ]
string   $object_id_capture [line 52]

This string will be searched in $_GET to capture object id

API Tags:
Internal:  
Access:  private


[ Top ]
array   $object_to_form_id_links [line 44]

array that holds Object to form_ids links

API Tags:
Internal:  
Access:  protected


[ Top ]
Methods
Constructor __construct  [line 79]

  GForm_Ctrl_With_Object __construct( string $system_name, Vars_Manager $vm, DB_Connection $dbc, [string $object_id_capture = 'obj_id']  )

Conctructor

Parameters:
string   $system_name:  Controller's name
Vars_Manager   $vm:  Permanent Vars_Manager that will be used. Session of Thread VM
DB_Connection   $dbc:  Database connection
string   $object_id_capture:  This string will be searched in $_GET to capture object id


Redefinition of:
GForm_Ctrl::__construct()
Constructor

[ Top ]
after_save  [line 380]

  void after_save( )

Called right after object is saved.

Useful for some post processing. For example: notifying other controllers, etc.


API Tags:
Access:  protected


[ Top ]
compose_add_new_event_name  [line 400]

  string compose_add_new_event_name( )

Composes name for add new event


API Tags:
Access:  public


[ Top ]
compose_object_id_event_name  [line 390]

  string compose_object_id_event_name( )

Composes name for receiving object id event


API Tags:
Access:  public


[ Top ]
create_object  [line 340]

  void create_object( )

Creates and returns I_DB_Storable object.

This method have to be implemented by the user. At the end I_DB_Storable object have to be returned.


API Tags:
Abstract:  
Access:  protected


[ Top ]
get_add_new_event  [line 108]

  Web_Event_Simple get_add_new_event( )

Returns the event for adding new record


API Tags:
Access:  public


[ Top ]
get_dbc  [line 201]

  DB_Connection get_dbc( )


API Tags:
Access:  public


[ Top ]
get_object  [line 175]

  I_DB_Storable get_object( )

Returns I_DB_Storable object


API Tags:
Access:  public


[ Top ]
get_object_id_event  [line 94]

  Web_Event_Simple get_object_id_event( )

Returns the event for receiving object id


API Tags:
Access:  public


[ Top ]
init_object_to_form_id_links  [line 291]

  void init_object_to_form_id_links( )

Initializes array that will hold object to form_id links


API Tags:
Access:  protected


[ Top ]
on_accepted_submit  [line 308]

  void on_accepted_submit( )


API Tags:
See:  GForm_Ctrl::on_accepted_submit()
Access:  protected

Information Tags:
Throws:  Tangra_Exception

Redefinition of:
GForm_Ctrl::on_accepted_submit()
Called right after submit is accepted.

Redefined in descendants as:

[ Top ]
on_bad_submit  [line 405]

  void on_bad_submit( )


API Tags:
Access:  protected


Redefinition of:
Form_Ctrl::on_bad_submit()
This method will be called when form submit is not good, i.e. Form_Ctrl::SUBMIT_RESULT_ERROR

[ Top ]
on_process_submit  [line 210]

  void on_process_submit( )

Transfers data from form to object. Saves the object into DB


API Tags:
Access:  public


Redefinition of:
GForm_Ctrl::on_process_submit()
Place for your own processing of the validated form data.

[ Top ]
on_trans_ending  [line 282]

  void on_trans_ending( DB_Connection $dbc  )

This method will be called just after saving the object and before db transaction end

Feel free to overload this method if you need some postprocessing just after save. For example: creating additional records that depends on result of object saving (its id)

Parameters:
DB_Connection   $dbc: 

API Tags:
Access:  protected


[ Top ]
on_trans_started  [line 270]

  void on_trans_started( DB_Connection $dbc  )

This method will be called just before saving the object and after db transaction is stared

Feel free to overload this method if you need some processing just before save. For example: inserting other records and getting their ids that are needed for current object.

Parameters:
DB_Connection   $dbc: 

API Tags:
Access:  protected


[ Top ]
prepare_for_show  [line 184]

  void prepare_for_show( )

Prepares form for show


API Tags:
Access:  public


Redefinition of:
GForm_Ctrl::prepare_for_show()
Prepares form for show

[ Top ]
process_add_new  [line 153]

  void process_add_new( )

Called when receives command to show "empty" form that will be used to add new record

Transfers data to form, prepares for show


API Tags:
Access:  public


Redefined in descendants as:

[ Top ]
process_object_id  [line 124]

  boolean process_object_id( integer $object_id  )

Loads object from the DB, transfers data to form, prepares for show

Parameters:
integer   $object_id:  - ID of the object

API Tags:
Return:  Returns true if record is loaded, false if not found
Access:  public

Information Tags:
Throws:  Tangra_Exception

[ Top ]
query_object_id_capture  [line 165]

  string query_object_id_capture( )

Returns string for capture of the object id


API Tags:
Access:  public


[ Top ]
save_object  [line 232]

  void save_object( )

Save the object into DB

Please note that saving is in DB transaction.


API Tags:
Access:  protected


[ Top ]
transfer_form2obj  [line 372]

  void transfer_form2obj( )

Transfers data from object to form

User have to implement this method and to transfer each field from form to object Example:

  1.  $object $this->get_object();
  2.  $form $this->get_form();
  3.  
  4.  $object->set_name($form->get_field_value('name'));


API Tags:
Abstract:  
Access:  protected


[ Top ]
transfer_obj2form  [line 356]

  void transfer_obj2form( )

Transfers date from object to form

User have to implement this method and to transfer each field from object to form

Example:

  1.  $object $this->get_object();
  2.  $form $this->get_form();
  3.  
  4.  $form->set_field_value('name'$object->get_name());


API Tags:
Abstract:  
Access:  protected


[ Top ]
_create_object  [line 324]

  void _create_object( )

Ensures that create_object() returns object that is instance of I_DB_Storable


API Tags:
Access:  private

Information Tags:
Throws:  Tangra_Exception

[ Top ]
_save_object  [line 258]

  void _save_object( DB_Connection $dbc, I_DB_Storable $object  )

Actual save is called here.

You can overload this method in order to provide additional parameters to save(), e.g. user id.

Parameters:
DB_Connection   $dbc: 
I_DB_Storable   $object: 

API Tags:
Access:  protected


[ Top ]