|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2023 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Shop\Command; |
|
10
|
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
12
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Command for initializing or updating the Aimeos database tables |
|
17
|
|
|
*/ |
|
18
|
|
|
class SetupCommand extends AbstractCommand |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* The name and signature of the console command. |
|
22
|
|
|
* |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $signature = 'aimeos:setup |
|
26
|
|
|
{site? : Site for updating database entries} |
|
27
|
|
|
{tplsite=default : Site used as template for creating the new one} |
|
28
|
|
|
{--q : Quiet} |
|
29
|
|
|
{--v=v : Verbosity level} |
|
30
|
|
|
{--option= : Setup configuration, name and value are separated by colon like "setup/default/demo:1"} |
|
31
|
|
|
'; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* The console command description. |
|
35
|
|
|
* |
|
36
|
|
|
* @var string |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $description = 'Initialize or update the Aimeos database tables'; |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Execute the console command. |
|
43
|
|
|
* |
|
44
|
|
|
* @return mixed |
|
45
|
|
|
*/ |
|
46
|
|
|
public function handle() |
|
47
|
|
|
{ |
|
48
|
|
|
\Aimeos\MShop::cache( false ); |
|
49
|
|
|
\Aimeos\MAdmin::cache( false ); |
|
50
|
|
|
|
|
51
|
|
|
$template = $this->argument( 'tplsite' ); |
|
52
|
|
|
|
|
53
|
|
|
if( ( $site = $this->argument( 'site' ) ) === null ) { |
|
54
|
|
|
$site = config( 'shop.mshop.locale.site', 'default' ); |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
$boostrap = $this->getLaravel()->make( 'aimeos' )->get(); |
|
58
|
|
|
$ctx = $this->getLaravel()->make( 'aimeos.context' )->get( false, 'command' ); |
|
59
|
|
|
|
|
60
|
|
|
$this->info( sprintf( 'Initializing or updating the Aimeos database tables for site "%1$s"', $site ) ); |
|
61
|
|
|
|
|
62
|
|
|
\Aimeos\Setup::use( $boostrap ) |
|
63
|
|
|
->verbose( $this->option( 'q' ) ? '' : $this->option( 'v' ) ) |
|
64
|
|
|
->context( $this->addConfig( $ctx->setEditor( 'aimeos:setup' ) ) ) |
|
65
|
|
|
->up( $site, $template ); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|