<?php

/**
 * This is a sample bootstrap file for the console. All jackalope variants
 * provide their own bootstrap file. This file is only relevant for people
 * implementing PHPCR and using the phpcr-utils.
 */

$path_to_jackalope = __DIR__.'/../jackalope';

// $autoload was created in the autoload that is included before this.
$autoload->add('Jackalope', "$path_to_jackalope/src");

/* credentials you plan to use */
$jackrabbit_url = 'http://127.0.0.1:8080/server/';
$workspace = 'default';
$user = 'admin';
$pass = 'admin';

if (isset($argv[1])
    && $argv[1] != 'list'
    && $argv[1] != 'help'
) {
    /* bootstrapping the repository implementation. for jackalope with jackrabbit, do this: */
    $factory = new \Jackalope\RepositoryFactoryJackrabbit;
    $repository = $factory->getRepository(array("jackalope.jackrabbit_uri" => $jackrabbit_url));
    $credentials = new \PHPCR\SimpleCredentials($user, $pass);
    $session = $repository->login($credentials, $workspace);

    $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
        'phpcr' => new \PHPCR\Util\Console\Helper\PhpcrHelper($session),
        'phpcr_console_dumper' => new \PHPCR\Util\Console\Helper\PhpcrConsoleDumperHelper(),
    ));

    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');
    }
}
