X-Git-Url: https://git.mxchange.org/?p=shipsimu.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Ffactories%2Fweb%2Fclass_WebNewsFactory.php;h=dfbb6db85f26b04d14187a21182792a387c2f42d;hp=ecd1f286422f9f38294e25dbac5848da3f3d1a1b;hb=b848cab53db89342f0a854a00be91cadbcff2967;hpb=425cd4dda06724de295f7762c27efc2e539c2a53 diff --git a/inc/classes/main/factories/web/class_WebNewsFactory.php b/inc/classes/main/factories/web/class_WebNewsFactory.php index ecd1f28..dfbb6db 100644 --- a/inc/classes/main/factories/web/class_WebNewsFactory.php +++ b/inc/classes/main/factories/web/class_WebNewsFactory.php @@ -51,67 +51,16 @@ class WebNewsFactory extends BaseFactory { * @return $factoryInstance An instance of a WebNewsFactory class */ public final static function createFactoryByRequest (Requestable $requestInstance) { - // Generate the new instance - $factoryInstance = new WebNewsFactory(); - - // Get the element name from configuration - $element = FrameworkConfiguration::getInstance()->readConfig('app_selector_get'); - - // Analyze the request, first get the Uni* application name (short one from URL) - $appName = $requestInstance->getRequestElement($element); - - // Initialize some variables - $className = ""; - $className2 = $appName; - - // Then construct the class name - foreach (array("_", "-") as $exp) { - $array = explode($exp, $className2); - foreach ($array as $el) { - $className .= ucfirst(strtolower($el)); - } - - // Copy it back and clear the class name - $className2 = $className; - $className = ""; - } - - // After all is done, copy it back and add this class' name - $className = $className2 . $factoryInstance->__toString(); + // Get the news reader class name from config + $className = $requestInstance->getConfigInstance()->readConfig('news_reader_class'); // Once we have that name, try to load initialize it - $realFactoryInstance = ObjectFactory::createObjectByName($className); - - // And assign it with the factory - $factoryInstance->setRealFactoryInstance($realFactoryInstance); + $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance)); - // Remember the request we have used for later usage - $factoryInstance->setRequestInstance($requestInstance); + // Initialize the reader + $newsInstance->initializeReader(); // Return the prepared factory instance - return $factoryInstance; - } - - /** - * Setter for the request instance - * - * @param $requestInstance An instance of a request object - * @return void - */ - public final function setRequestInstance (Requestable $requestInstance) { - $this->requestInstance = $requestInstance; - } - - /** - * Creates a new object instance and returns it - * - * @return $newsInstance An instance of a news object - */ - public function createNewsObject () { - // Ask the real factory class for doing this - $newsInstance = $this->getRealFactoryInstance()->createNewObject($this->requestInstance); - - // And return it return $newsInstance; } }