Exemplo n.º 1
0
 */
/** Load Slim library */
require_once '../../../lib/Slim-2.1.0/Slim/Slim.php';
/** Load ClassLoader */
require_once '../../../server/php/ClassLoader.php';
use Webservice\User\UserHandler;
use Webservice\User\UserGetHandler;
use Webservice\User\UserBadgesHandler;
use Helper\SlimHelper;
// Load Slim library
\Slim\Slim::registerAutoloader();
Kort\ClassLoader::registerAutoLoader();
$app = new \Slim\Slim();
$slim = new SlimHelper($app);
\session_start();
$userHandler = new UserHandler();
$userGetHandler = new UserGetHandler();
$userBadgesHandler = new UserBadgesHandler();
// define REST resources
$app->get('/(:secret)', function ($secret = null) use($userGetHandler, $slim) {
    if (empty($secret) && isset($_SESSION['secret'])) {
        $secret = $_SESSION['secret'];
    }
    $userData = $userGetHandler->getUserBySecret($secret);
    $slim->returnData($userData);
});
$app->get('/:id/badges', function ($id) use($userBadgesHandler, $slim, $app) {
    $userBadgesHandler->setLanguage($app->request()->params('lang'));
    $userBadges = $userBadgesHandler->getUserBadges($id);
    $slim->returnData($userBadges);
});
Exemplo n.º 2
0
 /**
  * Update a user from the database.
  *
  * @param array $appUser Array of user infos from the application.
  * @param array $user    Array of user infos from OAuth.
  *
  * @return array The updated user from the database
  */
 protected function updateApplicationUser(array $appUser, array $user)
 {
     $userHandler = new UserHandler();
     $dbUser = $userHandler->updateUser($appUser['id'], $user);
     return $dbUser;
 }