Permalink
Browse files

Improve class naming and docs for DataList::applyFilterContext()

  • Loading branch information...
1 parent 7be8a22 commit c23df511cd0dc0d316489bd443d7256ee28c4226 @halkyon halkyon committed Dec 13, 2012
Showing with 9 additions and 9 deletions.
  1. +9 −9 model/DataList.php
View
@@ -386,7 +386,7 @@ public function addFilter($filterArray) {
$fieldArgs = explode(':',$field);
$field = array_shift($fieldArgs);
foreach($fieldArgs as $fieldArg){
- $comparisor = $this->applyFilterContext($field, $fieldArg, $value);
+ $this->applyFilterContext($field, $fieldArg, $value);
}
} else {
if($field == 'ID') {
@@ -455,23 +455,23 @@ public function getRelationName($field) {
}
/**
- * Translates the comparisator to the sql query
+ * Translates a filter type to a SQL query.
*
* @param string $field - the fieldname in the db
- * @param string $comparisators - example StartsWith, relates to a filtercontext
+ * @param string $filter - a {@link SearchFilter} class, e.g. PartialMatch or StartsWith
* @param string $value - the value that the filtercontext will use for matching
* @todo Deprecated SearchContexts and pull their functionality into the core of the ORM
*/
- private function applyFilterContext($field, $comparisators, $value) {
+ private function applyFilterContext($field, $filter, $value) {
$t = singleton($this->dataClass())->dbObject($field);
- $className = "{$comparisators}Filter";
- if(!class_exists($className)){
- throw new InvalidArgumentException('There are no '.$comparisators.' comparisator');
+ $className = sprintf('%sFilter', $filter);
+ if(!class_exists($className)) {
+ throw new InvalidArgumentException(sprintf('Filter class "%s" does not exist', $className));
}
- $t = new $className($field,$value);
+ $t = new $className($field, $value);
$t->apply($this->dataQuery());
}
-
+
/**
* Return a copy of this list which does not contain any items with these charactaristics
*

0 comments on commit c23df51

Please sign in to comment.