Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge commit 'v2.6.4'

  • Loading branch information...
commit 6ec31746245f2b019a42f69d4134ef79cfb8b608 2 parents f2025c7 + 03b7529
@enyo authored
View
2  README.markdown
@@ -1,4 +1,4 @@
-# Rincewind Version 2.6.3
+# Rincewind Version 2.6.4
Is a PHP library.
View
6 library/Dao/File/FileDaoBase.php
@@ -254,7 +254,7 @@ protected function exportMap($map) {
if ( ! is_array($map)) throw new DaoWrongValueException("The passed map is not an array.");
- $assignments = array();
+ $exportedMap = array();
foreach ($map as $attributeName => $value) {
if ($value instanceof DaoAttributeAssignment) {
@@ -267,10 +267,10 @@ protected function exportMap($map) {
}
$type = $this->attributes[$attributeName];
- $map[$this->exportAttributeName($attributeName)] = $this->exportValue($attributeName, $value, $type, $this->notNull($attributeName));
+ $exportedMap[$this->exportAttributeName($attributeName)] = $this->exportValue($attributeName, $value, $type, $this->notNull($attributeName));
}
- return $map;
+ return $exportedMap;
}
/**
View
25 library/Dao/Reference/BasicDaoReference.php
@@ -89,6 +89,14 @@
*/
protected $foreignKey = 'id';
/**
+ * Can contain values the referenced records will be filtered with.
+ *
+ * Eg.: array('deleted' => false)
+ *
+ * @var array
+ */
+ protected $filterMap;
+ /**
* The Dao this reference is assigned to.
* @var Dao
*/
@@ -109,13 +117,15 @@
* @param bool $export specifies if this reference should be sent to the
* datasource when saving.
* @param bool $exportData If true, the complete data will be exported, not only the id.
+ * @param array $filterMap
*/
- public function __construct($foreignDaoName, $localKey = null, $foreignKey = null, $export = false, $exportData = false) {
+ public function __construct($foreignDaoName, $localKey = null, $foreignKey = null, $export = false, $exportData = false, $filterMap = null) {
$this->foreignDao = $foreignDaoName;
$this->localKey = $localKey;
if ($foreignKey !== null) $this->foreignKey = $foreignKey;
$this->export = $export;
$this->exportData = $exportData;
+ $this->filterMap = $filterMap;
}
/**
@@ -234,4 +244,17 @@ protected function cacheAndReturn($record, $attributeName, $value) {
return $value;
}
+ /**
+ * Adds the filterMap to the provided map.
+ * If values exist in both, $map will override the $filterMap
+ *
+ * @param array $map The map to add the filter to
+ * @return array
+ * @uses $filterMap
+ */
+ protected function applyFilter($map) {
+ if (!$this->filterMap) return $map;
+ else return array_merge($this->filterMap, $map);
+ }
+
}
View
7 library/Dao/Reference/DaoJoinTableToManyReference.php
@@ -73,9 +73,10 @@ class DaoJoinTableToManyReference extends BasicDaoToManyReference {
* @param string $joinToForeignKey
* @param string $localKey
* @param string $foreignKey
+ * @param array $filterMap
*/
- public function __construct($foreignDaoName, $joinDaoName, $joinToLocalKey, $joinToForeignKey, $localKey = 'id', $foreignKey = 'id') {
- parent::__construct($foreignDaoName, $localKey, $foreignKey, false);
+ public function __construct($foreignDaoName, $joinDaoName, $joinToLocalKey, $joinToForeignKey, $localKey = 'id', $foreignKey = 'id', $filterMap = null) {
+ parent::__construct($foreignDaoName, $localKey, $foreignKey, false, false, $filterMap);
$this->joinDao = $joinDaoName;
$this->joinToLocalKey = $joinToLocalKey;
$this->joinToForeignKey = $joinToForeignKey;
@@ -116,7 +117,7 @@ public function getReferenced($record, $attribute) {
$joinDao = $this->getJoinDao();
// Get all joins, that point to the local key.
- $joins = $joinDao->getIterator(array($this->getJoinToLocalKey() => $record->get($this->getLocalKey())));
+ $joins = $joinDao->getIterator($this->applyFilter(array($this->getJoinToLocalKey() => $record->get($this->getLocalKey()))));
// Extract an array of foreign keys.
$foreignKeys = array();
View
6 library/Dao/Reference/DaoJoinToManyReference.php
@@ -38,8 +38,8 @@ class DaoJoinToManyReference extends BasicDaoToManyReference {
* @param string $foreignKey
* @param string $localKey
*/
- public function __construct($foreignDaoName, $foreignKey, $localKey = 'id') {
- parent::__construct($foreignDaoName, $localKey, $foreignKey, false);
+ public function __construct($foreignDaoName, $foreignKey, $localKey = 'id', $filterMap = null) {
+ parent::__construct($foreignDaoName, $localKey, $foreignKey, false, false, $filterMap);
}
/**
@@ -66,7 +66,7 @@ public function getReferenced($record, $attributeName) {
}
}
else {
- return $this->cacheAndReturn($record, $attributeName, $this->getForeignDao()->getIterator(array($this->getForeignKey() => $record->get($this->getLocalKey()))));
+ return $this->cacheAndReturn($record, $attributeName, $this->getForeignDao()->getIterator($this->applyFilter(array($this->getForeignKey() => $record->get($this->getLocalKey())))));
}
}
View
2  library/rincewind.php
@@ -10,7 +10,7 @@
/**
* Defines the current rincewind version
*/
-define('RINCEWIND_VERSION', '2.6.3');
+define('RINCEWIND_VERSION', '2.6.4');
/**
* Defines the path to the rincewind library.
Please sign in to comment.
Something went wrong with that request. Please try again.