Hello,
I developped a method to create a user by API request for my needs called by “createMyUser”. Currently this function is in “app/Api/Procedure/UserProcedure.php” but I want to do something cleaner and put it in a plugin (I already developped a plugin and this function could be linked to it).
Reading the documentation, I need to do something like :
$this->api->getProcedureHandler()->withCallback('my_method', function() {
return 'foobar';
});
But I don’t know how to adapt to my purpose…
I think I should create a file located in my plugin directory “myPlugin/Procedure/MyUserProcedure.php”, create a “class UserProcedure extends BaseProcedure” (to access to User methods) and paste my function “createMyUser”.
public function createMyUser($username, $name = '', $email = '', $role = Role::APP_USER)
{
$values = array(
'username' => $username,
'name' => $name,
'email' => $email,
'role' => $role,
'is_ldap_user' => 1,
);
//list($valid, ) = $this->userValidator->validateCreation($values); // For later...
//return $valid ? $this->userModel->create($values) : false; // For later...
return $this->userModel->create($values);
}
Am I wrong ? Does anyone have a solution ?
Thank you !