This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli-config.php
60 lines (48 loc) · 2.32 KB
/
cli-config.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
/*
* This file is part of gpupo/content-butler
* Created by Gilmar Pupo <[email protected]>
* For the information of copyright and license you should read the file
* LICENSE which is distributed with this source code.
* Para a informação dos direitos autorais e de licença você deve ler o arquivo
* LICENSE que é distribuído com este código-fonte.
* Para obtener la información de los derechos de autor y la licencia debe leer
* el archivo LICENSE que se distribuye con el código fuente.
* For more information, see <https://opensource.gpupo.com/>.
*
*/
namespace Gpupo\ContentButler\Console;
require getcwd().\DIRECTORY_SEPARATOR.'/config/bootstrap.php';
$extraCommands = [];
$server = sprintf('http://%s:%d/server/', getenv('JACKRABBIT_SERVER'), getenv('JACKRABBIT_PORT'));
$params = [
'jackalope.jackrabbit_uri' => $server,
];
$jackrabbit_workspace = getenv('JACKRABBIT_WORKSPACE');
$jackrabbit_username = getenv('JACKRABBIT_USERNAME');
$jackrabbit_password = getenv('JACKRABBIT_PASSWORD');
// bootstrapping the repository implementation. for jackalope, do this:
$factory = new \Jackalope\RepositoryFactoryJackrabbit();
$repository = $factory->getRepository($params);
$credentials = new \PHPCR\SimpleCredentials($jackrabbit_username, $jackrabbit_password);
$session = $repository->login($credentials, $jackrabbit_workspace);
// prepare the doctrine configuration
$config = new \Doctrine\ODM\PHPCR\Configuration();
$driver = new \Doctrine\ODM\PHPCR\Mapping\Driver\AnnotationDriver(
new \Doctrine\Common\Annotations\AnnotationReader(),
'src/Document/',
'vendor/doctrine/phpcr-odm/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');
}