1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2016 |
6
|
|
|
* @package laravel |
7
|
|
|
* @subpackage Command |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Shop\Command; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Console\Input\InputOption; |
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
15
|
|
|
|
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Command for initializing or updating the Aimeos database tables |
19
|
|
|
* @package laravel |
20
|
|
|
* @subpackage Command |
21
|
|
|
*/ |
22
|
|
|
class SetupCommand extends AbstractCommand |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* The name and signature of the console command. |
26
|
|
|
* |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $signature = 'aimeos:setup |
30
|
|
|
{site=default : Site for updating database entries} |
31
|
|
|
{tplsite=default : Site used as template for creating the new one} |
32
|
|
|
{--q : Quiet} |
33
|
|
|
{--v=vv : Verbosity level} |
34
|
|
|
{--option= : Setup configuration, name and value are separated by colon like "setup/default/demo:1"} |
35
|
|
|
'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* The console command description. |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $description = 'Initialize or update the Aimeos database tables'; |
43
|
|
|
|
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Execute the console command. |
47
|
|
|
* |
48
|
|
|
* @return mixed |
49
|
|
|
*/ |
50
|
|
|
public function handle() |
51
|
|
|
{ |
52
|
|
|
\Aimeos\MShop::cache( false ); |
53
|
|
|
\Aimeos\MAdmin::cache( false ); |
54
|
|
|
|
55
|
|
|
$site = $this->argument( 'site' ); |
56
|
|
|
$template = $this->argument( 'tplsite' ); |
57
|
|
|
|
58
|
|
|
$boostrap = $this->getLaravel()->make( 'aimeos' )->get(); |
59
|
|
|
$ctx = $this->getLaravel()->make( 'aimeos.context' )->get( false, 'command' )->setEditor( 'aimeos:setup' ); |
|
|
|
|
60
|
|
|
|
61
|
|
|
$this->info( sprintf( 'Initializing or updating the Aimeos database tables for site "%1$s"', $site ) ); |
|
|
|
|
62
|
|
|
|
63
|
|
|
\Aimeos\Setup::use( $boostrap, $this->getOptions() ) |
64
|
|
|
->verbose( $this->option( 'q' ) ? '' : $this->option( 'v' ) ) |
65
|
|
|
->up( $site, $template ); |
|
|
|
|
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Returns the configuration options from the input object |
71
|
|
|
* |
72
|
|
|
* @return array Associative list of key/value pairs of configuration options |
73
|
|
|
*/ |
74
|
|
|
protected function getOptions() : array |
75
|
|
|
{ |
76
|
|
|
$map = []; |
77
|
|
|
|
78
|
|
|
foreach( (array) $this->option( 'option' ) as $option ) |
79
|
|
|
{ |
80
|
|
|
list( $name, $value ) = explode( ':', $option ); |
81
|
|
|
$map[str_replace( '\\', '/', $name )] = $value; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
return $map; |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|