forked from jackalope/jackalope-doctrine-dbal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli-config.php.dist
56 lines (47 loc) · 1.88 KB
/
cli-config.php.dist
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/* bootstrapping the repository implementation */
/*
* configuration
*/
$workspace = 'default'; // phpcr workspace to use
$user = 'admin'; // RDBMS user
$pass = 'admin'; // RDBMS password
/** for jackalope - doctrine dbal, do this: */
function bootstrapDoctrineDbal()
{
global $repository, $user, $pass, $dbConn;
/* additional doctrine dbal configuration
* For further details, please see Doctrine configuration page.
* http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connection-details
*/
$driver = 'pdo_mysql';
$host = 'localhost';
$database = 'jackalope';
// Bootstrap Doctrine
$dbConn = \Doctrine\DBAL\DriverManager::getConnection(array(
'driver' => $driver,
'host' => $host,
'user' => $user,
'password' => $pass,
'dbname' => $database,
));
$repository = \Jackalope\RepositoryFactoryDoctrineDBAL::getRepository(array('jackalope.doctrine_dbal_connection' => $dbConn));
}
bootstrapDoctrineDbal();
$credentials = new \PHPCR\SimpleCredentials($user, $pass);
/* only create a session if this is not about the server control command */
if (isset($argv[1])
&& $argv[1] != 'jackalope:init:dbal'
&& $argv[1] != 'list'
&& $argv[1] != 'help'
) {
$session = $repository->login($credentials, $workspace);
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'session' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session)
));
} else if (isset($argv[1]) && $argv[1] == 'jackalope:init:dbal') {
// special case: the init command needs the db connection, but a session is impossible if the db is not yet initialized
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
'connection' => new \Jackalope\Tools\Console\Helper\DoctrineDbalHelper($dbConn)
));
}