]> git.mxchange.org Git - core.git/blob - application/tests/classes/controller/console/class_TestsConsoleDefaultNewsController.php
Continued:
[core.git] / application / tests / classes / controller / console / class_TestsConsoleDefaultNewsController.php
1 <?php
2 // Own namespace
3 namespace CoreFramework\Tests\Controller;
4
5 // Import framework stuff
6 use CoreFramework\Controller\BaseController;
7
8 /**
9  * The default controller with news for e.g. home or news page
10  *
11  * @author              Roland Haeder <webmaster@shipsimu.org>
12  * @version             0.0.0
13  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Hub Developer Team
14  * @license             GNU GPL 3.0 or any newer version
15  * @link                http://www.shipsimu.org
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program. If not, see <http://www.gnu.org/licenses/>.
29  */
30 class TestsConsoleDefaultNewsController extends BaseController implements Controller {
31         /**
32          * Protected constructor
33          *
34          * @return      void
35          */
36         protected function __construct () {
37                 // Call parent constructor
38                 parent::__construct(__CLASS__);
39
40                 // Init additional filter chains
41                 /*
42                 foreach (array('bootstrap', 'activation','shutdown') as $filterChain) {
43                         $this->initFilterChain($filterChain);
44                 } // END - foreach
45                 */
46         }
47
48         /**
49          * Creates an instance of this class
50          *
51          * @param       $resolverInstance               An instance of a command resolver class
52          * @return      $controllerInstance             A prepared instance of this class
53          */
54         public static final function createTestsConsoleDefaultNewsController (CommandResolver $resolverInstance) {
55                 // Create the instance
56                 $controllerInstance = new TestsConsoleDefaultNewsController();
57
58                 // Set the command resolver
59                 $controllerInstance->setResolverInstance($resolverInstance);
60
61                 // Add news filters to this controller
62                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
63                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter'));
64
65                 // Return the prepared instance
66                 return $controllerInstance;
67         }
68
69         /**
70          * Handles the given request and response
71          *
72          * @param       $requestInstance        An instance of a request class
73          * @param       $responseInstance       An instance of a response class
74          * @return      void
75          */
76         public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
77                 // Get the command instance from the resolver by sending a request instance to the resolver
78                 $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
79
80                 // Add more filters by the command
81                 $commandInstance->addExtraFilters($this, $requestInstance);
82
83                 // Run the pre filters
84                 $this->executePreFilters($requestInstance, $responseInstance);
85
86                 // This request was valid! :-D
87                 $requestInstance->requestIsValid();
88
89                 // Execute the command
90                 $commandInstance->execute($requestInstance, $responseInstance);
91
92                 // Run the pre filters
93                 $this->executePostFilters($requestInstance, $responseInstance);
94
95                 // Flush the response out
96                 $responseInstance->flushBuffer();
97         }
98
99         /**
100          * Add a bootstrap filter
101          *
102          * @param       $filterInstance         A Filterable class
103          * @return      void
104          */
105         public function addBootstrapFilter (Filterable $filterInstance) {
106                 $this->addFilter('bootstrap', $filterInstance);
107         }
108
109         /**
110          * Executes all bootstrap filters
111          *
112          * @param       $requestInstance        A Requestable class
113          * @param       $responseInstance       A Responseable class
114          * @return      void
115          */
116         public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
117                 $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
118         }
119
120         /**
121          * Add a hub activation filter
122          *
123          * @param       $filterInstance         A Filterable class
124          * @return      void
125          */
126         public function addActivationFilter (Filterable $filterInstance) {
127                 $this->addFilter('activation', $filterInstance);
128         }
129
130         /**
131          * Executes all hub activation filters
132          *
133          * @param       $requestInstance        A Requestable class
134          * @param       $responseInstance       A Responseable class
135          * @return      void
136          */
137         public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
138                 $this->executeFilters('activation', $requestInstance, $responseInstance);
139         }
140 }
141
142 // [EOF]
143 ?>