PluginProbe
Packeta / 1.5.1
Packeta v1.5.1
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / ContextResolver.php

ContextResolver.php in Packeta 1.5.1, at src/Packetery/Module/ContextResolver.php

122 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class ContextResolver.
4 *
5 * @package Packetery\Module
6 */
7
8 declare( strict_types=1 );
9
10
11 namespace Packetery\Module;
12
13 use PacketeryNette\Http\Request;
14
15 /**
16 * Class ContextResolver.
17 *
18 * @package Packetery\Module
19 */
20 class ContextResolver {
21
22 /**
23 * Request.
24 *
25 * @var Request
26 */
27 private $request;
28
29 /**
30 * ContextResolver constructor.
31 *
32 * @param Request $request Packetery request.
33 */
34 public function __construct( Request $request ) {
35 $this->request = $request;
36 }
37
38 /**
39 * Tells if requesting user is at order grid page.
40 *
41 * @return bool
42 */
43 public function isOrderGridPage(): bool {
44 global $pagenow, $typenow;
45
46 return 'edit.php' === $pagenow && 'shop_order' === $typenow;
47 }
48
49 /**
50 * Tells if requesting user is at order detail page.
51 *
52 * @return bool
53 */
54 public function isOrderDetailPage(): bool {
55 global $pagenow, $typenow;
56
57 return 'post.php' === $pagenow && 'shop_order' === $typenow;
58 }
59
60 /**
61 * Tells if requesting user is at product detail page.
62 *
63 * @return bool
64 */
65 private function isProductDetailPage(): bool {
66 global $pagenow, $typenow;
67
68 return 'post.php' === $pagenow && 'product' === $typenow;
69 }
70
71 /**
72 * Tells if requesting user is at product create page.
73 *
74 * @return bool
75 */
76 private function isProductCreatePage(): bool {
77 global $pagenow, $typenow;
78
79 return 'post-new.php' === $pagenow && 'product' === $typenow;
80 }
81
82 /**
83 * Tells if requesting user is at product page.
84 *
85 * @return bool
86 */
87 public function isProductPage(): bool {
88 return $this->isProductCreatePage() || $this->isProductDetailPage();
89 }
90
91 /**
92 * Tells if requesting user is at page using packetery confirm.
93 *
94 * @return bool
95 */
96 public function isPacketeryConfirmPage(): bool {
97 return $this->isOrderDetailPage() || $this->isOrderGridPage();
98 }
99
100 /**
101 * Tells if requesting user is at product category grid page.
102 *
103 * @return bool
104 */
105 public function isProductCategoryGridPage(): bool {
106 global $pagenow;
107
108 return 'edit-tags.php' === $pagenow && ProductCategory\Entity::TAXONOMY_NAME === $this->request->getQuery( 'taxonomy' );
109 }
110
111 /**
112 * Tells if requesting user is at product category grid page.
113 *
114 * @return bool
115 */
116 public function isProductCategoryDetailPage(): bool {
117 global $pagenow;
118
119 return 'term.php' === $pagenow && ProductCategory\Entity::TAXONOMY_NAME === $this->request->getQuery( 'taxonomy' );
120 }
121 }
122