Exemplo n.º 1
0
 /**
  * @param	Watchlist $watchlist The watchlist object to add.
  */
 protected function doAddWatchlist($watchlist)
 {
     $this->collWatchlists[] = $watchlist;
     $watchlist->setUser($this);
 }
Exemplo n.º 2
0
use GW2Spidy\DB\ItemQuery;
use Symfony\Component\HttpFoundation\Request;
/**
 * ----------------------
 *  route /watchlistadd POST
 * ----------------------
 */
$app->get("/watchlist/add/{dataId}", function (Request $request, $dataId) use($app) {
    if (!($user = $app['user'])) {
        return $app->redirect($app['url_generator']->generate('login'));
    }
    if ($item = ItemQuery::create()->findPk($dataId)) {
        // check unique
        if (!WatchlistQuery::create()->filterByUser($user)->filterByItem($item)->count()) {
            $w = new Watchlist();
            $w->setUser($user);
            $w->setItemId($dataId);
            $w->save();
        }
    }
    $uri = $request->headers->get('referer');
    if ($uri && preg_match('/\\/login/', $uri)) {
        $uri = null;
    }
    return $app->redirect($uri ?: $app['url_generator']->generate('watchlist'));
})->assert('dataId', '\\d+')->bind('watchlistaddpost');
/**
 * ----------------------
 *  route /watchlistremove POST
 * ----------------------
 */
Exemplo n.º 3
0
 /**
  * @param	User $user The user object to add.
  */
 protected function doAddUser($user)
 {
     $watchlist = new Watchlist();
     $watchlist->setUser($user);
     $this->addWatchlist($watchlist);
 }