Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (61 sloc) 2.27 KB
<?php
/* bootstrapping the repository implementation */
/*
* configuration
*/
$workspace = 'default'; // phpcr workspace to use
$user = 'admin'; // jackrabbit or sql user
$pass = 'admin'; // jackrabbit or sql password
/** for jackalope - jackrabbit, do this: */
function bootstrapJackrabbit()
{
global $repository, $user, $pass;
/* additional jackrabbit configuration */
$jackrabbit_url = 'http://127.0.0.1:8080/server/';
// bootstrap jackrabbit
$repository = \Jackalope\RepositoryFactoryJackrabbit::getRepository(array("jackalope.jackrabbit_uri" => $jackrabbit_url));
}
/** for jackalope - doctrine dbal, do this: */
function bootstrapDoctrineDbal()
{
global $repository, $user, $pass, $dbConn;
/* additional doctrine dbal configuration */
$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));
}
/*
* enable jackrabbit backend
*/
bootstrapJackrabbit();
/*
* or comment out jackrabbit and uncomment this instead to enable doctrine backend
*/
//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:run:jackrabbit'
&& $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)
));
}