Introduce setConfiguredLimit() to SearchCriteria class, this is much better than...
authorRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2011 21:55:19 +0000 (21:55 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 29 Mar 2011 21:55:19 +0000 (21:55 +0000)
inc/classes/main/criteria/search/class_SearchCriteria.php
inc/classes/main/reader/class_ConsoleNewsReader.php
inc/classes/main/reader/class_DefaultNewsReader.php

index 3a45b74..c85d244 100644 (file)
@@ -97,6 +97,18 @@ class SearchCriteria extends BaseCriteria implements LocalSearchCriteria {
                $this->limit = $limit;
        }
 
+       /**
+        * "Setter" for limit from a configuration entry
+        *
+        * @param       $configEntry    The configuration entry which hold a number as limit
+        * @return      void
+        */
+       public final function setConfiguredLimit ($configEntry) {
+               // Get the limit from config entry and set it
+               $limit = $this->getConfigInstance()->getConfigEntry($configEntry);
+               $this->setLimit($limit);
+       }
+
        /**
         * Getter for limit
         *
index c771487..ee5040d 100644 (file)
@@ -69,7 +69,7 @@ class ConsoleNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg
                $criteriaInstance->addCriteria('page', $command);
 
                // Add limitation from config
-               $criteriaInstance->setLimit($this->getConfigInstance()->getConfigEntry('news_' . $command . '_limit'));
+               $criteriaInstance->setConfiguredLimit('news_' . $command . '_limit');
 
                // Get a resultInstance back from the database
                $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
index f21e622..29c325a 100644 (file)
@@ -69,7 +69,7 @@ class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Reg
                $criteriaInstance->addCriteria('page', $page);
 
                // Add limitation from config
-               $criteriaInstance->setLimit($this->getConfigInstance()->getConfigEntry('news_' . $page . '_limit'));
+               $criteriaInstance->setConfiguredLimit('news_' . $page . '_limit');
 
                // Get a resultInstance back from the database
                $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);