5 * @author Roland Haeder <webmaster@ship-simu.org>
7 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
8 * @license GNU GPL 3.0 or any newer version
9 * @link http://www.ship-simu.org
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 class ???Resolver extends BaseResolver implements Resolver {
26 * Protected constructor
30 private function __construct () {
31 // Call parent constructor
32 parent::__construct(__CLASS__);
34 // Set prefix to '???'
35 $this->setClassPrefix('???');
39 * Creates an instance of a Html action resolver with a given default action
41 * @param $!!!Name The default action we shall execute
42 * @param $appInstance An instance of a manageable application helper class
43 * @return $resolverInstance The prepared action resolver instance
44 * @throws EmptyVariableException Thrown if default action is not set
45 * @throws Invalid|||Exception Thrown if default action is invalid
47 public static final function create???Resolver ($!!!Name, ManageableApplication $appInstance) {
48 // Create the new instance
49 $resolverInstance = new ???Resolver();
51 // Is the variable $!!!Name set and the action is valid?
52 if (empty($!!!Name)) {
53 // Then thrown an exception here
54 throw new EmptyVariableException(array($resolverInstance, 'default|||'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
55 } elseif ($resolverInstance->is|||Valid($!!!Name) === false) {
56 // Invalid action found
57 throw new Invalid|||Exception(array($resolverInstance, $!!!Name), self::EXCEPTION_INVALID_ACTION);
60 // Set the application instance
61 $resolverInstance->setApplicationInstance($appInstance);
63 // Return the prepared instance
64 return $resolverInstance;
68 * Returns an action instance for a given request class or null if
71 * @param $requestInstance An instance of a request class
72 * @return $!!!Instance An instance of the resolved action
73 * @throws Invalid|||Exception Thrown if $!!!Name is
75 * @throws Invalid|||InstanceException Thrown if $!!!Instance
76 * is an invalid instance
78 public function resolve|||ByRequest (Requestable $requestInstance) {
83 // This goes fine so let's resolve the action
84 $!!!Name = $requestInstance->getRequestElement('action');
86 // Is the action empty? Then fall back to default action
87 if (empty($!!!Name)) $!!!Name = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_action');
89 // Check if action is valid
90 if ($this->is|||Valid($!!!Name) === false) {
91 // This action is invalid!
92 throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
96 $!!!Instance = $this->load|||();
99 if ((!is_object($!!!Instance)) || (!$!!!Instance instanceof |||able)) {
100 // This action has an invalid instance!
101 throw new Invalid|||InstanceException(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
105 $this->setResolvedInstance($!!!Instance);
107 // Return the resolved action instance
112 * Resolves the action by its direct name and returns an instance of its class
114 * @return $!!!Instance An instance of the action class
115 * @throws Invalid|||Exception Thrown if $!!!Name is invalid
117 public function resolve||| () {
118 // Initiate the instance variable
122 $!!!Name = $this->get|||Name();
124 // Is the action empty? Then fall back to default action
125 if (empty($!!!Name)) {
126 $!!!Name = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_action');
129 // Check if action is valid
130 if ($this->is|||Valid($!!!Name) === false) {
131 // This action is invalid!
132 throw new Invalid|||Exception(array($this, $!!!Name), self::EXCEPTION_INVALID_ACTION);
136 $!!!Instance = $this->load|||();
138 // Return the instance