@@ -37,7 +37,7 @@ function __construct() {
3737 * Returns the APIAuthentication entity associated with the given identifier.
3838 *
3939 * @param string $ident Identifier (e.g. X.509 DN as string)
40- * @return \APIAuthentication APIAuthentication associated with this identifier
40+ * @return \APIAuthentication[] APIAuthentication associated with this identifier
4141 */
4242 public function getAPIAuthentication ($ ident ) {
4343
@@ -48,12 +48,13 @@ public function getAPIAuthentication($ident) {
4848 $ dql = "SELECT a FROM APIAuthentication a " .
4949 "WHERE (a.identifier = :ident) " ;
5050
51+ /* @var $qry \Doctine\DBAL\query */
5152 $ qry = $ this ->em ->createQuery ($ dql );
5253 $ qry ->setParameter ('ident ' , $ ident );
5354
54- $ apiAuth = $ qry ->getOneOrNullResult ();
55+ $ apiAuths = $ qry ->getResult ();
5556
56- return $ apiAuth ;
57+ return $ apiAuths ;
5758 }
5859
5960 /**
@@ -188,17 +189,19 @@ public function editAPIAuthentication(\APIAuthentication $authEntity, \User $use
188189 /**
189190 * Set the last use time field to the current UTC time
190191 *
191- * @param \APIAuthentication $authEntity entity to update
192+ * @param \APIAuthentication[] $authEntities entity to update
192193 * @throws \Exception if the update fails
193194 */
194- public function updateLastUseTime (\ APIAuthentication $ authEntity ) {
195-
195+ public function updateLastUseTime (array $ authEntities )
196+ {
196197 $ this ->em ->getConnection ()->beginTransaction ();
197198
198199 try {
199- $ authEntity ->setLastUseTime ();
200-
201- $ this ->em ->persist ($ authEntity );
200+ /* @var \APIAuthentication $authEntity */
201+ foreach ($ authEntities as $ authEntity ) {
202+ $ authEntity ->setLastUseTime ();
203+ $ this ->em ->persist ($ authEntity );
204+ }
202205
203206 $ this ->em ->flush ();
204207 $ this ->em ->getConnection ()->commit ();
@@ -220,14 +223,15 @@ public function updateLastUseTime(\APIAuthentication $authEntity) {
220223 */
221224 public function uniqueAPIAuthEnt (\Site $ site , $ identifier , $ type ) {
222225
223- $ authEnt = $ this ->getAPIAuthentication ($ identifier , $ type );
226+ $ authEntities = $ this ->getAPIAuthentication ($ identifier , $ type );
224227
225- if (!is_null ($ authEnt ) &&
226- $ authEnt ->getParentSite ()->getId () == $ site ->getId ()) {
227- throw new \Exception (
228- "An authentication object of type \"$ type \" and with identifier " .
229- "\"$ identifier \" already exists for " . $ site ->getName ()
230- );
228+ foreach ($ authEntities as $ authEnt ) {
229+ if ($ authEnt ->getParentSite ()->getId () == $ site ->getId ()) {
230+ throw new \Exception (
231+ "An authentication object of type \"$ type \" and with identifier " .
232+ "\"$ identifier \" already exists for " . $ site ->getName ()
233+ );
234+ }
231235 }
232236 }
233237 /**
0 commit comments