/** * Creates a principal without managing database transactions. For internal use only. This method * is called from both the primary {@link #createPrincipal} method and from the {@link #link} method * if there is no existing principal to use. * * @param string $app_id the application creating the principal. * @param string $network_id the network associated with the user ID. * @param string $uid the subject's user ID on the given network. * @return string the created principal's ID. */ private function _createPrincipal($app_id, $network_id, $uid) { $principal = new RingsidePrincipal(); // TODO: Exception: Throw a meaningful service-level exception $principal->state('TDIRTY'); $principal->save(); $pid = $principal->id; $principal_map = new RingsidePrincipalMap(); $principal_map->principal_id = $pid; $principal_map->app_id = $app_id; $principal_map->network_id = $network_id; $principal_map->uid = $uid; $principal_map->save(); return $pid; }