public function executeActivationFilters (Requestable $requestInstance, Responseable $responseInstance) {
$this->executeFilters('activation', $requestInstance, $responseInstance);
}
-}
-// [EOF]
-?>
+}
--- /dev/null
+Deny from all
--- /dev/null
+Deny from all
--- /dev/null
+<?php
+// Own namespace
+namespace CoreFramework\Tests\Resolver\Command;
+
+// Import framework stuff
+use CoreFramework\Command\InvalidCommandException;
+use CoreFramework\Manager\ManageableApplication;
+use CoreFramework\Resolver\Command\BaseCommandResolver;
+use CoreFramework\Resolver\Command\CommandResolver;
+
+/**
+ * A command resolver for console commands
+ *
+ * @author Roland Haeder <webmaster@shipsimu.org>
+ * @version 0.0.0
+ * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2015 Core 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 TestsConsoleCommandResolver extends BaseCommandResolver implements CommandResolver {
+ /**
+ * Protected constructor
+ *
+ * @return void
+ */
+ protected function __construct () {
+ // Call parent constructor
+ parent::__construct(__CLASS__);
+
+ // Set prefix to "TestsConsole"
+ $this->setClassPrefix('tests_console');
+ }
+
+ /**
+ * Creates an instance of a TestsConsole 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 createTestsConsoleCommandResolver ($commandName, ManageableApplication $applicationInstance) {
+ // Create the new instance
+ $resolverInstance = new TestsConsoleCommandResolver();
+
+ // 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('CoreFramework\Tests\Command', $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;
+ }
+
+}
// Return the maybe resolved instance
return $controllerInstance;
}
-}
-// [EOF]
-?>
+}
// CFG: DEFAULT-TESTS-CONSOLE-CONTROLLER
$cfg->setConfigEntry('default_tests_console_controller', 'main');
+
+// CFG: TESTS-CONSOLE-CMD-MAIN-RESOLVER-CLASS
+$cfg->setConfigEntry('tests_console_cmd_main_resolver_class', 'CoreFramework\Tests\Resolver\Command\TestsConsoleCommandResolver');
*/
public static function scanFrameworkClasses () {
// Trace message
- /* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
// Cache loader instance
$loaderInstance = self::getSelfInstance();
// Load all classes
foreach (self::$frameworkPaths as $pathName) {
// Debug message
- /* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
// Try to load the framework classes
$loaderInstance->scanClassPath('inc/main/' . $pathName . '/');
*/
public static function scanApplicationClasses () {
// Trace message
- /* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: CALLED!' . PHP_EOL, __METHOD__, __LINE__);
// Get config instance
$cfg = FrameworkConfiguration::getSelfInstance();
$pathName = sprintf('%s/%s/%s', $cfg->getConfigEntry('application_path'), $cfg->getConfigEntry('app_name'), $class);
// Debug message
- /* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
+ //* NOISY-DEBUG: */ printf('[%s:%d]: pathName=%s' . PHP_EOL, __METHOD__, __LINE__, $pathName);
// Is the path readable?
if (is_dir($pathName)) {
}
// Get a new iterator
- /* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s' . PHP_EOL, __METHOD__, __LINE__, $basePath);
+ //* NOISY-DEBUG: */ printf('[%s:%d] basePath=%s' . PHP_EOL, __METHOD__, __LINE__, $basePath);
$iteratorInstance = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($basePath), RecursiveIteratorIterator::CHILD_FIRST);
// Load all entries
$iteratorInstance->next();
// Skip non-file entries
- /* NOISY-DEBUG: */ printf('[%s:%d] SKIP: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] SKIP: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
continue;
} // END - if
// Is this file wanted?
- /* NOISY-DEBUG: */ printf('[%s:%d] FOUND: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] FOUND: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
if ((substr($fileName, 0, strlen($this->prefix)) == $this->prefix) && (substr($fileName, -strlen($this->suffix), strlen($this->suffix)) == $this->suffix)) {
// Add it to the list
- /* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
+ //* NOISY-DEBUG: */ printf('[%s:%d] ADD: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
$this->foundClasses[$fileName] = $fqfn;
} else {
// Not added
- /* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
+ //* NOISY-DEBUG: */ printf('[%s:%d] NOT ADDED: %s,fqfn=%s' . PHP_EOL, __METHOD__, __LINE__, $fileName, $fqfn);
}
// Advance to next entry
- /* NOISY-DEBUG: */ printf('[%s:%d] NEXT: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] NEXT: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
$iteratorInstance->next();
} // END - while
}
*/
private function loadClassFile ($className) {
// Trace message
- /* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
+ //* NOISY-DEBUG: */ printf('[%s:%d] className=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $className);
// The class name should contain at least 2 back-slashes, so split at them
$classNameParts = explode("\\", $className);
$fileName = $this->prefix . $shortClassName . $this->suffix;
// Now look it up in our index
- /* NOISY-DEBUG: */ printf('[%s:%d] ISSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] ISSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
if ((isset($this->foundClasses[$fileName])) && (!isset($this->loadedClasses[$this->foundClasses[$fileName]]))) {
// File is found and not loaded so load it only once
- /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
require($this->foundClasses[$fileName]);
- /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
// Count this loaded class/interface/exception
$this->total++;
$this->loadedClasses[$this->foundClasses[$fileName]] = TRUE;
// Remove it from classes list so it won't be found twice.
- /* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
unset($this->foundClasses[$fileName]);
// Developer mode excludes caching (better debugging)
if (!defined('DEVELOPER')) {
// Reset cache
- /* NOISY-DEBUG: */ printf('[%s:%d] classesCached=FALSE' . PHP_EOL, __METHOD__, __LINE__);
+ //* NOISY-DEBUG: */ printf('[%s:%d] classesCached=FALSE' . PHP_EOL, __METHOD__, __LINE__);
$this->classesCached = FALSE;
} // END - if
} else {
// Not found
- /* NOISY-DEBUG: */ printf('[%s:%d] 404: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] 404: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
}
}
// Is this a config?
if (substr($fileName, 0, strlen($this->prefix)) == $this->prefix) {
// Then include it
- /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - START' . PHP_EOL, __METHOD__, __LINE__, $fileName);
require($fqfn);
- /* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] LOAD: %s - END' . PHP_EOL, __METHOD__, __LINE__, $fileName);
// Remove it from the list
- /* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
+ //* NOISY-DEBUG: */ printf('[%s:%d] UNSET: %s' . PHP_EOL, __METHOD__, __LINE__, $fileName);
unset($this->foundClasses[$fileName]);
} // END - if
} // END - foreach
/**
* Checks whether the given action is valid
*
- * @param $actionName The default action we shall execute
+ * @param $namespace Namespace to look in
+ * @param $actionName The default action we shall execute
* @return $isValid Whether the given action is valid
* @throws EmptyVariableException Thrown if given action is not set
*/
- public function isActionValid ($actionName) {
+ public function isActionValid ($namespace, $actionName) {
// By default nothing shall be valid
$isValid = FALSE;
// Is a action set?
- if (empty($actionName)) {
+ if (empty($namespace)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($this, 'namespace'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (empty($actionName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($this, 'actionName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} // END - if
// Create class name
- $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($actionName) . 'Action';
+ $className = sprintf(
+ '%s\%s%sAction',
+ $namespace,
+ $this->getCapitalizedClassPrefix(),
+ self::convertToClassName($actionName)
+ );
// Now, let us create the full name of the action class
$this->setClassName($className);
// Init action instance
$actionInstance = NULL;
- // Create action class name
- $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($this->getActionName()) . 'Action';
+ // Create class name
+ $className = sprintf(
+ '%s\%s%sAction',
+ $this->getNamespace(),
+ $this->getCapitalizedClassPrefix(),
+ self::convertToClassName($actionName)
+ );
// ... and set it
$this->setClassName($className);
<?php
// Own namespace
-namespace CoreFramework\Resolver\Controller;
+namespace CoreFramework\Resolver\Command;
// Import framework stuff
+use CoreFramework\Command\InvalidCommandException;
use CoreFramework\Factory\ObjectFactory;
use CoreFramework\Request\Requestable;
use CoreFramework\Resolver\BaseResolver;
$commandInstance = NULL;
// Create class name
- $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($commandName) . 'Command';
+ $className = sprintf(
+ '%s\%s%sCommand',
+ $this->getNamespace(),
+ $this->getCapitalizedClassPrefix(),
+ self::convertToClassName($commandName)
+ );
// Create command class name
$this->setClassName($className);
/**
* Checks whether the given command is valid
*
+ * @param $namespace Namespace to look in
* @param $commandName The default command we shall execute
* @return $isValid Whether the given command is valid
* @throws EmptyVariableException Thrown if given command is not set
*/
- public function isCommandValid ($commandName) {
+ protected function isCommandValid ($namespace, $commandName) {
// By default nothing shall be valid
$isValid = FALSE;
- // Is a command set?
- if (empty($commandName)) {
+ // Is namespace and command name set?
+ if (empty($namespace)) {
+ // Then thrown an exception here
+ throw new EmptyVariableException(array($this, 'namespace'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
+ } elseif (empty($commandName)) {
// Then thrown an exception here
throw new EmptyVariableException(array($this, 'commandName'), self::EXCEPTION_UNEXPECTED_EMPTY_STRING);
} // END - if
// Create the full class name
- $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($commandName) . 'Command';
+ $className = sprintf(
+ '%s\%s%sCommand',
+ $namespace,
+ $this->getCapitalizedClassPrefix(),
+ self::convertToClassName($commandName)
+ );
// Now, let us create the full name of the command class
$this->setClassName($className);
namespace CoreFramework\Resolver\Command;
// Import framework stuff
+use CoreFramework\Command\InvalidCommandException;
use CoreFramework\Manager\ManageableApplication;
/**
namespace CoreFramework\Resolver\Command;
// Import framework stuff
+use CoreFramework\Command\InvalidCommandException;
use CoreFramework\Manager\ManageableApplication;
/**
namespace CoreFramework\Resolver\Command;
// Import framework stuff
+use CoreFramework\Command\InvalidCommandException;
use CoreFramework\Manager\ManageableApplication;
/**
//* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BEFORE: controller=' . $controllerName);
if ($controllerName != $defaultController) {
// Create controller class name
- $className = $this->getCapitalizedClassPrefix() . self::convertToClassName($controllerName) . 'Controller';
+ $className = sprintf(
+ '%s\%s%sController',
+ $namespace,
+ $this->getCapitalizedClassPrefix(),
+ self::convertToClassName($controllerName)
+ );
// ... and set it
$this->setClassName($className);
* @throws EmptyVariableException Thrown if given controller is not set
* @throws DefaultControllerException Thrown if default controller was not found
*/
- public function isControllerValid ($namespace, $controllerName) {
+ protected function isControllerValid ($namespace, $controllerName) {
// By default nothing shall be valid
$isValid = FALSE;
// In emergency exit?
if (defined('EMERGENCY_EXIT_CALLED')) {
// Output message
- printf("[%s:] Message: %s, Backtrace: <pre>%s</pre>",
+ printf(
+ '[%s:] Message: %s, Backtrace: <pre>%s</pre>',
$this->__toString(),
$message,
$this->getPrintableBackTrace()
// Should we log exceptions? (bad implementation)
if (defined('LOG_EXCEPTIONS')) {
// Log the error
- error_log(sprintf("[%s:] %s (%s)",
+ error_log(sprintf(
+ '[%s:] %s (%s)',
$this->__toString(),
$message,
$this->getHexCode()
<?php
// Own namespace
-namespace CoreFramework\Deprecated;
+namespace CoreFramework\Command;
// Import framework stuff
use CoreFramework\Generic\FrameworkException;
* @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team
* @license GNU GPL 3.0 or any newer version
* @link http://www.shipsimu.org
- * @deprecated Don't use this anymore
*
* 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
*/
function resolveCommandByRequest (Requestable $requestInstance);
- /**
- * Checks whether the given command is valid
- *
- * @param $commandName The default command we shall execute
- * @return $isValid Whether the given command is valid
- * @throws EmptyVariableException Thrown if given command is not set
- */
- function isCommandValid ($commandName);
-
}