Passed
Push — 1.6.0 ( 412404...2a5487 )
by Sylver
03:48
created

smiliescat_1_6_1::update_data()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
/**
3
*
4
* @package		Breizh Smilies Categories Extension
5
* @copyright	(c) 2020-2024 Sylver35  https://breizhcode.com
6
* @license		https://opensource.org/licenses/gpl-license.php GNU Public License
7
*
8
*/
9
10
namespace sylver35\smiliescat\migrations;
11
12
use phpbb\db\migration\migration;
13
14
class smiliescat_1_6_1 extends migration
15
{
16
	public function effectively_installed()
17
	{
18
		return isset($this->config['smilies_first_cat']);
19
	}
20
21
	static public function depends_on()
22
	{
23
		return ['\sylver35\smiliescat\migrations\smiliescat_1_6_0'];
24
	}
25
26
	public function update_data()
27
	{
28
		return [
29
			// Config
30
			['config.add', ['smilies_first_cat', $this->get_first_order()]],
31
		];
32
	}
33
34
	public function get_first_order()
35
	{
36
		// Get first order id...
37
		$sql = 'SELECT cat_order, cat_id
38
			FROM ' . $this->table_prefix . 'smilies_category
39
			ORDER BY cat_order ASC';
40
		$result = $this->db->sql_query_limit($sql, 1);
41
		$first = (int) $this->db->sql_fetchfield('cat_id');
42
		$this->db->sql_freeresult($result);
43
44
		return $first;
45
	}
46
}
47