-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUser.php
More file actions
114 lines (101 loc) · 2.78 KB
/
User.php
File metadata and controls
114 lines (101 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace CougarTutorial;
use Cougar\Security\iSecurity;
/**
* Manages application users.
*
* @package CougarTutorial
*/
class User implements iUser
{
/**
* Stores reference to the security context
*
* @param iSecurity $security
* Security context
*/
public function __construct(iSecurity $security)
{
// Store the reference to the security context
$this->security = $security;
}
/***************************************************************************
* PUBLIC PROPERTIES AND METHODS
**************************************************************************/
/**
* Greets the user
*
* @Path /greeting
* @Methods GET
* @Authentication optional
* @XmlRootElement greeting
*
* @return string Greeting
*/
public function greet()
{
if ($this->security->isAuthenticated())
{
$identity = $this->security->getIdentity();
return "Welcome, " . $identity->givenName;
}
else
{
return "Welcome, visitor";
}
}
/**
* Creates a new user from a given object or assoc. array that resembles
* a UserModel object.
*
* @param mixed $user
* User object or associative array
* @return UserModel User model object
*/
public function createUser($user)
{
throw new \Cougar\Exceptions\NotImplementedException("Not implemented");
}
/**
* Gets the user identified by the given User ID
*
* @param string $id
* User ID
* @return UserModel User model object
*/
public function getUser($id)
{
throw new \Cougar\Exceptions\NotImplementedException("Not implemented");
}
/**
* Updates the given user with the object provided. If the provided object
* does not have the ID property set, it may pass it as a method parameter.
*
* @param mixed $user
* User object or associative array (must contain changes)
* @param string $id
* User ID (optional)
* @return UserModel Modified user model object
*/
public function updateUser($user, $id = null)
{
throw new \Cougar\Exceptions\NotImplementedException("Not implemented");
}
/**
* Deletes the user with the given ID.
*
* @param string $id
* User ID
*/
public function deleteUser($id)
{
throw new \Cougar\Exceptions\NotImplementedException("Not implemented");
}
/***************************************************************************
* PROTECTED PROPERTIES AND METHODS
**************************************************************************/
/**
* @var \Cougar\Security\iSecurity $security;
*/
protected $security;
}