PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.7
Filter Everything — WordPress & WooCommerce Filters v1.9.7
1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2.2 1.9.2.1 trunk 1.2.1 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.1 1.4.4 1.4.5 1.4.8 1.4.9 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 All 52 releases
filter-everything / src / Settings / Container.php

Container.php in Filter Everything — WordPress & WooCommerce Filters 1.9.7, at src/Settings/Container.php

204 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FilterEverything\Filter;
4
5 if ( ! defined('ABSPATH') ) {
6 exit;
7 }
8
9 use FilterEverything\Filter\Pro\SeoFrontend;
10
11 class Container
12 {
13 private static $instance;
14
15 private $services = [];
16
17 private $params = [];
18
19 private function __construct()
20 {
21 }
22
23 public function __clone()
24 {
25 }
26
27 public function __wakeup()
28 {
29 throw new Exception("Cannot unserialize singleton");
30 }
31
32 public static function instance()
33 {
34 if (!isset(self::$instance)) {
35 self::$instance = new self();
36 }
37 return self::$instance;
38 }
39
40 public function storeParam($key, $value)
41 {
42 if (!isset($this->params[$key])) {
43 $this->params[$key] = $value;
44 }
45 }
46
47 public function getParam($key)
48 {
49 if (isset($this->params[$key])) {
50 return $this->params[$key];
51 }
52 return false;
53 }
54
55 public function getService($key)
56 {
57 if (isset($this->services[$key])) {
58 return $this->services[$key];
59 }
60 }
61
62 public function addService($key, $service)
63 {
64 $this->services[$key] = $service;
65 }
66
67 public function getEntityManager()
68 {
69 if (!isset($this->services['entitymanager'])) {
70 $this->addService('entitymanager', new EntityManager());
71 }
72
73 return $this->getService('entitymanager');
74 }
75
76 public function getFilterService()
77 {
78 if (!isset($this->services['filterservice'])) {
79 $this->addService('filterservice', new Filter() );
80 }
81
82 return $this->getService('filterservice');
83 }
84
85 public function getUrlManager()
86 {
87 if ( ! isset( $this->services['urlmanager'] ) ) {
88 $this->addService('urlmanager', new UrlManager() );
89 }
90 return $this->getService('urlmanager');
91 }
92
93 public function getTemplateManager()
94 {
95 if (!isset($this->services['templatemanager'])) {
96 $this->addService('templatemanager', new TemplateManager(FLRT_PLUGIN_DIR_PATH));
97 }
98
99 return $this->getService('templatemanager');
100 }
101
102 public function getFilterSetService()
103 {
104 if (!isset($this->services['filterset'])) {
105 $this->addService('filterset', new FilterSet());
106 }
107
108 return $this->getService('filterset');
109 }
110
111 public function getFilterFieldsService()
112 {
113 if (!isset($this->services['filterfields'])) {
114 $this->addService('filterfields', new FilterFields());
115 }
116
117 return $this->getService('filterfields');
118 }
119
120 public function getWpManager()
121 {
122 if (!isset($this->services['wpmanager'])) {
123 $this->addService('wpmanager', new WpManager());
124 }
125
126 return $this->getService('wpmanager');
127 }
128
129 public function getSeoFrontendService()
130 {
131 if( class_exists('FilterEverything\Filter\Pro\SeoFrontend') ) {
132 if (!isset($this->services['seofrontend'])) {
133 $this->addService('seofrontend', new SeoFrontend());
134 }
135
136 return $this->getService('seofrontend');
137 }
138
139 return new \stdClass();
140 }
141
142 public function getTabRenderer()
143 {
144 if (!isset($this->services['tabrenderer'])) {
145 $this->addService('tabrenderer', new TabRenderer());
146 }
147
148 return $this->getService('tabrenderer');
149 }
150
151 /**
152 * Per-request filter state (parsed request, relevant sets, JSON payload).
153 * @since 1.9.7
154 * @return FilterContext
155 */
156 public function getFilterContext()
157 {
158 if ( ! isset( $this->services['filtercontext'] ) ) {
159 $this->addService( 'filtercontext', new FilterContext() );
160 }
161
162 return $this->getService( 'filtercontext' );
163 }
164
165 public function getSwatches()
166 {
167 if ( !isset( $this->services['swatches'] ) ) {
168 $this->addService('swatches', new Swatches() );
169 }
170
171 return $this->getService('swatches' );
172 }
173
174 /**
175 * Sanitizes $_GET variables and stores them in the Container
176 * @return false|mixed
177 */
178 public function getTheGet()
179 {
180 if ( ! $this->getParam('get') ) {
181 $clean_get = [];
182
183 if ( is_array( $_GET ) ) {
184 foreach ( $_GET as $param => $value ) {
185 $clean_get[ $param ] = flrt_string_polyfill( $value );
186 }
187 }
188
189 $this->storeParam( 'get', $clean_get );
190 }
191
192 return $this->getParam('get');
193 }
194
195 public function getThePost()
196 {
197 if( ! $this->getParam('post') ){
198 $this->storeParam( 'post', $_POST );
199 }
200
201 return $this->getParam('post');
202 }
203
204 }