Skip to content

Instantly share code, notes, and snippets.

@chregu
Created May 31, 2011 19:45
Show Gist options
  • Save chregu/1001130 to your computer and use it in GitHub Desktop.
Save chregu/1001130 to your computer and use it in GitHub Desktop.
diff --git a/src/Jackalope/NamespaceRegistry.php b/src/Jackalope/NamespaceRegistry.php
index ce806d4..9aa6da7 100644
--- a/src/Jackalope/NamespaceRegistry.php
+++ b/src/Jackalope/NamespaceRegistry.php
@@ -34,7 +34,7 @@ class NamespaceRegistry implements \IteratorAggregate, \PHPCR\NamespaceRegistryI
* Set of namespaces registered by the user.
* @var array
*/
- protected $userNamespaces = array();
+ protected $userNamespaces = null;
/**
* Initializes the created object.
@@ -46,11 +46,18 @@ class NamespaceRegistry implements \IteratorAggregate, \PHPCR\NamespaceRegistryI
{
$this->factory = $factory;
$this->transport = $transport;
-
- $namespaces = $transport->getNamespaces();
- foreach ($namespaces as $prefix => $uri) {
- if (! array_key_exists($prefix, $this->defaultNamespaces)) {
- $this->userNamespaces[$prefix] = $uri;
+ }
+
+
+ protected function __lazyLoadNamespaces() {
+ //FIXMEPERF: Cache it somehow
+ if ($this->userNamespaces === null) {
+ $namespaces = $this->transport->getNamespaces();
+ $this->userNamespaces = array();
+ foreach ($namespaces as $prefix => $uri) {
+ if (! array_key_exists($prefix, $this->defaultNamespaces)) {
+ $this->userNamespaces[$prefix] = $uri;
+ }
}
}
}
@@ -96,7 +103,7 @@ class NamespaceRegistry implements \IteratorAggregate, \PHPCR\NamespaceRegistryI
if (false !== array_search($uri, $this->defaultNamespaces)) {
throw new \PHPCR\NamespaceException("Can not change default namespace $prefix = $uri");
}
-
+ $this->__lazyLoadNamespaces();
//first try putting the stuff in backend, and only afterwards update lokal info
// this has no impact on running sessions, go directly to storage
@@ -145,6 +152,7 @@ class NamespaceRegistry implements \IteratorAggregate, \PHPCR\NamespaceRegistryI
*/
public function getPrefixes()
{
+ $this->__lazyLoadNamespaces();
return array_merge(
array_keys($this->defaultNamespaces),
array_keys($this->userNamespaces)
@@ -160,6 +168,7 @@ class NamespaceRegistry implements \IteratorAggregate, \PHPCR\NamespaceRegistryI
*/
public function getURIs()
{
+ $this->__lazyLoadNamespaces();
return array_merge(
array_values($this->defaultNamespaces),
array_values($this->userNamespaces)
@@ -179,6 +188,7 @@ class NamespaceRegistry implements \IteratorAggregate, \PHPCR\NamespaceRegistryI
if (isset($this->defaultNamespaces[$prefix])) {
return $this->defaultNamespaces[$prefix];
} elseif (isset($this->userNamespaces[$prefix])) {
+ $this->__lazyLoadNamespaces();
return $this->userNamespaces[$prefix];
}
throw new \PHPCR\NamespaceException("Mapping for '$prefix' is not defined");
@@ -197,6 +207,7 @@ class NamespaceRegistry implements \IteratorAggregate, \PHPCR\NamespaceRegistryI
{
$prefix = array_search($uri, $this->defaultNamespaces);
if ($prefix === false) {
+ $this->__lazyLoadNamespaces();
$prefix = array_search($uri, $this->userNamespaces);
if ($prefix === false) {
throw new \PHPCR\NamespaceException("URI '$uri' is not defined in registry");
diff --git a/src/Jackalope/Repository.php b/src/Jackalope/Repository.php
index 22f2d3e..4295566 100644
--- a/src/Jackalope/Repository.php
+++ b/src/Jackalope/Repository.php
@@ -19,6 +19,9 @@ class Repository implements \PHPCR\RepositoryInterface
protected $factory;
protected $transport;
+
+ protected $loginCheck;
+
/** Array of descriptors. Each is either a string or an array of strings. */
protected $descriptors;
@@ -47,6 +50,9 @@ class Repository implements \PHPCR\RepositoryInterface
$this->transport = $transport;
}
+ public function setLoginCheck($bool) {
+ $this->loginCheck = $bool;
+ }
/**
* Authenticates the user using the supplied credentials. If workspaceName is recognized as the
* name of an existing workspace in the repository and authorization to access that workspace
diff --git a/src/Jackalope/Transport/Davex/Client.php b/src/Jackalope/Transport/Davex/Client.php
index 9941666..5c7b0a6 100755
--- a/src/Jackalope/Transport/Davex/Client.php
+++ b/src/Jackalope/Transport/Davex/Client.php
@@ -242,7 +242,8 @@ class Client implements TransportInterface
$this->workspace = $workspaceName;
$this->workspaceUri = $this->server . $workspaceName;
$this->workspaceUriRoot = $this->workspaceUri . "/jcr:root";
-
+return true;
+//FIXMEPERF... Can't we just remove that? You get the proper exception later...
$request = $this->getRequest(Request::PROPFIND, $this->workspaceUri);
$request->setBody($this->buildPropfindRequest(array('D:workspace', 'dcr:workspaceName')));
$dom = $request->executeDom();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment