* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews {
+class DefaultNewsReader extends BaseFrameworkSystem implements ReadableNews, Registerable {
+ /**
+ * Result set with news
+ */
+ private $resultInstance = null;
+
/**
* Protected constructor
*
* @return void
*/
public function initializeReader () {
- // TODO Need to implement this method
+ // Get "page" for saving some calls
+ $page = $this->getRequestInstance()->getRequestElement('page');
+
+ // First get a wrapper instance
+ $wrapperInstance = ObjectFactory::createObjectByConfiguredName('news_db_wrapper_class');
+
+ // Next create a searchable criteria instance
+ $criteriaInstance = ObjectFactory::createObjectByConfiguredName('search_criteria_class');
+
+ // Add the page as criteria to it at lease
+ $criteriaInstance->addCriteria('page', $page);
+
+ // Add limitation from config
+ $criteriaInstance->setLimit($this->getConfigInstance()->readConfig("news_{$page}_limit"));
+
+ // Get a resultInstance back from the database
+ $resultInstance = $wrapperInstance->doSelectByCriteria($criteriaInstance);
+
+ // Save that resultInstance in this class
+ $this->resultInstance = $resultInstance;
}
}