public login ( PHPCR\CredentialsInterface $credentials = null, $workspaceName = null ) | ||
$credentials | PHPCR\CredentialsInterface |
public function login(CredentialsInterface $credentials = null, $workspaceName = null)
{
if (!($workspaceName = $this->transport->login($credentials, $workspaceName))) {
throw new RepositoryException('transport failed to login without telling why');
}
/** @var $session Session */
$session = $this->factory->get('Session', array($this, $workspaceName, $credentials, $this->transport));
$session->setSessionOption(Session::OPTION_AUTO_LASTMODIFIED, $this->options[Session::OPTION_AUTO_LASTMODIFIED]);
if ($this->options['transactions']) {
$utx = $this->factory->get('Transaction\\UserTransaction', array($this->transport, $session, $session->getObjectManager()));
$session->getWorkspace()->setTransactionManager($utx);
}
return $session;
}
public function setUp() { parent::setUp(); $conn = $this->getConnection(); $options = array('disable_fks' => $conn->getDatabasePlatform() instanceof SqlitePlatform); $schema = new RepositorySchema($options, $conn); // do not use reset as we want to ignore exceptions on drop foreach ($schema->toDropSql($conn->getDatabasePlatform()) as $statement) { try { $conn->exec($statement); } catch (\Exception $e) { // ignore } } foreach ($schema->toSql($conn->getDatabasePlatform()) as $statement) { $conn->exec($statement); } $this->transport = new \Jackalope\Transport\DoctrineDBAL\Client(new \Jackalope\Factory(), $conn); $this->transport->createWorkspace('default'); $this->repository = new \Jackalope\Repository(null, $this->transport); try { $this->transport->createWorkspace($GLOBALS['phpcr.workspace']); } catch (\PHPCR\RepositoryException $e) { if ($e->getMessage() != "Workspace '" . $GLOBALS['phpcr.workspace'] . "' already exists") { // if the message is not that the workspace already exists, something went really wrong throw $e; } } $this->session = $this->repository->login(new \PHPCR\SimpleCredentials("user", "passwd"), $GLOBALS['phpcr.workspace']); }