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