Missing class/config entries added, execeute() implemented, some rewrites:
[shipsimu.git] / application / ship-simu / main / commands / web / government / class_WebShipsimuGovernmentTrainingCommand.php
1 <?php
2 /**
3  *
4  * @author              Roland Haeder <webmaster@ship-simu.org>
5  * @version             0.0.0
6  * @copyright   Copyright (c) 2007, 2008 Roland Haeder, 2009 Ship-Simu Developer Team
7  * @license             GNU GPL 3.0 or any newer version
8  * @link                http://www.ship-simu.org
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <http://www.gnu.org/licenses/>.
22  */
23 class WebShipsimuGovernmentTrainingCommand extends BaseCommand implements Commandable {
24         /**
25          * Protected constructor
26          *
27          * @return      void
28          */
29         protected function __construct () {
30                 // Call parent constructor
31                 parent::__construct(__CLASS__);
32         }
33
34         /**
35          * Creates an instance of this class
36          *
37          * @param       $resolverInstance       An instance of a command resolver class
38          * @return      $commandInstance        An instance a prepared command class
39          */
40         public final static function createWebShipsimuGovernmentTrainingCommand (CommandResolver $resolverInstance) {
41                 // Get new instance
42                 $commandInstance = new WebShipsimuGovernmentTrainingCommand();
43
44                 // Set the application instance
45                 $commandInstance->setResolverInstance($resolverInstance);
46
47                 // Return the prepared instance
48                 return $commandInstance;
49         }
50
51         /**
52          * Executes the given command with given request and response objects
53          *
54          * @param       $requestInstance        An instance of a class with an Requestable interface
55          * @param       $responseInstance       An instance of a class with an Responseable interface
56          * @return      void
57          * @todo        0% done
58          */
59         public function execute (Requestable $requestInstance, Responseable $responseInstance) {
60                 // Get a wrapper instance
61                 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_gov_wrapper_class');
62
63                 // Register the training
64                 $wrapperInstance->registerTrainingByRequest($requestInstance);
65         }
66
67         /**
68          * Adds extra filters to the given controller instance
69          *
70          * @param       $controllerInstance             A controller instance
71          * @param       $requestInstance                An instance of a class with an Requestable interface
72          * @return      void
73          * @todo        Maybe we need some filters here?
74          */
75         public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
76                 // Add user auth filter (we don't need an update of the user here because it will be redirected)
77                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_auth_filter'));
78
79                 // Add user status filter here
80                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
81
82                 // Check if government can pay training help
83                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('government_pays_training_filter'));
84
85                 // Verify password
86                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('account_password_filter'));
87
88                 // Verify CAPTCHA code
89                 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_refill_verifier_filter'));
90         }
91 }
92
93 // [EOF]
94 ?>