release_2_1_0_data::update_data()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 16
nc 1
nop 0
dl 0
loc 32
rs 9.7333
c 2
b 0
f 0
1
<?php
2
/**
3
 *
4
 * Topic Preview
5
 *
6
 * @copyright (c) 2013 Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\topicpreview\migrations\v2xx;
12
13
class release_2_1_0_data extends \phpbb\db\migration\container_aware_migration
0 ignored issues
show
Bug introduced by
The type phpbb\db\migration\container_aware_migration was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
{
15
	public function effectively_installed()
16
	{
17
		return isset($this->config['topic_preview_delay']);
18
	}
19
20
	public static function depends_on()
21
	{
22
		return array('\vse\topicpreview\migrations\v2xx\release_2_1_0_schema');
23
	}
24
25
	public function update_data()
26
	{
27
		// use module tool explicitly since module.exists does not work in 'if'
28
		$module_tool = $this->container->get('migrator.tool.module');
29
30
		return array(
31
			// Remove old ACP module if it exists
32
			array('if', array(
33
				$module_tool->exists('acp', 'TOPIC_PREVIEW', 'TOPIC_PREVIEW_SETTINGS', true),
34
				array('module.remove', array('acp', 'TOPIC_PREVIEW', 'TOPIC_PREVIEW_SETTINGS')),
35
			)),
36
37
			// Add new ACP module
38
			array('module.add', array('acp', 'TOPIC_PREVIEW', array(
39
				'module_basename'	=> '\vse\topicpreview\acp\topic_preview_module',
40
				'modes'				=> array('settings'),
41
			))),
42
43
			// Remove old config if it exists
44
			array('if', array(
45
				isset($this->config['topic_preview_jquery']),
46
				array('config.remove', array('topic_preview_jquery')),
47
			)),
48
49
			// Add new configs
50
			array('config.add', array('topic_preview_delay', '1000')),
51
			array('config.add', array('topic_preview_drift', '15')),
52
			array('config.add', array('topic_preview_width', '360')),
53
54
			// Update existing configs
55
			array('config.update', array('topic_preview_avatars', '1')),
56
			array('config.update', array('topic_preview_version', '2.1.0')),
57
		);
58
	}
59
}
60