関数
Rest::declareRoutes( WCEXWL\Aivec\WordPress\Routing\WordPressRouteCollector $r )
Declares routes
パラメータ パラメータ
- $r
(WCEXWL\Aivec\WordPress\Routing\WordPressRouteCollector) (必須)
ファイル: src/Routes/Rest.php
public function declareRoutes(WordPressRouteCollector $r) { $r->addGroup('/v3', function (WordPressRouteCollector $r) { // REST handlers $item = new API\Item($this->master); $cart = new API\Cart($this->master); $wishlist = new API\Wishlist($this->master); $validation = new API\Validation($this->master); // route guards and middleware $isLoggedIn = [$validation, 'isLoggedIn']; $maybeClearCart = [$wishlist, 'maybeClearCart']; $beforeRouteEnter = [$this, 'beforeRouteEnter']; // REST routes $r->post('/item/addToWishlist', [$item, 'postToWishlist'], [$beforeRouteEnter]); $r->post('/cart/addToWishlist', [$cart, 'postToWishlistBySerial'], [$beforeRouteEnter]); $r->post('/cart/batchDelete', [$cart, 'batchDelete'], [$beforeRouteEnter]); $r->post('/wishlist/delete/{itemId}', [$wishlist, 'delete'], [$beforeRouteEnter, $isLoggedIn]); $r->post('/wishlist/batchDelete', [$wishlist, 'batchDelete'], [$beforeRouteEnter, $isLoggedIn]); $r->post('/wishlist/addToCart/{itemId}', [$wishlist, 'addToCart'], [$beforeRouteEnter, $isLoggedIn, $maybeClearCart]); $r->post('/wishlist/batchAddToCart', [$wishlist, 'batchAddToCart'], [$beforeRouteEnter, $isLoggedIn, $maybeClearCart]); }); }