4
4
5
5
namespace MauticPlugin \CustomObjectsBundle \Provider ;
6
6
7
- use Doctrine \DBAL \Connection ;
8
- use Doctrine \DBAL \Exception ;
9
7
use Mautic \CoreBundle \Helper \CoreParametersHelper ;
10
- use MauticPlugin \CustomObjectsBundle \Entity \CustomObject ;
11
8
12
9
class ConfigProvider
13
10
{
14
11
/**
15
12
* @var string
16
13
*/
17
- public const CONFIG_PLUGIN_NAME = 'CustomObjectsBundle ' ;
18
14
public const CONFIG_PARAM_ENABLED = 'custom_objects_enabled ' ;
19
15
public const CONFIG_PARAM_ITEM_VALUE_TO_CONTACT_RELATION_LIMIT = 'custom_object_item_value_to_contact_relation_limit ' ;
20
16
@@ -25,38 +21,17 @@ class ConfigProvider
25
21
*/
26
22
private $ coreParametersHelper ;
27
23
28
- /**
29
- * @var Connection
30
- */
31
- private $ connection ;
32
-
33
- public function __construct (CoreParametersHelper $ coreParametersHelper , Connection $ connection )
24
+ public function __construct (CoreParametersHelper $ coreParametersHelper )
34
25
{
35
26
$ this ->coreParametersHelper = $ coreParametersHelper ;
36
- $ this ->connection = $ connection ;
37
27
}
38
28
39
29
/**
40
30
* Returns true if the Custom Objects plugin is enabled.
41
31
*/
42
32
public function pluginIsEnabled (): bool
43
33
{
44
- $ pluginEnabled = (bool ) $ this ->coreParametersHelper ->get (self ::CONFIG_PARAM_ENABLED , true );
45
- if (!$ pluginEnabled ) {
46
- return false ;
47
- }
48
-
49
- try {
50
- $ pluginWasInstalledBefore = $ this ->connection
51
- ->executeQuery ('SELECT id FROM plugins WHERE bundle=:pluginName ' , ['pluginName ' => self ::CONFIG_PLUGIN_NAME ])
52
- ->rowCount ();
53
- $ customObjectsTableExists = $ this ->connection
54
- ->executeQuery ('SHOW TABLES LIKE :tableName ' , ['tableName ' => CustomObject::TABLE_NAME ])
55
- ->rowCount ();
56
- return $ pluginWasInstalledBefore && $ customObjectsTableExists ;
57
- } catch (Exception $ e ) {
58
- return false ;
59
- }
34
+ return (bool ) $ this ->coreParametersHelper ->get (self ::CONFIG_PARAM_ENABLED , true );
60
35
}
61
36
62
37
public function isCustomObjectMergeFilterEnabled (): bool
0 commit comments