Completed
Push — master ( 8fad21...ed2a2d )
by David
01:43
created

WbmTagManager::update()   B

Complexity

Conditions 4
Paths 8

Size

Total Lines 22
Code Lines 11

Duplication

Lines 15
Ratio 68.18 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 15
loc 22
rs 8.9197
cc 4
eloc 11
nc 8
nop 1
1
<?php
2
/**
3
 * Tag Manager
4
 * Copyright (c) Webmatch GmbH
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 */
16
17
namespace WbmTagManager;
18
19
use Symfony\Component\DependencyInjection\ContainerBuilder;
20
use Shopware\Components\Plugin\Context\ActivateContext;
21
use Shopware\Components\Plugin\Context\InstallContext;
22
use Shopware\Components\Plugin\Context\UpdateContext;
23
24
/**
25
 * Class WbmTagManager
26
 * @package WbmTagManager
27
 */
28
class WbmTagManager extends \Shopware\Components\Plugin
29
{
30
    /**
31
     * @param ContainerBuilder $container
32
     */
33
    public function build(ContainerBuilder $container)
34
    {
35
        $container->setParameter('wbm_tag_manager.plugin_dir', $this->getPath());
36
37
        parent::build($container);
38
    }
39
40
    /**
41
     * @param InstallContext $context
42
     */
43
    public function install(InstallContext $context)
44
    {
45
        $sql = file_get_contents($this->getPath() . '/Resources/sql/install.sql');
46
47
        $this->container->get('shopware.db')->query($sql);
48
    }
49
50
    /**
51
     * @param ActivateContext $context
52
     */
53
    public function activate(ActivateContext $context)
54
    {
55
        $context->scheduleClearCache(InstallContext::CACHE_LIST_ALL);
56
    }
57
58
    /**
59
     * @param UpdateContext $context
60
     */
61
    public function update(UpdateContext $context)
62
    {
63 View Code Duplication
        if (version_compare($context->getCurrentVersion(), '2.0.0', '<')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
            $sql = file_get_contents($this->getPath() . '/Resources/sql/install.sql');
65
66
            $this->container->get('shopware.db')->query($sql);
67
        }
68
69 View Code Duplication
        if (version_compare($context->getCurrentVersion(), '2.0.3', '<')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
            $sql = file_get_contents($this->getPath() . '/Resources/sql/update.2.0.3.sql');
71
72
            $this->container->get('shopware.db')->query($sql);
73
        }
74
75 View Code Duplication
        if (version_compare($context->getCurrentVersion(), '2.0.4', '<')) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
            $sql = file_get_contents($this->getPath() . '/Resources/sql/update.2.0.4.sql');
77
78
            $this->container->get('shopware.db')->query($sql);
79
        }
80
81
        $context->scheduleClearCache(InstallContext::CACHE_LIST_ALL);
82
    }
83
}