Passed
Push — master ( 9993cc...adf1aa )
by Aimeos
05:54 queued 41s
created

LocaleCreateSite::before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2024
6
 */
7
8
9
namespace Aimeos\Upscheme\Task;
10
11
12
/**
13
 * Adds locale records to tables.
14
 */
15
class LocaleCreateSite extends MShopAddLocaleData
16
{
17
	/**
18
	 * Returns the list of task names which this task depends on.
19
	 *
20
	 * @return string[] List of task names
21
	 */
22
	public function after() : array
23
	{
24
		return ['MShopAddLocaleLangCurData'];
25
	}
26
27
28
	/**
29
	 * Returns the list of task names which depends on this task.
30
	 *
31
	 * @return string[] List of task names
32
	 */
33
	public function before() : array
34
	{
35
		return ['MShopAddLocaleDataDefault'];
36
	}
37
38
39
	/**
40
	 * Adds locale data.
41
	 */
42
	public function up()
43
	{
44
		$this->info( 'Create site and locale', 'vv' );
45
46
		$context = $this->context()->setEditor( 'core' ); // Set editor for further tasks
0 ignored issues
show
Bug introduced by
The method context() does not exist on Aimeos\Upscheme\Task\LocaleCreateSite. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

46
		$context = $this->/** @scrutinizer ignore-call */ context()->setEditor( 'core' ); // Set editor for further tasks
Loading history...
47
		$localeManager = \Aimeos\MShop::create( $context, 'locale', 'Standard' );
48
49
		$config = $context->config();
50
		$site = $config->get( 'setup/site', 'default' );
51
		$lang = $config->get( 'setup/language', 'en' );
52
		$curr = $config->get( 'setup/currency', 'USD' );
53
54
		$siteIds = $this->addLocaleSiteData( $localeManager, [
55
			$site => ['locale.site.code' => $site, 'locale.site.label' => ucfirst( $site )]
56
		] );
57
58
		$this->addLocaleData( $localeManager, [
59
			['site' => $site, 'locale.languageid' => $lang, 'locale.currencyid' => $curr]
60
		], $siteIds );
61
	}
62
}
63