3 namespace CoreFramework\Resolver\Command;
5 // Import framework stuff
6 use CoreFramework\Command\InvalidCommandException;
7 use CoreFramework\Generic\EmptyVariableException;
8 use CoreFramework\Manager\ManageableApplication;
9 use CoreFramework\Resolver\Command\CommandResolver;
12 * A command resolver for local (non-hubbed) HTML commands
14 * @author Roland Haeder <webmaster@shipsimu.org>
16 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
17 * @license GNU GPL 3.0 or any newer version
18 * @link http://www.shipsimu.org
20 * This program is free software: you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation, either version 3 of the License, or
23 * (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 class HtmlCommandResolver extends BaseCommandResolver implements CommandResolver {
35 * Last successfull resolved command
37 private $lastCommandInstance = NULL;
40 * Protected constructor
44 protected function __construct () {
45 // Call parent constructor
46 parent::__construct(__CLASS__);
48 // Set prefix to "html"
49 $this->setClassPrefix('html');
53 * Creates an instance of a Html command resolver with a given default command
55 * @param $commandName The default command we shall execute
56 * @param $applicationInstance An instance of a manageable application helper class
57 * @return $resolverInstance The prepared command resolver instance
58 * @throws EmptyVariableException Thrown if default command is not set
59 * @throws InvalidCommandException Thrown if default command is invalid
61 public static final function createHtmlCommandResolver ($commandName, ManageableApplication $applicationInstance) {
62 // Create the new instance
63 $resolverInstance = new HtmlCommandResolver();
65 // Is the variable $commandName set and the command is valid?
66 if (empty($commandName)) {
67 // Then thrown an exception here
68 throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
69 } elseif ($resolverInstance->isCommandValid($commandName) === false) {
70 // Invalid command found
71 throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
74 // Set the application instance
75 $resolverInstance->setApplicationInstance($applicationInstance);
77 // Return the prepared instance
78 return $resolverInstance;