Permalink
Browse files

added Configuration class

  • Loading branch information...
1 parent 3cff91d commit ac26ea9ee688febb38b96d701c91a36fbe277b02 @LeoOnTheEarth committed Jul 7, 2012
Showing with 37 additions and 2 deletions.
  1. +30 −0 lib/Couchbase/ODM/Configuration.php
  2. +7 −2 lib/Couchbase/ODM/DocumentManager.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Couchbase\ODM;
+
+/**
+ * Configuration class
+ */
+class Configuration
+{
+ /**
+ * @var string
+ */
+ protected $namespace = '';
+
+ /**
+ * @param string $namespace
+ */
+ public function setNamespace($namespace)
+ {
+ $this->namespace = $namespace;
+ }
+
+ /**
+ * @return string
+ */
+ public function getNamespace()
+ {
+ return $this->namespace;
+ }
+}
@@ -15,6 +15,10 @@ class DocumentManager
*/
protected $conn = null;
/**
+ * @var Configuration
+ */
+ protected $config = null;
+ /**
* @var array
*/
protected $objects = array();
@@ -23,9 +27,10 @@ class DocumentManager
*/
protected $persists = array();
- public function __construct(Connection $conn)
+ public function __construct(Connection $conn, Configuration $config)
{
$this->conn = $conn;
+ $this->config = $config;
}
/**
@@ -99,7 +104,7 @@ public function getKey($className, array $primaryIds)
$className = substr($className, 1);
}
- return $className . ':' . implode(':', $primaryIds);
+ return $this->config->getNamespace() . $className . ':' . implode(':', $primaryIds);
}
/**

0 comments on commit ac26ea9

Please sign in to comment.