Completed
Pull Request — master (#28)
by Christopher
07:47
created

Event::getCreatedBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace TechWilk\Rota;
4
5
use TechWilk\Rota\Authoriser\EventAuthoriser;
6
use TechWilk\Rota\Base\Event as BaseEvent;
7
8
/**
9
 * Skeleton subclass for representing a row from the 'cr_events' table.
10
 *
11
 *
12
 *
13
 * You should add additional methods to this class to meet the
14
 * application requirements.  This class will only be generated as
15
 * long as it does not already exist in the output directory.
16
 */
17
class Event extends BaseEvent
18
{
19
    /**
20
     * Get array of userroles currently assigned to the event.
21
     *
22
     * @return array of UserRole() objects
23
     */
24
    public function getCurrentUserRoles()
25
    {
26
        $eventPeople = $this->getEventPeople();
27
28
        $userRoles = [];
29
        foreach ($eventPeople as $eventPerson) {
30
            $userRoles[] = $eventPerson->getUserRole();
31
        }
32
33
        return $userRoles;
34
    }
35
36
    public function authoriser()
37
    {
38
        return new EventAuthoriser($this);
39
    }
40
41
    /**
42
     * Get the [createdby] column value.
43
     *
44
     * @return User
45
     */
46
    public function getCreatedBy()
47
    {
48
        return UserQuery::create()->findPk($this->createdby);
49
    }
50
51
    /**
52
     * Set the value of [createdby] column.
53
     *
54
     * @param User|int $v new value
55
     *
56
     * @return $this|\TechWilk\Rota\Event The current object (for fluent API support)
57
     */
58
    public function setCreatedBy($v)
59
    {
60
        if (is_a('\TechWilk\Rota\User', $v)) {
61
            $v = $v->getId();
62
        }
63
64
        return parent::setCreatedBy($v);
65
    }
66
67
    // setCreatedBy()
68
}
69