3 namespace Org\Mxchange\CoreFramework\Factory\News;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Factory\BaseFactory;
7 use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
8 use Org\Mxchange\CoreFramework\Request\Requestable;
11 * A news factory for web pages
13 * @author Roland Haeder <webmaster@shipsimu.org>
15 <<<<<<< HEAD:framework/main/classes/factories/html/class_HtmlNewsFactory.php
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
18 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2016 Core Developer Team
19 >>>>>>> Some updates::inc/main/classes/factories/html/class_HtmlNewsFactory.php
20 * @license GNU GPL 3.0 or any newer version
21 * @link http://www.shipsimu.org
23 * This program is free software: you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation, either version 3 of the License, or
26 * (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
33 * You should have received a copy of the GNU General Public License
34 * along with this program. If not, see <http://www.gnu.org/licenses/>.
36 class HtmlNewsFactory extends BaseFactory {
38 * Protected constructor
42 protected function __construct () {
43 // Call parent constructor
44 parent::__construct(__CLASS__);
48 * Singleton getter for a special factory instance depending on the given
51 * @param $requestInstance An instance of a Requestable class
52 * @return $factoryInstance An instance of a HtmlNewsFactory class
54 public static final function createFactoryByRequest (Requestable $requestInstance) {
55 // Set default news reader class
56 $configEntry = 'news_reader_class';
59 $command = $requestInstance->getRequestElement('command');
62 if (!empty($command)) {
64 $configEntry = sprintf('news_reader_%s_class', $command);
67 $action = $requestInstance->getRequestElement('action');
70 if (!empty($action)) {
71 // Then use both for config entry
72 $configEntry = sprintf('news_reader_%s_%s_class', $command, $action);
76 // Get the news reader class name from config
77 $className = $requestInstance->getConfigInstance()->getConfigEntry($configEntry);
79 // Once we have that name, try to load initialize it
80 $newsInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
82 // Initialize the reader
83 $newsInstance->initializeReader();
85 // Return the prepared factory instance