\FOFModel
FrameworkOnFramework Model class. The Model is the worhorse. It performs all of the business logic based on its state and then returns the raw (processed) data to the caller, or modifies its own state. It's important to note that the model doesn't get data directly from the request (this is the Controller's business) and that it doesn't output anything (that the View's business).
Synopsis
class FOFModel
extends JObject
{
- // members
- protected $__state_set;
- protected $_db;
- protected $event_after_delete;
- protected $event_after_save;
- protected $event_before_delete;
- protected $event_before_save;
- protected $event_change_state;
- protected $event_clean_cache;
- protected $id_list;
- protected $id;
- protected $input;
- protected $list;
- protected $name;
- protected $option;
- protected FOFTable $otable;
- protected JPagination $pagination;
- protected FOFTable $record;
- protected $state;
- protected $table;
- protected $total;
- protected bool $_savestate;
- protected $_forms;
- protected $_formData;
- protected FOFConfigProvider $configProvider;
- protected FOFModelDispatcherBehavior $modelDispatcher;
- protected $default_behaviors;
- // Inherited members from JObject
- protected $_errors;
- // methods
- public static FOFModel getAnInstance()
- public boolean addBehavior()
- public static FOFModel getTmpInstance()
- public static array addIncludePath()
- public static void addTablePath()
- protected static string _createFileName()
- public void __construct()
- public FOFModel setIDsFromRequest()
- public FOFModel setId()
- public integer getId()
- public FOFModel setIds()
- public array getIds()
- public FOFModel reset()
- public FOFModel clearState()
- public FOFModel clearInput()
- public FOFModel setInput()
- public FOFModel resetSavedState()
- public FOFTable getItem()
- public array getList()
- public array getItemList()
- public FOFTable getFirstItem()
- public boolean save()
- public boolean copy()
- public FOFTable getSavedTable()
- public boolean delete()
- public boolean publish()
- public boolean checkout()
- public boolean checkin()
- public boolean isCheckedOut()
- public boolean hit()
- public boolean move()
- public boolean reorder()
- public JPagination getPagination()
- public integer getTotal()
- protected integer _getListCount()
- public mixed getState()
- protected _real_getState()
- public string getHash()
- protected string getUserStateFromRequest()
- protected array _getList()
- public FOFTable getTable()
- protected FOFTable _createTable()
- public string getReorderWhere()
- public JDatabaseQuery buildQuery()
- public array getTableFields()
- public string getTableAlias()
- public boolean buildCountQuery()
- public FOFModel getClone()
- public mixed __get()
- public void __set()
- public FOFModel __call()
- public FOFModel savestate()
- public void populateSavestate()
- protected void populateState()
- public FOFModel applyAccessFiltering()
- public mixed getForm()
- protected mixed loadForm()
- public mixed findFormFilename()
- protected array loadFormData()
- protected void preprocessForm()
- public mixed validateForm()
- public void onBeforeLoadForm()
- public void onAfterLoadForm()
- public void onBeforePreprocessForm()
- public void onAfterPreprocessForm()
- protected void onProcessList()
- protected void onAfterGetItem()
- protected boolean onBeforeSave()
- protected boolean onAfterSave()
- protected boolean onBeforeDelete()
- protected boolean onAfterDelete()
- protected boolean onBeforeCopy()
- protected boolean onAfterCopy()
- protected boolean onBeforePublish()
- protected boolean onAfterPublish()
- protected boolean onBeforeHit()
- protected boolean onAfterHit()
- protected boolean onBeforeMove()
- protected boolean onAfterMove()
- protected boolean onBeforeReorder()
- protected boolean onAfterReorder()
- public JDatabaseDriver getDbo()
- public string getName()
- public void setDbo()
- public mixed setState()
- protected void cleanCache()
- // Inherited methods from JObject
- public void __construct()
- public string __toString()
- public mixed def()
- public mixed get()
- public array getProperties()
- public string getError()
- public array getErrors()
- public mixed set()
- public boolean setProperties()
- public void setError()
Hierarchy
Members
protected
- $__state_set
—
boolean
Indicates if the internal state has been set - $_db
—
Database Connector - $_errors
—
array
An array of error messages or Exception objects. - $_formData
—
array
The data to load into a form - $_forms
—
array
Array of form objects. - $_savestate
—
bool
Should I save the model's state in the session? - $configProvider
—
FOFConfigProvider
An instance of FOFConfigProvider to provision configuration overrides - $default_behaviors
—
array
Default behaviors to apply to the model - $event_after_delete
—
string
The event to trigger after deleting the data. - $event_after_save
—
string
The event to trigger after saving the data. - $event_before_delete
—
string
The event to trigger before deleting the data. - $event_before_save
—
string
The event to trigger before saving the data. - $event_change_state
—
string
The event to trigger after changing the published state of the data. - $event_clean_cache
—
string
The event to trigger when cleaning cache. - $id
—
int
The first row ID passed to the model's state - $id_list
—
array
Stores a list of IDs passed to the model's state - $input
—
array
Input variables, passed on from the controller, in an associative array - $list
—
array
The list of records made available through getList - $modelDispatcher
—
FOFModelDispatcherBehavior
FOFModelDispatcherBehavior for dealing with extra behaviors - $name
—
string
The model (base) name - $option
—
string
The URL option for the component. - $otable
—
FOFTable
The table object, populated when saving data - $pagination
—
JPagination
Pagination object - $record
—
FOFTable
The table object, populated when retrieving data - $state
—
string
A state object - $table
—
string
The name of the table to use - $total
—
int
Total rows based on the filters set in the model's state
Methods
protected
- _createFileName() — Create the filename for a resource
- _createTable() — Method to load and return a model object.
- _getList() — Returns an object list
- _getListCount() — Returns a record count for the query
- _real_getState() — Method to get model state variables
- cleanCache() — Clean the cache
- getUserStateFromRequest() — Gets the value of a user state variable.
- loadForm() — Method to get a form object.
- loadFormData() — Method to get the data that should be injected in the form.
- onAfterCopy() — This method runs after a record has been copied
- onAfterDelete() — This method runs after a record with key value $id is deleted
- onAfterGetItem() — This method runs after an item has been gotten from the database in a read operation. You can modify it before it's returned to the MVC triad for further processing.
- onAfterHit() — This method runs after a record has been hit
- onAfterMove() — This method runs after a record has been moved
- onAfterPublish() — This method runs after a record has been published
- onAfterReorder() — This method runs after a table is reordered
- onAfterSave() — This method runs after the data is saved to the $table.
- onBeforeCopy() — This method runs before a record is copied
- onBeforeDelete() — This method runs before the record with key value of $id is deleted from $table
- onBeforeHit() — This method runs before a record is hit
- onBeforeMove() — This method runs before a record is moved
- onBeforePublish() — This method runs before a record is published
- onBeforeReorder() — This method runs before a table is reordered
- onBeforeSave() — This method runs before the $data is saved to the $table. Return false to stop saving.
- onProcessList() — This method can be overriden to automatically do something with the list results array. You are supposed to modify the list which was passed in the parameters; DO NOT return a new array!
- populateState() — Method to auto-populate the model state.
- preprocessForm() — Method to allow derived classes to preprocess the form.
public
- __construct() — Public class constructor
- __call() — Magic caller; allows to use the name of model state keys as methods to set their values.
- __get() — Magic getter; allows to use the name of model state keys as properties
- __set() — Magic setter; allows to use the name of model state keys as properties
- addBehavior() — Adds a behavior to the model
- addIncludePath() — Add a directory where FOFModel should search for models. You may either pass a string or an array of directories.
- addTablePath() — Adds to the stack of model table paths in LIFO order.
- applyAccessFiltering() — Applies view access level filtering for the specified user. Useful to filter a front-end items listing.
- buildCountQuery() — Builds the count query used in getTotal()
- buildQuery() — Builds the SELECT query
- checkin() — Checks in the current item
- checkout() — Checks out the current item
- clearInput() — Clears the input array.
- clearState() — Clears the model state, but doesn't touch the internal lists of records, record tables or record id variables. To clear these values, please use reset().
- copy() — Copy one or more records
- delete() — Deletes one or several items
- findFormFilename() — Guesses the best candidate for the path to use for a particular form.
- getAnInstance() — Returns a new model object. Unless overriden by the $config array, it will try to automatically populate its state from the request variables.
- getClone() — Clones the model object and returns the clone
- getDbo() — Method to get the database driver object
- getFirstItem() — A cross-breed between getItem and getItemList. It runs the complete query, like getItemList does. However, instead of returning an array of ad-hoc objects, it binds the data from the first item fetched on the list to an instance of the table object and returns that table object instead.
- getForm() — A method for getting the form from the model.
- getHash() — Returns a hash for this component and view, e.g. "foobar.items.", used for determining the keys of the variables which will be placed in the session storage.
- getId() — Returns the currently set ID
- getIds() — Returns the list of IDs for batch operations
- getItem() — Returns a single item. It uses the id set with setId, or the first ID in the list of IDs for batch operations
- getItemList() — Returns a list of items
- getList() — Alias for getItemList
- getName() — Method to get the model name
- getPagination() — Get a pagination object
- getReorderWhere() — Creates the WHERE part of the reorder query
- getSavedTable() — Returns the table object after the last save() operation
- getState() — Get a filtered state variable
- getTable() — Method to get a table object, load it if necessary.
- getTableAlias() — Get the alias set for this model's table
- getTableFields() — Returns a list of the fields of the table associated with this model
- getTmpInstance() — Returns a new instance of a model, with the state reset to defaults
- getTotal() — Get the number of all items
- hit() — Increments the hit counter
- isCheckedOut() — Tells you if the current item is checked out or not
- move() — Moves the current item up or down in the ordering list
- onAfterLoadForm() — Allows the manipulation after the form is loaded
- onAfterPreprocessForm() — Allows data and form manipulation after preprocessing the form
- onBeforeLoadForm() — Allows the manipulation before the form is loaded
- onBeforePreprocessForm() — Allows data and form manipulation before preprocessing the form
- populateSavestate() — Initialises the _savestate variable
- publish() — Toggles the published state of one or several items
- reorder() — Reorders all items in the table
- reset() — Resets the model, like it was freshly loaded
- resetSavedState() — Resets the saved state for this view
- save() — Binds the data to the model and tries to save it
- savestate() — Sets the model state auto-save status. By default the model is set up to save its state to the session.
- setDbo() — Method to set the database driver object
- setIDsFromRequest() — Sets the list of IDs from the request data
- setId() — Sets the ID and resets internal data
- setIds() — Sets a list of IDs for batch operations from an array and resets the model
- setInput() — Set the internal input field
- setState() — Method to set model state variables
- validateForm() — Method to validate the form data.
Inherited from JObject
public
- __toString() — Magic method to convert the object to a string gracefully.
- def() — Sets a default value if not alreay assigned
- get() — Returns a property of the object or the default value if the property is not set.
- getError() — Get the most recent error message.
- getErrors() — Return all errors, if any.
- getProperties() — Returns an associative array of object properties.
- set() — Modifies a property of the object, creating it if it does not already exist.
- setError() — Add an error message.
- setProperties() — Set the object properties based on a named array/hash.