-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.power
More file actions
116 lines (103 loc) · 2.41 KB
/
code.power
File metadata and controls
116 lines (103 loc) · 2.41 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
* Selected search engine
*
* @var int
* @since 3.2.0
**/
protected $searchEngine = 101;
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.0
*/
public function register(Container $container)
{
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Regex::class, 'Search.Regex')
->share('Search.Regex', [$this, 'getRegex'], true);
$container->alias(Basic::class, 'Search.Basic')
->share('Search.Basic', [$this, 'getBasic'], true);
$container->alias(SearchEngine::class, 'Search')
->share('Search', [$this, 'getSearch'], true);
}
/**
* Get the Config
*
* @param Container $container The DI container.
*
* @return Config
* @since 3.2.0
*/
public function getConfig(Container $container): Config
{
return new Config();
}
/**
* Get the Table
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.0
*/
public function getTable(Container $container): Table
{
return new Table();
}
/**
* Get the Regex Type Search Engine
*
* @param Container $container The DI container.
*
* @return Regex
* @since 3.2.0
*/
public function getRegex(Container $container): Regex
{
return new Regex(
$container->get('Config')
);
}
/**
* Get the Basic Type Search Engine
*
* @param Container $container The DI container.
*
* @return Basic
* @since 3.2.0
*/
public function getBasic(Container $container): Basic
{
return new Basic(
$container->get('Config')
);
}
/**
* Get the Search Engine
*
* @param Container $container The DI container.
*
* @return SearchEngine
* @since 3.2.0
*/
public function getSearch(Container $container): SearchEngine
{
// set the search engine to use for this container
if ($this->searchEngine == 101)
{
$this->searchEngine = (int) $container->get('Config')->regex_search;
}
// get the correct type of search engine
if ($this->searchEngine == 1)
{
return $container->get('Search.Regex');
}
// the default is the basic
return $container->get('Search.Basic');
}