| Conditions | 6 |
| Paths | 7 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 31 | public function WishListForm($productID = 0) |
||
| 32 | { |
||
| 33 | if (!Security::getCurrentUser()) { |
||
| 34 | return false; |
||
| 35 | } |
||
| 36 | |||
| 37 | if (!$productID) { |
||
| 38 | $productID = $this->owner->ID; |
||
| 39 | } else if ($productID instanceof HTTPRequest) { |
||
| 40 | $productID = $productID->postVar('ProductID'); |
||
| 41 | } |
||
| 42 | |||
| 43 | /** @var ProductWishList $list */ |
||
| 44 | $list = ProductWishList::get()->filter([ |
||
| 45 | 'MemberID' => Security::getCurrentUser()->ID, |
||
| 46 | ])->first(); |
||
| 47 | |||
| 48 | if (!$list || !$list->Products()->byID($productID)) { |
||
| 49 | return AddToWishListForm::create($this->owner, __FUNCTION__, $productID); |
||
| 50 | } |
||
| 51 | |||
| 52 | return RemoveFromWishListForm::create($this->owner, __FUNCTION__, $productID); |
||
| 53 | } |
||
| 55 |