4 * @author Roland Haeder <webmaster@shipsimu.org>
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.shipsimu.org
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.
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.
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/>.
23 class WebShipsimuGovernmentTrainingCommand extends BaseCommand implements Commandable {
25 * Protected constructor
29 protected function __construct () {
30 // Call parent constructor
31 parent::__construct(__CLASS__);
35 * Creates an instance of this class
37 * @param $resolverInstance An instance of a command resolver class
38 * @return $commandInstance An instance a prepared command class
40 public static final function createWebShipsimuGovernmentTrainingCommand (CommandResolver $resolverInstance) {
42 $commandInstance = new WebShipsimuGovernmentTrainingCommand();
44 // Set the application instance
45 $commandInstance->setResolverInstance($resolverInstance);
47 // Return the prepared instance
48 return $commandInstance;
52 * Executes the given command with given request and response objects
54 * @param $requestInstance An instance of a class with an Requestable interface
55 * @param $responseInstance An instance of a class with an Responseable interface
59 public function execute (Requestable $requestInstance, Responseable $responseInstance) {
60 // Get a wrapper instance
61 $wrapperInstance = ObjectFactory::createObjectByConfiguredName('user_gov_wrapper_class');
63 // Register the training
64 $wrapperInstance->registerTrainingByRequest($requestInstance);
68 * Adds extra filters to the given controller instance
70 * @param $controllerInstance A controller instance
71 * @param $requestInstance An instance of a class with an Requestable interface
73 * @todo Maybe we need some filters here?
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'));
79 // Add user status filter here
80 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('user_status_filter'));
82 // Check if government can pay training help
83 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('government_pays_training_filter'));
86 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('account_password_filter'));
88 // Verify CAPTCHA code
89 $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('captcha_refill_verifier_filter'));