class_WebNewsFactory.php

Go to the documentation of this file.
00001 <?php
00024 class WebNewsFactory extends BaseFactory {
00028         private $requestInstance = null;
00029 
00035         protected function __construct () {
00036                 // Call parent constructor
00037                 parent::__construct(__CLASS__);
00038         }
00039 
00047         public final static function createFactoryByRequest (Requestable $requestInstance) {
00048                 // Set default news reader class
00049                 $configEntry = "news_reader_class";
00050 
00051                 // Get "page"
00052                 $page = $requestInstance->getRequestElement('page');
00053 
00054                 // Is "page" used?
00055                 if (!empty($page)) {
00056                         // Then add it
00057                         $configEntry = sprintf("news_reader_%s_class", $page);
00058 
00059                         // Get "action"
00060                         $action = $requestInstance->getRequestElement('action');
00061 
00062                         // Is it also there?
00063                         if (!empty($action)) {
00064                                 // Then use both for config entry
00065                                 $configEntry = sprintf("news_reader_%s_%s_class", $page, $action);
00066                         } // END - if
00067                 } // END - if
00068 
00069                 // Get the news reader class name from config
00070                 $className = $requestInstance->getConfigInstance()->readConfig($configEntry);
00071 
00072                 // Once we have that name, try to load initialize it
00073                 $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
00074 
00075                 // Initialize the reader
00076                 $newsInstance->initializeReader();
00077 
00078                 // Return the prepared factory instance
00079                 return $newsInstance;
00080         }
00081 }
00082 
00083 // [EOF]
00084 ?>

Generated on Mon Dec 8 01:06:45 2008 for Ship-Simulator by  doxygen 1.5.6