forked from thelia-modules/OpenSearchServerSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
OpensearchserverConfigQuery.php
52 lines (43 loc) · 1.45 KB
/
OpensearchserverConfigQuery.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
<?php
namespace OpenSearchServerSearch\Model;
use OpenSearchServerSearch\Model\Base\OpensearchserverConfigQuery as BaseOpensearchserverConfigQuery;
/**
* Skeleton subclass for performing query and update operations on the 'opensearchserver_config' table.
*
*
*
* You should add additional methods to this class to meet the
* application requirements. This class will only be generated as
* long as it does not already exist in the output directory.
*
*/
class OpensearchserverConfigQuery extends BaseOpensearchserverConfigQuery
{
/**
* Return a configuration variable value, or a default value if the variable was not found
*
* @param string $name the configuration variable name
* @param string $default the default value
* @return string the value
*/
public static function read($name, $default = null)
{
$value = self::create()->findOneByName($name);
return $value ? $value->getValue() : $default;
}
/**
* Set or update a configuration variable value.
*
* @param string $name the configuration variable name
* @param string $value the configuration value
*/
public static function set($name, $value)
{
$config = self::create()->findOneByName($name);
if (null == $config) {
$config = new OpenSearchServerConfig();
$config->setName($name);
}
$config->setValue($value)->save();
}
} // OpensearchserverConfigQuery