This repository has been archived by the owner on Feb 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Overriding Warden Classes
dre1080 edited this page Dec 17, 2011
·
1 revision
If you want to override Warden with your own model classes to add your own custom methods and properties, all you have to do is create your model in the APPPATH/classes/model
directory and extend the model class you want to override. Don't forget to add this class to your APPPATH bootstrap.php
file.
Create a file: APPPATH/classes/model/profile.php
class Model_Profile extends \Warden\Model_Profile
{
const REGEX_NAME = '\^[^;]+$';
/**
* Object properties
*
* @var array
*/
protected static $_properties = array(
// Must include original fields
'id',
'user_id',
// My extra custom fields
'first_name' => array(
'validation' => array(
'null' => true,
'match_pattern' => array(self::REGEX_NAME),
),
),
'last_name' => array(
'validation' => array(
'null' => true,
'match_pattern' => array(self::REGEX_NAME),
),
),
'gender'
);
}
In APPPATH/bootstrap.php
:
Autoloader::add_classes(array(
// Add classes you want to override here
'Model_Profile' => APPPATH.'classes/model/profile.php',
));
Now, Warden will automatically use your new Model_Profile when creating/modifying users.
For more detail, view: http://fuelphp.com/forums/topics/view/6451/