mirror of
https://github.com/doctrine/phpcr-odm.git
synced 2026-03-23 22:32:11 +01:00
56 lines
2.0 KiB
Plaintext
56 lines
2.0 KiB
Plaintext
<?php
|
|
/**
|
|
* The config file is responsible to make class loading work and initialize a
|
|
* DocumentManagerHelper that contains the doctrine document manager with a
|
|
* Session of your phpcr implementation.
|
|
* The array $extraCommands can be used to inject implementation specific commands.
|
|
* Add instances of commands for eventual implementation specific commands to this array.
|
|
*/
|
|
|
|
$extraCommands = [];
|
|
$extraCommands[] = new \Jackalope\Tools\Console\Command\JackrabbitCommand();
|
|
|
|
if (! isset($argv[1])
|
|
|| $argv[1] == 'jackalope:run:jackrabbit'
|
|
|| $argv[1] == 'list'
|
|
|| $argv[1] == 'help'
|
|
) {
|
|
//abort here, do not try to init repository
|
|
return;
|
|
}
|
|
|
|
$params = [
|
|
'jackalope.jackrabbit_uri' => 'http://127.0.0.1:8080/server/',
|
|
];
|
|
|
|
$workspace = 'default';
|
|
$user = 'admin';
|
|
$pass = 'admin';
|
|
|
|
/* bootstrapping the repository implementation. for jackalope, do this: */
|
|
$factory = new \Jackalope\RepositoryFactoryJackrabbit();
|
|
$repository = $factory->getRepository($params);
|
|
$credentials = new \PHPCR\SimpleCredentials($user, $pass);
|
|
$session = $repository->login($credentials, $workspace);
|
|
|
|
/* prepare the doctrine configuration */
|
|
$config = new \Doctrine\ODM\PHPCR\Configuration();
|
|
$driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AttributeDriver([
|
|
__DIR__ . '/lib/Doctrine/ODM/PHPCR/Document'
|
|
]);
|
|
$config->setMetadataDriverImpl($driver);
|
|
|
|
$dm = \Doctrine\ODM\PHPCR\DocumentManager::create($session, $config);
|
|
|
|
$helperSet = new \Symfony\Component\Console\Helper\HelperSet([
|
|
'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session),
|
|
'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(),
|
|
'dm' => new \Doctrine\ODM\PHPCR\Tools\Console\Helper\DocumentManagerHelper(null, $dm),
|
|
]);
|
|
|
|
if (class_exists('Symfony\Component\Console\Helper\QuestionHelper')) {
|
|
$helperSet->set(new \Symfony\Component\Console\Helper\QuestionHelper(), 'question');
|
|
} else {
|
|
$helperSet->set(new \Symfony\Component\Console\Helper\DialogHelper, 'dialog');
|
|
}
|