Repository navigation
Extended Users
Users are one of the basic features of the framework however on their own they lack flexibility for larger projets built around users. In order to extend users, it is currently necessary to overwrite some parts of the APIne library which would result in compatibility issues and feature loss when upgrading APIne Framework. The goal of this new features is to allow to extend users without actually needing to modify anything. This feature also comes with important guidelines to follow in order to prevent any bugs due to the database.
This feature requires an optional entry in the framework section of the configuration file. This entry should contain the name of the module (name of the folder inside the modules/ directory) in which the extended user and/or its extended factory is located, and the class name of the extended user class. The framework will then load the whole content of the folder as a core component of the framework.
[runtime]
user_class = "user/CustomUser"
Not only the framework will load the whole module but it will also change the output across the session and user module. Per exemple, the default factory will return the extended user instead of the regular one. Idem for the session's get_user method.
Data for the extended entity must not be saved on the same table than the basic user (apine_users). It is highly recommended to use the user property feature already available in the basic user and use the exented user class as a way to add custom getter and setter for these propertires.
class CustomUser extends Apine\User\User {
pritave $address;
public function get_address () {
if ($this->loaded == 0) {
$this->load();
}
return $this->address;
}
public function set_address ($a_value) {
if ($this->loaded == 0) {
$this->load();
}
$this->set_property('address', $a_value);
}
public function load () {
if (!is_null($this->id)) {
if ($this->loaded != 1) {
parent::load();
}
$this->address = $this->get_property('address');
}
}
}
Create a new factory extending Apine\User\Factory\UserFactory then add you own methods to it for you to use. On the other hand, the Framework will still use the default factory.
class CustomUserFactory extends Apine\User\Factory\UserFactory {
// Have fun with your own custom factory methods
}
- Introduction
- Getting Started
- Requirements & Installation
- Application Configuration
- Database Connection
- How to use Controllers
- How to use Views
- How to Manage Session
- How to use the api (Coming Soon)
- Utilities
- Entity Manager
- File Manager
- Access and Save File (Coming Soon)
- Image Methods (Coming Soon)
- XML Manager
- XML Class (Coming Soon)
- Parser (Coming Soon)
- Writer (Coming Soon)
- Advanced Topics
- Extended Users
- Routes
- Templating (Coming Soon)
- Translations and Locales