\Ceo\Core\ManagersLockManager

Lock manager handles creation and management of locking requests.

Managers provide a service layer in front of models. Managers implement domain specific logic, checks and initialization that would normally live in multiple controllers.

Summary

Methods
Properties
Constants
save()
getPaginator()
restDelete()
restCreate()
restUpdate()
create()
release()
isLocked()
isLockedByUser()
findFirstByContentSrn()
findFirstByUuid()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

save()

save(object  $obj) : object

Save handler, because DRY

Parameters

object $obj

Model to be saved

Throws

\Ceo\Core\Managers\Exception

Json encoded string of validation errors

Returns

object —

Model

getPaginator()

getPaginator(integer  $page = 1, integer  $limit = 50) : \Ceo\Core\Managers\Ceo\Core\ModelHelpers\Paginator

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

Returns

\Ceo\Core\Managers\Ceo\Core\ModelHelpers\Paginator

restDelete()

restDelete(\Ceo\Core\Managers\number  $id) : boolean

Delete an object with rest

Parameters

\Ceo\Core\Managers\number $id

Throws

\Exception

Returns

boolean

restCreate()

restCreate(array  $data) 

Create a new object

Parameters

array $data

restUpdate()

restUpdate(integer  $id, array  $data) 

Update an existing object

Parameters

integer $id
array $data

create()

create(string  $srn, mixed  $user) : \Ceo\Core\Models\LockRequest

Create new lock. The SRN parameter is the parent resource SRN.

Parameters

string $srn

PARENT SRN

mixed $user

User model or ID

Throws

\Exception

If lock already exists or mutex service cannot aquire lock

Returns

\Ceo\Core\Models\LockRequest

release()

release(string  $srn, mixed  $user) : boolean

Release a lock. SRN must accompany locking user

Parameters

string $srn

PARENT SRN

mixed $user

User model or ID

Returns

boolean

isLocked()

isLocked(string  $srn) : boolean

Determine if resource is locked

Parameters

string $srn

PARENT SRN

Returns

boolean

isLockedByUser()

isLockedByUser(string  $srn, mixed  $user) : boolean

Determine if resource is locked by user

Parameters

string $srn

PARENT SRN

mixed $user

User model or ID

Returns

boolean

findFirstByContentSrn()

findFirstByContentSrn(string  $srn) : \Ceo\Core\Models\LockRequest

Find first lock instance by PARENT content SRN

Parameters

string $srn

Parent SRN

Returns

\Ceo\Core\Models\LockRequest

findFirstByUuid()

findFirstByUuid(string  $uuid) : \Ceo\Core\Models\LockRequest

Find first lock by lock UUID

Parameters

string $uuid

Lock's UUID

Returns

\Ceo\Core\Models\LockRequest