\Ceo\Core\ManagersAssignmentManager

Core assignment manager

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()
find()
findFirst()
findFirstById()
findFirstByUuid()
findFirstBySrn()
findDueBetween()
create()
update()
delete()
updateDue()
updatePublish()
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

find()

find(mixed  $parameters = null) : mixed

Find assignment

Parameters

mixed $parameters

Returns

mixed

findFirst()

findFirst(mixed  $params = null) : mixed

Find first based on params

Parameters

mixed $params

Returns

mixed

findFirstById()

findFirstById(mixed  $params = null) : mixed

Find first content by ID

Parameters

mixed $params

Returns

mixed

findFirstByUuid()

findFirstByUuid(string  $uuid) : object

Find first item by given UUID

Parameters

string $uuid

Returns

object —

ContentModel

findFirstBySrn()

findFirstBySrn(string  $srn) : \Ceo\Core\Models\Assignment

Find first instance by SRN

Parameters

string $srn

SRN

Returns

\Ceo\Core\Models\Assignment

findDueBetween()

findDueBetween(  $after,   $before) 

Parameters

$after
$before

create()

create(array  $input, mixed  $user = false) : \Ceo\Core\Models\Assignment

Create new assignment. Accepts: * slug * abstract * content * notes * due_at - int or string * users - array of assigned users * children - array of assigned content items

Parameters

array $input

Assignment data

mixed $user

Creating user ID or object

Throws

\Ceo\Core\Managers\Exception

if unable to parse due date

Returns

\Ceo\Core\Models\Assignment

update()

update(integer  $id, array  $input, mixed  $user = false) : \Ceo\Core\Models\Assignment

Update assignment. Accepts: * slug * abstract * content * notes * due_at - int or string * users - array of assigned users * children - array of assigned content items

Keep in mind Users and Children are overwritten, not added to existing collection

Parameters

integer $id

Assignment ID

array $input

Assignment data

mixed $user

Creating user ID or object

Throws

\Ceo\Core\Managers\Exception

if unable to find assignment or parse date

Returns

\Ceo\Core\Models\Assignment

delete()

delete(integer  $id) : boolean

Remove assignment. This does not remove associated children

Parameters

integer $id

Assignment id

Throws

\Ceo\Core\Managers\Exception

if unable to load assignment

Returns

boolean

updateDue()

updateDue(integer  $id, mixed  $time) : \Ceo\Core\Models\Assignment

Update only the due date for the assignment

Parameters

integer $id

Assignment ID

mixed $time

timestamp or date string

Throws

\Ceo\Core\Managers\Exception

If unable to load assignment or parse date

Returns

\Ceo\Core\Models\Assignment

updatePublish()

updatePublish(integer  $id, mixed  $time) : \Ceo\Core\Models\Assignment

Update only the publish time of assignment. This will also update associated children's published time.

Parameters

integer $id

Assignment ID

mixed $time

Timestamp or date string

Throws

\Ceo\Core\Managers\Exception

If unable to load assignment or parse date

Returns

\Ceo\Core\Models\Assignment