-
Notifications
You must be signed in to change notification settings - Fork 660
/
Copy pathStatusVisibility.php
62 lines (51 loc) · 1.61 KB
/
StatusVisibility.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
* This file is part of EC-CUBE
*
* Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
*
* http://www.ec-cube.co.jp/
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Eccube\Service\Product;
use Eccube\Doctrine\Query\WhereClause;
use Eccube\Entity\Master\ProductStatus;
use Eccube\Entity\Product;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
class StatusVisibility extends ProductVisibility
{
/**
* @var SessionInterface
*/
private $session;
public function __construct(SessionInterface $session)
{
$this->session = $session;
}
public function checkVisibility(Product $Product)
{
$is_admin = $this->session->has('_security_admin');
// 管理ユーザの場合はステータスやオプションにかかわらず閲覧可能.
if (!$is_admin) {
// 在庫なし商品の非表示オプションが有効な場合.
// if ($this->BaseInfo->isOptionNostockHidden()) {
// if (!$Product->getStockFind()) {
// return false;
// }
// }
// 公開ステータスでない商品は表示しない.
if ($Product->getStatus()->getId() !== ProductStatus::DISPLAY_SHOW) {
return false;
}
}
return true;
}
protected function createStatements($params, $queryKey)
{
return [
WhereClause::eq('p.Status', ':ProductStatus', ProductStatus::DISPLAY_SHOW)
];
}
}