当前位置: 首页>>代码示例>>PHP>>正文


PHP WishList::current方法代码示例

本文整理汇总了PHP中WishList::current方法的典型用法代码示例。如果您正苦于以下问题:PHP WishList::current方法的具体用法?PHP WishList::current怎么用?PHP WishList::current使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WishList的用法示例。


在下文中一共展示了WishList::current方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set_current

 /**
  * @param WishList $list
  */
 public static function set_current($list)
 {
     if ($list) {
         $list->write(false, false, true);
     }
     // force LastEdited to change
     self::$current = $list;
 }
开发者ID:markguinn,项目名称:silverstripe-wishlist,代码行数:11,代码来源:WishList.php

示例2: updateGroupWishListResponse

 /**
  * @param SS_HTTPRequest $request
  * @param AjaxHTTPResponse $response
  * @param GroupedProduct $groupedProduct
  * @param array $data
  * @param GroupedCartForm $form [optional]
  */
 public function updateGroupWishListResponse(&$request, &$response, $groupedProduct, $data, $form = null)
 {
     if ($request->isAjax() && $this->owner->getController()->hasExtension('AjaxControllerExtension')) {
         if (!$response) {
             $response = $this->owner->getController()->getAjaxResponse();
         }
         $this->setupRenderContexts($response, $groupedProduct, $form);
         $response->triggerEvent('wishlistadd');
         $response->triggerEvent('wishlistchange', array('action' => 'add'));
         $n = 0;
         foreach ($data['Product'] as $info) {
             if ($info['Quantity'] > 0) {
                 $n++;
             }
         }
         $s = $n == 1 ? '' : 's';
         $response->triggerEvent('statusmessage', "{$n} item{$s} added to " . WishList::current()->getTitle());
     }
 }
开发者ID:markguinn,项目名称:silverstripe-shop-groupedproducts,代码行数:26,代码来源:GroupedCartFormAjax.php

示例3: addtowishlist

 /**
  * @param array $data
  */
 public function addtowishlist(array $data)
 {
     if (!class_exists('WishList')) {
         user_error('Wish List module not installed.');
     }
     $groupedProduct = $this->getController()->data();
     if (empty($data) || empty($data['Product']) || !is_array($data['Product'])) {
         $this->sessionMessage(_t('GroupedCartForm.EMPTY', 'Please select at least one product.'), 'bad');
         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
         return $response ? $response : $this->controller->redirectBack();
     }
     $list = WishList::current();
     foreach ($data['Product'] as $id => $prodReq) {
         if (!empty($prodReq['Quantity']) && $prodReq['Quantity'] > 0) {
             $prod = Product::get()->byID($id);
             if ($prod && $prod->exists()) {
                 $buyable = $prod;
                 if (isset($prodReq['Attributes'])) {
                     $buyable = $prod->getVariationByAttributes($prodReq['Attributes']);
                     if (!$buyable || !$buyable->exists()) {
                         $this->sessionMessage("{$prod->InternalItemID} is not available with the selected options.", "bad");
                         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
                         return $response ? $response : $this->controller->redirectBack();
                     }
                 }
                 $list->addBuyable($buyable);
             }
         }
     }
     $this->extend('updateGroupWishListResponse', $this->request, $response, $groupedProduct, $data, $this);
     return $response ? $response : $this->controller->redirect(WishListPage::inst()->Link());
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-groupedproducts,代码行数:35,代码来源:GroupedCartForm.php

示例4: testMultipleLists

 public function testMultipleLists()
 {
     WishList::set_current(null);
     $m1 = $this->objFromFixture('Member', 'm1');
     $m2 = $this->objFromFixture('Member', 'm2');
     $m1->logIn();
     $p1 = $this->objFromFixture('Product', 'p1');
     $p2 = $this->objFromFixture('Product', 'p2');
     $p3 = $this->objFromFixture('Product', 'p3');
     // should be able to retrieve a list of lists
     $allLists = WishList::get_for_user();
     $this->assertNotNull($allLists);
     $this->assertTrue($allLists instanceof DataList);
     // should initially be 0 lists
     $this->assertEquals(0, WishList::get_for_user()->count());
     $this->assertEquals(0, WishList::get_for_user($m2)->count());
     // current method should create one list
     $l1 = WishList::current();
     $l1->write();
     $l1->addBuyable($p1);
     //Debug::dump(array($l1, WishList::get_for_user()->sql(), WishList::get_for_user()->count(), WishList::get_for_user()->getIDList()));
     $this->assertEquals(1, WishList::get_for_user()->count());
     $this->assertEquals(0, WishList::get_for_user($m2)->count());
     // after manually creating a list there should be two lists
     $l2 = new WishList(array('OwnerID' => $m1->ID, 'Title' => 'Christmas'));
     $l2->write();
     $this->assertEquals(2, WishList::get_for_user()->count());
     // after adding a product to one list, it should not be present in the other one
     // but should still report that it is in a list
     $l2->addBuyable($p2);
     $this->assertTrue($p1->IsInWishList());
     $this->assertTrue($l1->hasBuyable($p1));
     $this->assertFalse($l2->hasBuyable($p1));
     $this->assertTrue($p2->IsInWishList());
     $this->assertFalse($l1->hasBuyable($p2));
     $this->assertTrue($l2->hasBuyable($p2));
     $this->assertFalse($p3->IsInWishList());
     $this->assertFalse($l1->hasBuyable($p3));
     $this->assertFalse($l2->hasBuyable($p3));
     // after creating a list for the a different user and adding
     // an item to that list, the item should not report that it is
     // in a list and should not be present in any of the other lists
     $l3 = new WishList(array('OwnerID' => $m2->ID, 'Title' => 'Christmas for someone else'));
     $l3->write();
     $l3->addBuyable($p3);
     $this->assertEquals(2, WishList::get_for_user()->count());
     $this->assertEquals(1, WishList::get_for_user($m2)->count());
     $this->assertFalse($p3->IsInWishList());
     $this->assertFalse($l1->hasBuyable($p3));
     $this->assertFalse($l2->hasBuyable($p3));
     // Buyable should be able to exist in two lists at once
     $l2->addBuyable($p1);
     $this->assertTrue($p1->IsInWishList());
     $this->assertTrue($l1->hasBuyable($p1));
     $this->assertTrue($l2->hasBuyable($p1));
     // removing an item from one list should not remove it from the other
     $l1->removeBuyable($p1);
     $this->assertTrue($p1->IsInWishList());
     $this->assertFalse($l1->hasBuyable($p1));
     $this->assertTrue($l2->hasBuyable($p1));
     // after removing item from both lists it should report as not being in a list
     $l2->removeBuyable($p1);
     $this->assertFalse($p1->IsInWishList());
     $this->assertFalse($l1->hasBuyable($p1));
     $this->assertFalse($l2->hasBuyable($p1));
 }
开发者ID:markguinn,项目名称:silverstripe-wishlist,代码行数:66,代码来源:WishListTest.php

示例5: CurrentList

 /**
  * @return WishList
  */
 public function CurrentList()
 {
     if (!isset($this->wishList)) {
         $this->wishList = WishList::current();
     }
     return $this->wishList;
 }
开发者ID:markguinn,项目名称:silverstripe-wishlist,代码行数:10,代码来源:WishListPage.php


注:本文中的WishList::current方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。