class UserManager extends BaseManager

User manager provides a standard API to user model management

Methods

object
save(object $obj)

Save handler, because DRY

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

boolean
restDelete(number $id)

Delete an object with rest

restCreate(array $data)

Create a new object

restUpdate(int $id, array $data)

Update an existing object

mixed
find(mixed $parameters = null)

Find users

mixed
findFirst(mixed $params = null)

Find first based on params

mixed
findFirstById(mixed $params = null)

Find first user by ID

mixed
findFirstByUuid(mixed $params = null)

Find first by UUID

object
getForm(mixed $entity = null, array $options = null)

Build and return standard editing form

object
create(array $data)

Create new user with given dataset

UserModel
update(int $id, array $data)

Update user

UserModel
appendRoles(int $id, array $newRoles)

Append ACL roles to existing user

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

delete($id)

No description

restGet(array $params = null, array $options = null, $page = 1, $limit = 10)

No description

Details

in BaseManager at line line 23
object save(object $obj)

Save handler, because DRY

Parameters

object $obj Model to be saved

Return Value

object Model

Exceptions

Exception Json encoded string of validation errors

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);

Parameters

integer $page Current page
integer $limit Per page limit

Return Value

Paginator

at line line 390
boolean restDelete(number $id)

Delete an object with rest

Parameters

number $id

Return Value

boolean

Exceptions

Exception

at line line 408
restCreate(array $data)

Create a new object

Parameters

array $data

at line line 368
restUpdate(int $id, array $data)

Update an existing object

Parameters

int $id
array $data

at line line 22
mixed find(mixed $parameters = null)

Find users

Parameters

mixed $parameters

Return Value

mixed

at line line 32
mixed findFirst(mixed $params = null)

Find first based on params

Parameters

mixed $params

Return Value

mixed

at line line 42
mixed findFirstById(mixed $params = null)

Find first user by ID

Parameters

mixed $params

Return Value

mixed

at line line 52
mixed findFirstByUuid(mixed $params = null)

Find first by UUID

Parameters

mixed $params @params

Return Value

mixed

at line line 63
object getForm(mixed $entity = null, array $options = null)

Build and return standard editing form

Parameters

mixed $entity Entity to prepopulate
array $options Form options

Return Value

object Ceo\Core\Forms\UserForm

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);

Parameters

array $data Initial data for user

Return Value

object Newly created user

Exceptions

Exception Will throw json encoded list of validation or other errors

at line line 176
UserModel update(int $id, array $data)

Update user

Parameters

int $id ID
array $data data

Return Value

UserModel

See also

create

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

Parameters

int $id user ID
array $newRoles New role names

Return Value

UserModel

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

Parameters

$id
$newRoles

Return Value

UserModel

at line line 320
delete($id)

Parameters

$id

at line line 341
restGet(array $params = null, array $options = null, $page = 1, $limit = 10)

Parameters

array $params
array $options
$page
$limit