-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDb.php
42 lines (35 loc) · 1001 Bytes
/
Db.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace Solire\Install;
use Composer\Script\Event;
use Solire\Install\Lib\DbServer;
/**
* Install the databases needed in the project.
*
* @author thansen <thansen@solire.fr>
* @license CC by-nc http://creativecommons.org/licenses/by-nc/3.0/fr/
*/
class Db
{
/**
* Install the project database.
*
* @param Event $event The composer event
*
* @return void
*/
public static function create(Event $event)
{
$io = $event->getIO();
$extras = $event->getComposer()->getPackage()->getExtra();
$parameters = $extras['solire']['parameters'];
$dataBases = $extras['solire']['db'];
foreach ($dataBases as $dataBase) {
$dbParam = $parameters[$dataBase['config']][$dataBase['section']];
$server = new DbServer($dbParam, $io);
$dbCreated = $server->connect();
if ($dbCreated) {
$server->import($dataBase['import']);
}
}
}
}