-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathLeuchtfeuerGoToBundle.php
74 lines (63 loc) · 2.17 KB
/
LeuchtfeuerGoToBundle.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
/*
* @copyright 2016 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
namespace MauticPlugin\LeuchtfeuerGoToBundle;
use Doctrine\DBAL\Exception\TableExistsException;
use Exception;
use Mautic\CoreBundle\Factory\MauticFactory;
use Mautic\PluginBundle\Bundle\PluginBundleBase;
use Mautic\PluginBundle\Entity\Plugin;
use MauticPlugin\LeuchtfeuerGoToBundle\Helper\GoToHelper;
use Psr\Log\LogLevel;
/**
* Class LeuchtfeuerGoToBundle.
*/
class LeuchtfeuerGoToBundle extends PluginBundleBase
{
/**
* Called by PluginController::reloadAction when adding a new plugin that's not already installed.
*
* @param null $metadata
* @param null $installedSchema
*
* @throws \Doctrine\DBAL\ConnectionException
* @throws Exception
*/
public static function onPluginInstall(Plugin $plugin, MauticFactory $factory, $metadata = null, $installedSchema = null)
{
$db = $factory->getDatabase();
$queries = [];
$queries[] = 'DELETE FROM '.MAUTIC_TABLE_PREFIX.'plugins WHERE bundle = "MauticCitrixBundle"';
$queries[] = 'DELETE FROM '.MAUTIC_TABLE_PREFIX.'plugin_integration_settings WHERE name LIKE "goto%"';
if (!empty($queries)) {
$db->beginTransaction();
try {
foreach ($queries as $q) {
$db->query($q);
}
$db->commit();
} catch (Exception $exception) {
$db->rollback();
GoToHelper::log($exception->getMessage(), LogLevel::NOTICE);
}
}
if (null !== $metadata) {
try {
self::installPluginSchema($metadata, $factory);
} catch (TableExistsException $tableExistsException) {
GoToHelper::log($tableExistsException->getMessage(), LogLevel::NOTICE);
}
}
}
public function boot()
{
parent::boot();
GoToHelper::init($this->container->get('mautic.helper.integration'), $this->container->get('monolog.logger.mautic'));
}
}