--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command for the 'server' routine
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Lfdb2ConsoleServerCommand extends BaseCommand implements Commandable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $commandInstance An instance a prepared command class
+ */
+ public static final function createLfdb2ConsoleServerCommand (CommandResolver $resolverInstance) {
+ // Get new instance
+ $commandInstance = new Lfdb2ConsoleServerCommand();
+
+ // Set the application instance
+ $commandInstance->setResolverInstance($resolverInstance);
+
+ // Return the prepared instance
+ return $commandInstance;
+ }
+
+ /**
+ * Executes the given command with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo Try to create a Lfdb2ActivationTask or so
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get a registry and the application instance from it
+ $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+ /*
+ * ----------------------- Bootstrapping phase ------------------------
+ * Try to bootstrap the server and pass the request instance to it for
+ * extra arguments which mostly override config entries or enable special
+ * features within the hub (none is ready at this development stage)
+ */
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
+ $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
+ self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
+
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Add some server-specific filters, e.g. announcement
+ $serverInstance->addExtraServerFilters();
+
+ /*
+ * -------------------------- Server activation --------------------------
+ * Activates the server by doing some final preparation steps and setting
+ * the attribute $hubIsActive to TRUE.
+ */
+ $serverInstance->activateServer($requestInstance, $responseInstance);
+
+ // Get task handler instance
+ $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
+
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---');
+
+ /*
+ * ----------------------------- Main loop ----------------------------
+ * This is the main server loop. Queried calls should come back here very fast
+ * so the whole application runs on nice speed. This while-loop goes
+ * until the hub is no longer active or all tasks are killed.
+ */
+ while (($serverInstance->isServerActive()) && ($handlerInstance->hasTasksLeft())) {
+ // Handle all tasks here
+ $handlerInstance->handleTasks();
+ } // END - while
+
+ // Debug message
+ self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---');
+ }
+
+ /**
+ * Adds extra filters to the given controller instance
+ *
+ * @param $controllerInstance A controller instance
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @return void
+ * @todo Should we add some more filters?
+ */
+ public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
+ // Add pre filters
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_php_requirements_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_initializer_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_welcome_teaser_filter'));
+
+ // Add bootstrap filters
+ $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_extra_bootstrapping_filter'));
+ $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_listener_pool_filter'));
+
+ // Add server activation filters
+ $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('server_activation_task_handler_initializer_filter'));
+
+ // Add shutdown filters
+ $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_task_handler_filter'));
+
+ // This is the last generic shutdown filter
+ $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_server_filter'));
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * The default controller with news for e.g. home or news page
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Lfdb2ConsoleDefaultNewsController extends BaseController implements Controller {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Init additional filter chains
+ foreach (array('bootstrap', 'activation','shutdown') as $filterChain) {
+ $this->initFilterChain($filterChain);
+ } // END - foreach
+ }
+
+ /**
+ * Creates an instance of this class
+ *
+ * @param $resolverInstance An instance of a command resolver class
+ * @return $controllerInstance A prepared instance of this class
+ */
+ public static final function createLfdb2ConsoleDefaultNewsController (CommandResolver $resolverInstance) {
+ // Create the instance
+ $controllerInstance = new Lfdb2ConsoleDefaultNewsController();
+
+ // Set the command resolver
+ $controllerInstance->setResolverInstance($resolverInstance);
+
+ // Add news filters to this controller
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
+ $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter'));
+
+ // Return the prepared instance
+ return $controllerInstance;
+ }
+
+ /**
+ * Handles the given request and response
+ *
+ * @param $requestInstance An instance of a request class
+ * @param $responseInstance An instance of a response class
+ * @return void
+ */
+ public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get the command instance from the resolver by sending a request instance to the resolver
+ $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
+
+ // Add more filters by the command
+ $commandInstance->addExtraFilters($this, $requestInstance);
+
+ // Run the pre filters
+ $this->executePreFilters($requestInstance, $responseInstance);
+
+ // This request was valid! :-D
+ $requestInstance->requestIsValid();
+
+ // Execute the command
+ $commandInstance->execute($requestInstance, $responseInstance);
+
+ // Run the pre filters
+ $this->executePostFilters($requestInstance, $responseInstance);
+
+ // Flush the response out
+ $responseInstance->flushBuffer();
+ }
+
+ /**
+ * Add a bootstrap filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addBootstrapFilter (Filterable $filterInstance) {
+ $this->addFilter('bootstrap', $filterInstance);
+ }
+
+ /**
+ * Executes all bootstrap filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
+ }
+
+ /**
+ * Add a hub activation filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addActivationFilter (Filterable $filterInstance) {
+ $this->addFilter('activation', $filterInstance);
+ }
+
+ /**
+ * Executes all hub activation filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('activation', $requestInstance, $responseInstance);
+ }
+
+ /**
+ * Add a shutdown filter
+ *
+ * @param $filterInstance A Filterable class
+ * @return void
+ */
+ public function addShutdownFilter (Filterable $filterInstance) {
+ $this->addFilter('shutdown', $filterInstance);
+ }
+
+ /**
+ * Executes all shutdown filters
+ *
+ * @param $requestInstance A Requestable class
+ * @param $responseInstance A Responseable class
+ * @return void
+ */
+ public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->executeFilters('shutdown', $requestInstance, $responseInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? filter for bootstrapping
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Server Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerBootstrap???Filter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createServerBootstrap???Filter () {
+ // Get a new instance
+ $filterInstance = new ServerBootstrap???Filter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Now do something
+ $this->partialStub('Please implement this step.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ExtraBootstrapping filter for bootstrapping
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerBootstrapExtraBootstrappingFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerBootstrapExtraBootstrappingFilter () {
+ // Get a new instance
+ $filterInstance = new ServerBootstrapExtraBootstrappingFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $serverInstance is null (no NullPointerException here)
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Do some extra bootstrapping steps
+ $serverInstance->doBootstrapping();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ListenerPool filter for bootstrapping
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerBootstrapListenerPoolFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerBootstrapListenerPoolFilter () {
+ // Get a new instance
+ $filterInstance = new ServerBootstrapListenerPoolFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $serverInstance is null (no NullPointerException here)
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Now do something
+ $serverInstance->initializeListenerPool();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A generic filter for LFDB2 project
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseLfdb2Filter extends BaseFilter {
+ /**
+ * Array with all data XML nodes (which hold the actual data) and their values
+ */
+ protected $dataXmlNodes = array();
+
+ /**
+ * Protected constructor
+ *
+ * @param $className Real name of class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+
+ /**
+ * Processes the given raw message content. The method renderXmlContent
+ * may throw (not the method itself) several exceptions:
+ *
+ * InvalidXmlNodeException - If an invalid XML node has been found (e.g.
+ * wrong/out-dated template used)
+ * XmlNodeMismatchException - Again might be caused by invalid XML node
+ * usage
+ * XmlParserException - If the XML message is damaged or not
+ * well-formed
+ *
+ * @param $messageType Type of message
+ * @param $messageContent Raw message content
+ * @param $packageInstance An instance of a Receivable class
+ * @return void
+ * @todo Exceptions from renderXmlContent() are currently unhandled
+ */
+ protected function genericProcessMessage ($messageType, $messageContent, Receivable $packageInstance) {
+ $this->partialStub('Please fix this imported code.');
+ die();
+
+ // Get a template instance from the factory
+ $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_' . $messageType . '_template_class');
+
+ // And render the XML content (aka message)
+ $templateInstance->renderXmlContent($messageContent);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent);
+
+ /*
+ * The template system now stores all required data as 'general'
+ * variables, so simply get them. If there is an invalid XML node
+ * inside the message, the above method call will cause exceptions.
+ */
+ foreach ($this->dataXmlNodes as $key => $dummy) {
+ // Call it
+ $value = $templateInstance->readXmlData($key);
+
+ /*
+ * If value is NULL, a variable hasn't been found. This could mean
+ * that *this* node is running an out-dated software or the other
+ * peer is using an out-dated $messageType.xml template.
+ */
+ if (is_null($value)) {
+ // Output a warning
+ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.');
+
+ // Skip this part, don't write NULLs to the array
+ continue;
+ } // END - if
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value);
+
+ // Set it now
+ $this->dataXmlNodes[$key] = $value;
+ } // END - foreach
+
+ // Construct an array for pushing it on next stack
+ $messageArray = array(
+ // Message data itself
+ NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes,
+ // Message type (which is $messageType)
+ NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType
+ );
+
+ // Push the processed message back on stack
+ $packageInstance->getStackerInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A generic filter for servers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class BaseServerFilter extends BaseLfdb2Filter {
+ /**
+ * Protected constructor
+ *
+ * @param $className Real name of class
+ * @return void
+ */
+ protected function __construct ($className) {
+ // Call parent constructor
+ parent::__construct($className);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? filter for servers
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Server???Filter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createServer???Filter () {
+ // Get a new instance
+ $filterInstance = new Server???Filter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Implement this!
+ $this->partialStub('Please implement this method.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A Initialization filter for servers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerInitializationFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerInitializationFilter () {
+ // Get a new instance
+ $filterInstance = new ServerInitializationFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->partialStub('Unported.');
+ die();
+
+ // The default node-mode is from our configuration
+ $nodeMode = $this->getConfigInstance()->getConfigEntry('node_default_mode');
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Got default node mode ' . $nodeMode . ' from configuration.');
+
+ // Is the node 'mode' parameter set?
+ if ($requestInstance->isRequestElementSet('mode')) {
+ // Then use this which overrides the config entry temporarily
+ $nodeMode = $requestInstance->getRequestElement('mode');
+ } else {
+ // Set it for easier re-usage
+ $requestInstance->setRequestElement('mode', $nodeMode);
+ }
+
+ // Now convert the node-mode in a class name
+ $className = 'Lfdb2' . self::convertToClassName($nodeMode) . 'Server';
+
+ // And try to instance it
+ try {
+ // Get an instance
+ $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
+
+ // Get a registry
+ $applicationInstance = Registry::getRegistry()->getInstance('app');
+
+ // Set the app instance
+ $nodeInstance->setApplicationInstance($applicationInstance);
+
+ // Add node-specific filters
+ $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
+ } catch (ClassNotFoundException $e) {
+ // This exception means, the node mode is invalid.
+ // @TODO Can we rewrite this to app_exit() ?
+ $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: node mode ' . $nodeMode . ' is invalid.');
+ }
+
+ // Set the node instance in registry
+ Registry::getRegistry()->addInstance('node', $nodeInstance);
+ //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Server ' . $nodeMode . ' has been added to registry.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A PhpRequirements filter for servers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerPhpRequirementsFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerPhpRequirementsFilter () {
+ // Get a new instance
+ $filterInstance = new ServerPhpRequirementsFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If a required PHP function is not available
+ * @todo Add more test and try to add an extra message to the thrown exception
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // By default, the requirement check is passed and zero checks are failed
+ $checkPassed = TRUE;
+ $checksFailed = 0;
+
+ // Socket support is essential...
+ if (!function_exists('socket_create')) {
+ // Test failed
+ $checkPassed = FALSE;
+ $checksFailed++;
+ } // END -if
+
+ // Are all tests passed?
+ if ($checkPassed === FALSE) {
+ // Throw an exception
+ throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
+ } // END - if
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A welcome-teaser filter for the console
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerWelcomeTeaserFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerWelcomeTeaserFilter () {
+ // Get a new instance
+ $filterInstance = new ServerWelcomeTeaserFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $nodeInstance is null (no NullPointerException here)
+ * @todo Handle over the $responseInstance to outputConsoleTeaser()
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Now output the teaser
+ $serverInstance->outputConsoleTeaser();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A ??? filter for shutting down the server.
+ *
+ * @author Roland Haeder <webmaster@ship-simu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.ship-simu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerShutdown???Filter extends BaseNodeFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public final static function createServerShutdown???Filter () {
+ // Get a new instance
+ $filterInstance = new ServerShutdown???Filter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $serverInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Now do something
+ $this->partialStub('Please implement this step.');
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A ShutdownServer filter for shutting down the server. This filter should be the
+ * last one in 'shutdown' chain so the hub is shutted down at the very end of
+ * its life... R.I.P. little hub...
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerShutdownServerFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerShutdownServerFilter () {
+ // Get a new instance
+ $filterInstance = new ServerShutdownServerFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $serverInstance is null (no NullPointerException please)
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Shutdown the server. This should be the last line
+ $serverInstance->doShutdown();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+<?php
+/**
+ * A TaskHandler filter for shutting down the node.
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerShutdownTaskHandlerFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerShutdownTaskHandlerFilter () {
+ // Get a new instance
+ $filterInstance = new ServerShutdownTaskHandlerFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If $nodeInstance is null (no NullPointerException here)
+ * @todo 0% done
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ // Get task handler instance
+ $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
+
+ // Shutdown the task manager and all its registered tasks
+ $handlerInstance->doShutdown();
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A TaskHandlerInitializer filter for servers
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class ServerTaskHandlerInitializerFilter extends BaseServerFilter implements Filterable {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+ }
+
+ /**
+ * Creates an instance of this filter class
+ *
+ * @return $filterInstance An instance of this filter class
+ */
+ public static final function createServerTaskHandlerInitializerFilter () {
+ // Get a new instance
+ $filterInstance = new ServerTaskHandlerInitializerFilter();
+
+ // Return the instance
+ return $filterInstance;
+ }
+
+ /**
+ * Executes the filter with given request and response objects
+ *
+ * @param $requestInstance An instance of a class with an Requestable interface
+ * @param $responseInstance An instance of a class with an Responseable interface
+ * @return void
+ * @throws FilterChainException If we need to interrupt the filter chain
+ * @todo Maybe some more tasks needs to be added?
+ */
+ public function execute (Requestable $requestInstance, Responseable $responseInstance) {
+ $this->partialStub('Unported.');
+ die();
+
+ // Get server instance
+ $serverInstance = Registry::getRegistry()->getInstance('server');
+
+ // Get a new task handler instance
+ $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
+
+ // Generate socket listener task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_socket_listener_task_class');
+
+ // Network package reader, needs to be delayed a little
+ $handlerInstance->registerTask('socket_listener', $taskInstance);
+
+ // Generate package reader task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class', array($nodeInstance->getListenerPoolInstance()));
+
+ // Network package reader, needs to be delayed a little
+ $handlerInstance->registerTask('network_package_reader', $taskInstance);
+
+ // Generate package writer task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_writer_task_class');
+
+ // Register it as well
+ $handlerInstance->registerTask('network_package_writer', $taskInstance);
+
+ // Generate chunk assembler task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_chunk_assembler_task_class');
+
+ // Register it as well
+ $handlerInstance->registerTask('chunk_assembler', $taskInstance);
+
+ // Generate package decoder task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_decoder_task_class');
+
+ // Register it as well
+ $handlerInstance->registerTask('package_decoder', $taskInstance);
+
+ // Generate DHT initialization task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_init_task_class');
+
+ // Register it as well
+ $handlerInstance->registerTask('dht_init', $taskInstance);
+
+ // Generate DHT query task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_query_task_class');
+
+ // Register it as well
+ $handlerInstance->registerTask('dht_query', $taskInstance);
+
+ // Prepare a package-tags initialization task for the listeners
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class');
+
+ // Register it
+ $handlerInstance->registerTask('package_tags_init', $taskInstance);
+
+ // Prepare a self-test task for the listeners
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_selfconnect_task_class');
+
+ // Register it
+ $handlerInstance->registerTask('self_connect', $taskInstance);
+
+ // Prepare a update-check task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_update_check_task_class');
+
+ // Register it
+ $handlerInstance->registerTask('update_check', $taskInstance);
+
+ // Get the list instance here
+ $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance();
+
+ // Prepare a ping task
+ $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance));
+
+ // Register it
+ $handlerInstance->registerTask('ping', $taskInstance);
+
+ // Put the task handler in registry
+ Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A command resolver for local commands
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Lfdb2ConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "Lfdb2Console"
+ $this->setClassPrefix('lfdb2_console');
+ }
+
+ /**
+ * Creates an instance of a Lfdb2Console command resolver with a given default command
+ *
+ * @param $commandName The default command we shall execute
+ * @param $applicationInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared command resolver instance
+ * @throws EmptyVariableException Thrown if default command is not set
+ * @throws InvalidCommandException Thrown if default command is invalid
+ */
+ public static final function createLfdb2ConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new Lfdb2ConsoleCommandResolver();
+
+ // Is the variable $commandName set and the command is valid?
+ if (empty($commandName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) {
+ // Invalid command found
+ throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($applicationInstance);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+}
+
+// [EOF]
+?>
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+/**
+ * A resolver for resolving controllers locally
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2013 LFDB2 Developer Team
+ * @license GNU GPL 3.0 or any newer version
+ * @link http://www.shipsimu.org
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+class Lfdb2ConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "lfdb2_console"
+ $this->setClassPrefix('lfdb2_console');
+ }
+
+ /**
+ * Creates an instance of a resolver class with a given command
+ *
+ * @param $controllerName The controller we shall resolve
+ * @param $applicationInstance An instance of a manageable application helper class
+ * @return $resolverInstance The prepared controller resolver instance
+ * @throws EmptyVariableException Thrown if default command is not set
+ * @throws InvalidControllerException Thrown if default controller is invalid
+ */
+ public static final function createLfdb2ConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new Lfdb2ConsoleControllerResolver();
+
+ // Is the variable $controllerName set and the command is valid?
+ if (empty($controllerName)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
+ // Invalid command found
+ throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ }
+
+ // Set the application instance
+ $resolverInstance->setApplicationInstance($applicationInstance);
+
+ // Set command name
+ $resolverInstance->setControllerName($controllerName);
+
+ // Return the prepared instance
+ return $resolverInstance;
+ }
+
+ /**
+ * Resolves the default controller of the given command
+ *
+ * @return $controllerInstance A controller instance for the default
+ * command
+ * @throws InvalidControllerInstanceException Thrown if $controllerInstance
+ * is invalid
+ */
+ public function resolveController () {
+ // Init variables
+ $controllerName = '';
+ $controllerInstance = NULL;
+
+ // Get the command name
+ $controllerName = $this->getControllerName();
+
+ // Get the command
+ $controllerInstance = $this->loadController($controllerName);
+
+ // And validate it
+ if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
+ // This command has an invalid instance!
+ throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
+ } // END - if
+
+ // Set last controller
+ $this->setResolvedInstance($controllerInstance);
+
+ // Return the maybe resolved instance
+ return $controllerInstance;
+ }
+}
+
+// [EOF]
+?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A command for the 'server' routine
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Lfdb2ConsoleServerCommand extends BaseCommand implements Commandable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $commandInstance An instance a prepared command class
- */
- public static final function createLfdb2ConsoleServerCommand (CommandResolver $resolverInstance) {
- // Get new instance
- $commandInstance = new Lfdb2ConsoleServerCommand();
-
- // Set the application instance
- $commandInstance->setResolverInstance($resolverInstance);
-
- // Return the prepared instance
- return $commandInstance;
- }
-
- /**
- * Executes the given command with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo Try to create a Lfdb2ActivationTask or so
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get a registry and the application instance from it
- $applicationInstance = Registry::getRegistry()->getInstance('app');
-
- /*
- * ----------------------- Bootstrapping phase ------------------------
- * Try to bootstrap the server and pass the request instance to it for
- * extra arguments which mostly override config entries or enable special
- * features within the hub (none is ready at this development stage)
- */
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Beginning with bootstrap...');
- $applicationInstance->getControllerInstance()->executeBootstrapFilters($requestInstance, $responseInstance);
- self::createDebugInstance(__CLASS__)->debugOutput('BOOTSTRAP: Bootstrap finished.');
-
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Add some server-specific filters, e.g. announcement
- $serverInstance->addExtraServerFilters();
-
- /*
- * -------------------------- Server activation --------------------------
- * Activates the server by doing some final preparation steps and setting
- * the attribute $hubIsActive to TRUE.
- */
- $serverInstance->activateServer($requestInstance, $responseInstance);
-
- // Get task handler instance
- $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
-
- // Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Entering main loop. ---');
-
- /*
- * ----------------------------- Main loop ----------------------------
- * This is the main server loop. Queried calls should come back here very fast
- * so the whole application runs on nice speed. This while-loop goes
- * until the hub is no longer active or all tasks are killed.
- */
- while (($serverInstance->isServerActive()) && ($handlerInstance->hasTasksLeft())) {
- // Handle all tasks here
- $handlerInstance->handleTasks();
- } // END - while
-
- // Debug message
- self::createDebugInstance(__CLASS__)->debugOutput('MAIN: --- Leaving main loop. ---');
- }
-
- /**
- * Adds extra filters to the given controller instance
- *
- * @param $controllerInstance A controller instance
- * @param $requestInstance An instance of a class with an Requestable interface
- * @return void
- * @todo Should we add some more filters?
- */
- public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Add pre filters
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_php_requirements_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_initializer_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('server_welcome_teaser_filter'));
-
- // Add bootstrap filters
- $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_extra_bootstrapping_filter'));
- $controllerInstance->addBootstrapFilter(ObjectFactory::createObjectByConfiguredName('server_bootstrap_listener_pool_filter'));
-
- // Add server activation filters
- $controllerInstance->addActivationFilter(ObjectFactory::createObjectByConfiguredName('server_activation_task_handler_initializer_filter'));
-
- // Add shutdown filters
- $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_task_handler_filter'));
-
- // This is the last generic shutdown filter
- $controllerInstance->addShutdownFilter(ObjectFactory::createObjectByConfiguredName('server_shutdown_server_filter'));
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * The default controller with news for e.g. home or news page
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Lfdb2ConsoleDefaultNewsController extends BaseController implements Controller {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Init additional filter chains
- foreach (array('bootstrap', 'activation','shutdown') as $filterChain) {
- $this->initFilterChain($filterChain);
- } // END - foreach
- }
-
- /**
- * Creates an instance of this class
- *
- * @param $resolverInstance An instance of a command resolver class
- * @return $controllerInstance A prepared instance of this class
- */
- public static final function createLfdb2ConsoleDefaultNewsController (CommandResolver $resolverInstance) {
- // Create the instance
- $controllerInstance = new Lfdb2ConsoleDefaultNewsController();
-
- // Set the command resolver
- $controllerInstance->setResolverInstance($resolverInstance);
-
- // Add news filters to this controller
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_download_filter'));
- $controllerInstance->addPreFilter(ObjectFactory::createObjectByConfiguredName('news_process_filter'));
-
- // Return the prepared instance
- return $controllerInstance;
- }
-
- /**
- * Handles the given request and response
- *
- * @param $requestInstance An instance of a request class
- * @param $responseInstance An instance of a response class
- * @return void
- */
- public function handleRequest (Requestable $requestInstance, Responseable $responseInstance) {
- // Get the command instance from the resolver by sending a request instance to the resolver
- $commandInstance = $this->getResolverInstance()->resolveCommandByRequest($requestInstance);
-
- // Add more filters by the command
- $commandInstance->addExtraFilters($this, $requestInstance);
-
- // Run the pre filters
- $this->executePreFilters($requestInstance, $responseInstance);
-
- // This request was valid! :-D
- $requestInstance->requestIsValid();
-
- // Execute the command
- $commandInstance->execute($requestInstance, $responseInstance);
-
- // Run the pre filters
- $this->executePostFilters($requestInstance, $responseInstance);
-
- // Flush the response out
- $responseInstance->flushBuffer();
- }
-
- /**
- * Add a bootstrap filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addBootstrapFilter (Filterable $filterInstance) {
- $this->addFilter('bootstrap', $filterInstance);
- }
-
- /**
- * Executes all bootstrap filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeBootstrapFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('bootstrap', $requestInstance, $responseInstance);
- }
-
- /**
- * Add a hub activation filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addActivationFilter (Filterable $filterInstance) {
- $this->addFilter('activation', $filterInstance);
- }
-
- /**
- * Executes all hub activation filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('activation', $requestInstance, $responseInstance);
- }
-
- /**
- * Add a shutdown filter
- *
- * @param $filterInstance A Filterable class
- * @return void
- */
- public function addShutdownFilter (Filterable $filterInstance) {
- $this->addFilter('shutdown', $filterInstance);
- }
-
- /**
- * Executes all shutdown filters
- *
- * @param $requestInstance A Requestable class
- * @param $responseInstance A Responseable class
- * @return void
- */
- public function executeShutdownFilters (Requestable $requestInstance, Responseable $responseInstance) {
- $this->executeFilters('shutdown', $requestInstance, $responseInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? filter for bootstrapping
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Server Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerBootstrap???Filter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createServerBootstrap???Filter () {
- // Get a new instance
- $filterInstance = new ServerBootstrap???Filter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Now do something
- $this->partialStub('Please implement this step.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ExtraBootstrapping filter for bootstrapping
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerBootstrapExtraBootstrappingFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerBootstrapExtraBootstrappingFilter () {
- // Get a new instance
- $filterInstance = new ServerBootstrapExtraBootstrappingFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $serverInstance is null (no NullPointerException here)
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Do some extra bootstrapping steps
- $serverInstance->doBootstrapping();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ListenerPool filter for bootstrapping
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerBootstrapListenerPoolFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerBootstrapListenerPoolFilter () {
- // Get a new instance
- $filterInstance = new ServerBootstrapListenerPoolFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $serverInstance is null (no NullPointerException here)
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Now do something
- $serverInstance->initializeListenerPool();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A generic filter for LFDB2 project
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class BaseLfdb2Filter extends BaseFilter {
- /**
- * Array with all data XML nodes (which hold the actual data) and their values
- */
- protected $dataXmlNodes = array();
-
- /**
- * Protected constructor
- *
- * @param $className Real name of class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-
- /**
- * Processes the given raw message content. The method renderXmlContent
- * may throw (not the method itself) several exceptions:
- *
- * InvalidXmlNodeException - If an invalid XML node has been found (e.g.
- * wrong/out-dated template used)
- * XmlNodeMismatchException - Again might be caused by invalid XML node
- * usage
- * XmlParserException - If the XML message is damaged or not
- * well-formed
- *
- * @param $messageType Type of message
- * @param $messageContent Raw message content
- * @param $packageInstance An instance of a Receivable class
- * @return void
- * @todo Exceptions from renderXmlContent() are currently unhandled
- */
- protected function genericProcessMessage ($messageType, $messageContent, Receivable $packageInstance) {
- $this->partialStub('Please fix this imported code.');
- die();
-
- // Get a template instance from the factory
- $templateInstance = XmlTemplateEngineFactory::createXmlTemplateEngineInstance('node_' . $messageType . '_template_class');
-
- // And render the XML content (aka message)
- $templateInstance->renderXmlContent($messageContent);
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Handling ' . strlen($messageContent) . ' bytes: ' . $messageContent);
-
- /*
- * The template system now stores all required data as 'general'
- * variables, so simply get them. If there is an invalid XML node
- * inside the message, the above method call will cause exceptions.
- */
- foreach ($this->dataXmlNodes as $key => $dummy) {
- // Call it
- $value = $templateInstance->readXmlData($key);
-
- /*
- * If value is NULL, a variable hasn't been found. This could mean
- * that *this* node is running an out-dated software or the other
- * peer is using an out-dated $messageType.xml template.
- */
- if (is_null($value)) {
- // Output a warning
- self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: Found not fully supported variable ' . $key . ' - skipping.');
-
- // Skip this part, don't write NULLs to the array
- continue;
- } // END - if
-
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(str_replace('_', '-', strtoupper($messageType)) . '-TAG: key=' . $key . ',value=' . $value);
-
- // Set it now
- $this->dataXmlNodes[$key] = $value;
- } // END - foreach
-
- // Construct an array for pushing it on next stack
- $messageArray = array(
- // Message data itself
- NetworkPackage::MESSAGE_ARRAY_DATA => $this->dataXmlNodes,
- // Message type (which is $messageType)
- NetworkPackage::MESSAGE_ARRAY_TYPE => $messageType
- );
-
- // Push the processed message back on stack
- $packageInstance->getStackerInstance()->pushNamed(NetworkPackage::STACKER_NAME_PROCESSED_MESSAGE, $messageArray);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A generic filter for servers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class BaseServerFilter extends BaseLfdb2Filter {
- /**
- * Protected constructor
- *
- * @param $className Real name of class
- * @return void
- */
- protected function __construct ($className) {
- // Call parent constructor
- parent::__construct($className);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? filter for servers
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Server???Filter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createServer???Filter () {
- // Get a new instance
- $filterInstance = new Server???Filter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Implement this!
- $this->partialStub('Please implement this method.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A Initialization filter for servers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerInitializationFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerInitializationFilter () {
- // Get a new instance
- $filterInstance = new ServerInitializationFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub('Unported.');
- die();
-
- // The default node-mode is from our configuration
- $nodeMode = $this->getConfigInstance()->getConfigEntry('node_default_mode');
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Got default node mode ' . $nodeMode . ' from configuration.');
-
- // Is the node 'mode' parameter set?
- if ($requestInstance->isRequestElementSet('mode')) {
- // Then use this which overrides the config entry temporarily
- $nodeMode = $requestInstance->getRequestElement('mode');
- } else {
- // Set it for easier re-usage
- $requestInstance->setRequestElement('mode', $nodeMode);
- }
-
- // Now convert the node-mode in a class name
- $className = 'Lfdb2' . self::convertToClassName($nodeMode) . 'Server';
-
- // And try to instance it
- try {
- // Get an instance
- $nodeInstance = ObjectFactory::createObjectByName($className, array($requestInstance));
-
- // Get a registry
- $applicationInstance = Registry::getRegistry()->getInstance('app');
-
- // Set the app instance
- $nodeInstance->setApplicationInstance($applicationInstance);
-
- // Add node-specific filters
- $nodeInstance->addExtraFilters($applicationInstance->getControllerInstance(), $responseInstance);
- } catch (ClassNotFoundException $e) {
- // This exception means, the node mode is invalid.
- // @TODO Can we rewrite this to app_exit() ?
- $this->debugBackTrace('[' . __METHOD__ . ':' . __LINE__ . ']: node mode ' . $nodeMode . ' is invalid.');
- }
-
- // Set the node instance in registry
- Registry::getRegistry()->addInstance('node', $nodeInstance);
- //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[INIT:] Server ' . $nodeMode . ' has been added to registry.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A PhpRequirements filter for servers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerPhpRequirementsFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerPhpRequirementsFilter () {
- // Get a new instance
- $filterInstance = new ServerPhpRequirementsFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If a required PHP function is not available
- * @todo Add more test and try to add an extra message to the thrown exception
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // By default, the requirement check is passed and zero checks are failed
- $checkPassed = TRUE;
- $checksFailed = 0;
-
- // Socket support is essential...
- if (!function_exists('socket_create')) {
- // Test failed
- $checkPassed = FALSE;
- $checksFailed++;
- } // END -if
-
- // Are all tests passed?
- if ($checkPassed === FALSE) {
- // Throw an exception
- throw new FilterChainException($this, self::EXCEPTION_FILTER_CHAIN_INTERCEPTED);
- } // END - if
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A welcome-teaser filter for the console
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerWelcomeTeaserFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerWelcomeTeaserFilter () {
- // Get a new instance
- $filterInstance = new ServerWelcomeTeaserFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $nodeInstance is null (no NullPointerException here)
- * @todo Handle over the $responseInstance to outputConsoleTeaser()
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Now output the teaser
- $serverInstance->outputConsoleTeaser();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A ??? filter for shutting down the server.
- *
- * @author Roland Haeder <webmaster@ship-simu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.ship-simu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerShutdown???Filter extends BaseNodeFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public final static function createServerShutdown???Filter () {
- // Get a new instance
- $filterInstance = new ServerShutdown???Filter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $serverInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Now do something
- $this->partialStub('Please implement this step.');
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A ShutdownServer filter for shutting down the server. This filter should be the
- * last one in 'shutdown' chain so the hub is shutted down at the very end of
- * its life... R.I.P. little hub...
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerShutdownServerFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerShutdownServerFilter () {
- // Get a new instance
- $filterInstance = new ServerShutdownServerFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $serverInstance is null (no NullPointerException please)
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Shutdown the server. This should be the last line
- $serverInstance->doShutdown();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-<?php
-/**
- * A TaskHandler filter for shutting down the node.
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerShutdownTaskHandlerFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerShutdownTaskHandlerFilter () {
- // Get a new instance
- $filterInstance = new ServerShutdownTaskHandlerFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If $nodeInstance is null (no NullPointerException here)
- * @todo 0% done
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- // Get task handler instance
- $handlerInstance = Registry::getRegistry()->getInstance('task_handler');
-
- // Shutdown the task manager and all its registered tasks
- $handlerInstance->doShutdown();
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A TaskHandlerInitializer filter for servers
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class ServerTaskHandlerInitializerFilter extends BaseServerFilter implements Filterable {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
- }
-
- /**
- * Creates an instance of this filter class
- *
- * @return $filterInstance An instance of this filter class
- */
- public static final function createServerTaskHandlerInitializerFilter () {
- // Get a new instance
- $filterInstance = new ServerTaskHandlerInitializerFilter();
-
- // Return the instance
- return $filterInstance;
- }
-
- /**
- * Executes the filter with given request and response objects
- *
- * @param $requestInstance An instance of a class with an Requestable interface
- * @param $responseInstance An instance of a class with an Responseable interface
- * @return void
- * @throws FilterChainException If we need to interrupt the filter chain
- * @todo Maybe some more tasks needs to be added?
- */
- public function execute (Requestable $requestInstance, Responseable $responseInstance) {
- $this->partialStub('Unported.');
- die();
-
- // Get server instance
- $serverInstance = Registry::getRegistry()->getInstance('server');
-
- // Get a new task handler instance
- $handlerInstance = ObjectFactory::createObjectByConfiguredName('task_handler_class');
-
- // Generate socket listener task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_socket_listener_task_class');
-
- // Network package reader, needs to be delayed a little
- $handlerInstance->registerTask('socket_listener', $taskInstance);
-
- // Generate package reader task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_reader_task_class', array($nodeInstance->getListenerPoolInstance()));
-
- // Network package reader, needs to be delayed a little
- $handlerInstance->registerTask('network_package_reader', $taskInstance);
-
- // Generate package writer task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_writer_task_class');
-
- // Register it as well
- $handlerInstance->registerTask('network_package_writer', $taskInstance);
-
- // Generate chunk assembler task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_chunk_assembler_task_class');
-
- // Register it as well
- $handlerInstance->registerTask('chunk_assembler', $taskInstance);
-
- // Generate package decoder task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_decoder_task_class');
-
- // Register it as well
- $handlerInstance->registerTask('package_decoder', $taskInstance);
-
- // Generate DHT initialization task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_init_task_class');
-
- // Register it as well
- $handlerInstance->registerTask('dht_init', $taskInstance);
-
- // Generate DHT query task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_dht_query_task_class');
-
- // Register it as well
- $handlerInstance->registerTask('dht_query', $taskInstance);
-
- // Prepare a package-tags initialization task for the listeners
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_package_tags_init_task_class');
-
- // Register it
- $handlerInstance->registerTask('package_tags_init', $taskInstance);
-
- // Prepare a self-test task for the listeners
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_selfconnect_task_class');
-
- // Register it
- $handlerInstance->registerTask('self_connect', $taskInstance);
-
- // Prepare a update-check task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_update_check_task_class');
-
- // Register it
- $handlerInstance->registerTask('update_check', $taskInstance);
-
- // Get the list instance here
- $listInstance = $nodeInstance->getListenerPoolInstance()->getPoolEntriesInstance();
-
- // Prepare a ping task
- $taskInstance = ObjectFactory::createObjectByConfiguredName('node_ping_task_class', array($listInstance));
-
- // Register it
- $handlerInstance->registerTask('ping', $taskInstance);
-
- // Put the task handler in registry
- Registry::getRegistry()->addInstance('task_handler', $handlerInstance);
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A command resolver for local commands
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Lfdb2ConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "Lfdb2Console"
- $this->setClassPrefix('lfdb2_console');
- }
-
- /**
- * Creates an instance of a Lfdb2Console command resolver with a given default command
- *
- * @param $commandName The default command we shall execute
- * @param $applicationInstance An instance of a manageable application helper class
- * @return $resolverInstance The prepared command resolver instance
- * @throws EmptyVariableException Thrown if default command is not set
- * @throws InvalidCommandException Thrown if default command is invalid
- */
- public static final function createLfdb2ConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) {
- // Create the new instance
- $resolverInstance = new Lfdb2ConsoleCommandResolver();
-
- // Is the variable $commandName set and the command is valid?
- if (empty($commandName)) {
- // Then thrown an exception here
- throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isCommandValid($commandName) === FALSE) {
- // Invalid command found
- throw new InvalidCommandException(array($resolverInstance, $commandName), self::EXCEPTION_INVALID_COMMAND);
- }
-
- // Set the application instance
- $resolverInstance->setApplicationInstance($applicationInstance);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-}
-
-// [EOF]
-?>
+++ /dev/null
-Deny from all
+++ /dev/null
-Deny from all
+++ /dev/null
-<?php
-/**
- * A resolver for resolving controllers locally
- *
- * @author Roland Haeder <webmaster@shipsimu.org>
- * @version 0.0.0
- * @copyright Copyright (c) 2013 LFDB2 Developer Team
- * @license GNU GPL 3.0 or any newer version
- * @link http://www.shipsimu.org
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-class Lfdb2ConsoleControllerResolver extends BaseControllerResolver implements ControllerResolver {
- /**
- * Protected constructor
- *
- * @return void
- */
- protected function __construct () {
- // Call parent constructor
- parent::__construct(__CLASS__);
-
- // Set prefix to "lfdb2_console"
- $this->setClassPrefix('lfdb2_console');
- }
-
- /**
- * Creates an instance of a resolver class with a given command
- *
- * @param $controllerName The controller we shall resolve
- * @param $applicationInstance An instance of a manageable application helper class
- * @return $resolverInstance The prepared controller resolver instance
- * @throws EmptyVariableException Thrown if default command is not set
- * @throws InvalidControllerException Thrown if default controller is invalid
- */
- public static final function createLfdb2ConsoleControllerResolver ($controllerName, ManageableApplication $applicationInstance) {
- // Create the new instance
- $resolverInstance = new Lfdb2ConsoleControllerResolver();
-
- // Is the variable $controllerName set and the command is valid?
- if (empty($controllerName)) {
- // Then thrown an exception here
- throw new EmptyVariableException(array($resolverInstance, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
- } elseif ($resolverInstance->isControllerValid($controllerName) === FALSE) {
- // Invalid command found
- throw new InvalidControllerException(array($resolverInstance, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- }
-
- // Set the application instance
- $resolverInstance->setApplicationInstance($applicationInstance);
-
- // Set command name
- $resolverInstance->setControllerName($controllerName);
-
- // Return the prepared instance
- return $resolverInstance;
- }
-
- /**
- * Resolves the default controller of the given command
- *
- * @return $controllerInstance A controller instance for the default
- * command
- * @throws InvalidControllerInstanceException Thrown if $controllerInstance
- * is invalid
- */
- public function resolveController () {
- // Init variables
- $controllerName = '';
- $controllerInstance = NULL;
-
- // Get the command name
- $controllerName = $this->getControllerName();
-
- // Get the command
- $controllerInstance = $this->loadController($controllerName);
-
- // And validate it
- if ((!is_object($controllerInstance)) || (!$controllerInstance instanceof Controller)) {
- // This command has an invalid instance!
- throw new InvalidControllerInstanceException(array($this, $controllerName), self::EXCEPTION_INVALID_CONTROLLER);
- } // END - if
-
- // Set last controller
- $this->setResolvedInstance($controllerInstance);
-
- // Return the maybe resolved instance
- return $controllerInstance;
- }
-}
-
-// [EOF]
-?>
-Subproject commit 23aa45d4a6205e26184190ca446316d06a9b4648
+Subproject commit 7bc4014657a70dedfc38b9b28d134aa7c3a6158c