UserManager
class UserManager extends BaseManager
User manager provides a standard API to user model management
Methods
Helps paginate models using the query bulder. Bit more complicated than the native array method, but works better for larger data sets
Delete an object with rest
Create a new object
Update an existing object
Find users
Find first based on params
Find first user by ID
Find first by UUID
Build and return standard editing form
Create new user with given dataset
Update user
Append ACL roles to existing user
Replace user roles with new roles
echo $user->roles->count(); // 1 $user = $manager->replaceRoles(1, ['Administrator']); echo $user->roles->count(); // 1
No description
No description
Details
in BaseManager at line line 23
object
save(object $obj)
Save handler, because DRY
in BaseManager at line line 60
Paginator
getPaginator(integer $page = 1, integer $limit = 50)
Helps paginate models using the query bulder. Bit more complicated than the native array method, but works better for larger data sets
Because it's based on Phalcon's QueryBuilder, it supports a fluent filtering interface:
$manager = $this->foo_manager; $items = $manager->getPaginator(1, 20) ->orderBy('created_at desc') ->where('name = :name:', array('name' => $name)) ->andWhere('type = :type:', array('type' => $type)) ->paginate(); echo json_encode($items);
at line line 390
boolean
restDelete(number $id)
Delete an object with rest
at line line 408
restCreate(array $data)
Create a new object
at line line 368
restUpdate(int $id, array $data)
Update an existing object
at line line 22
mixed
find(mixed $parameters = null)
Find users
at line line 32
mixed
findFirst(mixed $params = null)
Find first based on params
at line line 42
mixed
findFirstById(mixed $params = null)
Find first user by ID
at line line 52
mixed
findFirstByUuid(mixed $params = null)
Find first by UUID
at line line 63
object
getForm(mixed $entity = null, array $options = null)
Build and return standard editing form
at line line 93
object
create(array $data)
Create new user with given dataset
Accepts an array of user data, including: * name * email * (plain text) password * array of ACL group names
Example:
$userData = [ 'name' => 'Test Testerson', 'email' => 'test@example', 'password' => 'thisisasecret', 'roles' => ['Administrators'] ]; $userManager = $DI->get('user_manager'); $userManager->create($userData);
at line line 176
UserModel
update(int $id, array $data)
Update user
at line line 244
UserModel
appendRoles(int $id, array $newRoles)
Append ACL roles to existing user
echo $user->roles->count(); // 1 $user = $manager->appendRoles(1, ['Administrator']); echo $user->roles->count(); // 2
at line line 291
UserModel
replaceRoles($id, $newRoles)
Replace user roles with new roles
echo $user->roles->count(); // 1 $user = $manager->replaceRoles(1, ['Administrator']); echo $user->roles->count(); // 1