// Import framework stuff
use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
-use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
/**
* A general application class for the ApplicationHelper classes.
protected function __construct (string $className) {
// Call parent constructor
parent::__construct($className);
-
- // Set this instance as application instance
- GenericRegistry::getRegistry()->addInstance('application', $this);
}
/**
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Generic\UnsupportedOperationException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Loader\ClassLoader;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Middleware\Debug\DebugMiddleware;
*/
protected function initWebOutputInstance () {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Init web output instance
$outputInstance = ObjectFactory::createObjectByConfiguredName('output_class', array($applicationInstance));
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
assert(!$requestInstance->isPostRequestMethod());
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Transfer application data
$this->getTemplateInstance()->assignApplicationData();
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Assign application data with template engine
$this->getTemplateInstance()->assignApplicationData();
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Prepare a template instance
// Transfer application data
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
}
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Assign base URL
$this->getTemplateInstance()->assignConfigVariable('base_url');
* @return void
*/
public function addExtraFilters (Controller $controllerInstance, Requestable $requestInstance) {
- // Get registry
- $registryInstance = GenericRegistry::getRegistry();
-
// Get our application instance from the registry
- $applicationInstance = $registryInstance->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Default action is the one from configuration
$this->actionName = StringUtils::convertDashesToUnderscores($applicationInstance->getAppShortName()) . '_login_' . FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('login_default_action');
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
GenericRegistry::getRegistry()->addInstance('extra', $this);
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Assign application data with template engine
$this->getTemplateInstance()->assignApplicationData();
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Assign application data with template engine
$this->getTemplateInstance()->assignApplicationData();
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Assign application data
$this->getTemplateInstance()->assignApplicationData();
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
GenericRegistry::getRegistry()->addInstance('extra', $this);
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Assign all the application's data with template variables
$this->getTemplateInstance()->assignApplicationData();
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Database\Frontend\User\UserDatabaseFrontend;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
$userInstance = GenericRegistry::getRegistry()->getInstance('user');
// Get an application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Get a RNG instance (Random Number Generator)
$rngInstance = ObjectFactory::createObjectByConfiguredName('rng_class');
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
use Org\Mxchange\CoreFramework\Response\Responseable;
*/
public function execute (Requestable $requestInstance, Responseable $responseInstance) {
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Transfer application data
$this->getTemplateInstance()->assignApplicationData();
use Org\Mxchange\CoreFramework\Command\BaseCommand;
use Org\Mxchange\CoreFramework\Command\Commandable;
use Org\Mxchange\CoreFramework\Controller\Controller;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Request\Requestable;
use Org\Mxchange\CoreFramework\Resolver\Command\CommandResolver;
$decryptedCode = $requestInstance->getRequestElement('decrypted');
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Assign variable
$this->getTemplateInstance()->assignVariable('decrypted_code', $decryptedCode);
// Set resolver instance
$controllerInstance->setResolverInstance($resolverInstance);
- // We need the controller instance in resolver class so set it here
- $resolverInstance->setControllerInstance($controllerInstance);
-
// Return the prepared instance
return $controllerInstance;
}
// Make sure no 'my-' or 'my_' passes this point
assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false) && (!is_bool($criteriaValue)));
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
-
// Add it
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '(' . $this->__toString() . ')-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaValue=' . $criteriaValue);
$this->pushValueToGenericArrayElement('criteria', 'choice', 'entries', StringUtils::convertDashesToUnderscores($criteriaKey), (string) $criteriaValue);
}
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return void
*/
- public final function addConfiguredCriteria ($criteriaKey, $configEntry, string $criteriaType = 'default') {
+ public final function addConfiguredCriteria (string $criteriaKey, string $configEntry, string $criteriaType = 'default') {
// Add the configuration entry as a criteria
$value = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry($configEntry);
$this->addCriteria($criteriaKey, $value, $criteriaType);
* @param $criteriaType Type of this criteria, can be one of 'default' (default), 'choice' or 'exclude'
* @return $value Whether the value of the critera or false
*/
- public function getCriteriaElemnent ($criteriaKey, string $criteriaType = 'default') {
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!');
-
+ public function getCriteriaElemnent (string $criteriaKey, string $criteriaType = 'default') {
// Make sure no 'my-' or 'my_' passes this point
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteriaType=' . $criteriaType . ' - CALLED!');
assert((strpos($criteriaKey, 'my-') === false) && (strpos($criteriaKey, 'my_') === false));
// Convert dashes to underscore
$criteriaKey = StringUtils::convertDashesToUnderscores($criteriaKey);
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType));
-
// Default is not found
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: criteriaKey=' . $criteriaKey . ',criteria()=' . $this->countGenericArrayGroup('criteria', $criteriaType));
$value = false;
// Is the criteria there?
$value = $this->getGenericArrayElement('criteria', $criteriaType, 'entries', $criteriaKey);
} // END - if
- // Debug message
- //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!');
-
// Return the value
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(strtoupper($criteriaType) . '-CRITERIA: value=' . $value . ' - EXIT!');
return $value;
}
* @param $pathName The new path name
* @return void
*/
- protected final function setPathName ($pathName) {
- $pathName = (string) $pathName;
+ protected final function setPathName (string $pathName) {
$this->pathName = $pathName;
}
* @param $actionName Action name to set
* @return void
*/
- protected final function setActionName ($actionName) {
- $this->actionName = (string) $actionName;
+ protected final function setActionName (string $actionName) {
+ $this->actionName = $actionName;
}
/**
/**
* Array for background color values
*/
- private $backgroundColor = array(
+ private $backgroundColor = [
'red' => 0,
'green' => 0,
'blue' => 0
- );
+ ];
/**
* Array for foreground color values
*/
- private $foregroundColor = array(
+ private $foregroundColor = [
'red' => 0,
'green' => 0,
'blue' => 0
- );
+ ];
/**
* All image strings
* @param $imageType Type of the image
* @return $helperInstance A preparedf instance of this helper
*/
- public static final function createImageHelper (CompileableTemplate $templateInstance, $imageType) {
+ public static final function createImageHelper (CompileableTemplate $templateInstance, string $imageType) {
// Get new instance
$helperInstance = new ImageHelper();
*
* @param $stringName String name (identifier)
*/
- public function addTextLine ($stringName) {
+ public function addTextLine (string $stringName) {
// Create the image string
$this->imageStrings[$stringName] = array(
'x' => '',
* @param $imageString A message to display in image
* @return void
*/
- public final function setImageString ($imageString) {
- $this->imageStrings[$this->currString]['string'] = (string) $imageString;
+ public final function setImageString (string $imageString) {
+ $this->imageStrings[$this->currString]['string'] = $imageString;
}
/**
* @param $y Y coordinate
* @return void
*/
- public final function setCoord ($x, $y) {
- $this->imageStrings[$this->currString]['x'] = (int) $x;
- $this->imageStrings[$this->currString]['y'] = (int) $y;
+ public final function setCoord (int $x, int $y) {
+ $this->imageStrings[$this->currString]['x'] = $x;
+ $this->imageStrings[$this->currString]['y'] = $y;
}
/**
use Org\Mxchange\CoreFramework\Configuration\FrameworkConfiguration;
use Org\Mxchange\CoreFramework\Configuration\NoConfigEntryException;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Helper\Template\HelpableTemplate;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
$helperInstance->setLinkName($linkName);
// Get the application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Get the request instance
$requestInstance = FrameworkBootstrap::getRequestInstance();
* @param $string String to set in image
* @return void
*/
- public final function setString ($string) {
- $this->imageString = (string) $string;
+ public final function setString (string $string) {
+ $this->imageString = $string;
}
/**
* @param $name Name of the image
* @return void
*/
- public final function setImageName ($name) {
- $this->imageName = (string) $name;
+ public final function setImageName (string $name) {
+ $this->imageName = $name;
}
/**
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Localization\ManageableLanguage;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\ObjectArray\FrameworkArrayObject;
if (empty($languageBasePath)) {
// No, then attempt "auto-dection":
// 1) Get application
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// 2) Try to build it
$languageBasePath = sprintf('%s%s/language/',
*/
protected final function setLanguageBasePath (string $languageBasePath) {
// And set it
- $this->languageBasePath = (string) $languageBasePath;
+ $this->languageBasePath = $languageBasePath;
}
/**
*
* Origin: StatusNet's lib/language.php
*/
- $localeCategories = array(
+ foreach ([
'LC_CTYPE',
'LC_NUMERIC',
'LC_TIME',
'LC_MONETARY',
'LC_MESSAGES',
'LC_ALL'
- );
-
- // Set all, if not defined
- foreach ($localeCategories as $key => $name) {
+ ] as $key => $name) {
// Is it set?
if (!defined($name)) {
// No, then set it
define($name, $key);
- } // END - if
- } // END - foreach
+ }
+ }
// Init language strings array
$this->langStrings = new FrameworkArrayObject('FakedLanguageStrings');
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Mailer\BaseMailer;
use Org\Mxchange\CoreFramework\Mailer\DeliverableMail;
use Org\Mxchange\CoreFramework\Manager\Login\ManageableMember;
$templateInstance->assignTemplateWithVariable('footer', 'footer');
// Get master template name
- $masterTemplateName = GenericRegistry::getRegistry()->getInstance('application')->buildMasterTemplateName();
+ $masterTemplateName = ApplicationHelper::getSelfInstance()->buildMasterTemplateName();
// Load the master template
$templateInstance->loadCodeTemplate($masterTemplateName);
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Traits\Template\CompileableTemplateTrait;
// If page is empty, choose default
if (empty($command)) {
// Use default page as none has been specified
- $command = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . GenericRegistry::getRegistry()->getInstance('application')->getAppShortName() . '_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command');
+ $command = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . ApplicationHelper::getSelfInstance()->getAppShortName() . '_' . FrameworkBootstrap::getRequestTypeFromSystem() . '_command');
} // END - if
// Load the menu template for this page
* @param $contentType A valid content-type
* @return $debugInstance An instance of this middleware class
*/
- public static final function createConsoleOutput ($contentType) {
+ public static final function createConsoleOutput (string $contentType) {
// Cast the content-type to string
- $contentType = (string) $contentType;
$contentType = trim($contentType);
// Get instance
* @param $actionName Last validated action name
* @return void
*/
- protected final function setActionName ($actionName) {
- $this->actionName = (string) $actionName;
+ protected final function setActionName (string $actionName) {
+ $this->actionName = $actionName;
}
/**
namespace Org\Mxchange\CoreFramework\Resolver;
// Import framework stuff
-use Org\Mxchange\CoreFramework\Controller\Controller;
use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Utils\String\StringUtils;
*/
private $resolvedInstance = NULL;
- /**
- * A controller instance
- */
- private $controllerInstance = NULL;
-
/**
* Protected constructor
*
* @param $classPrefix Last validated classPrefix
* @return void
*/
- protected final function setClassPrefix ($classPrefix) {
- $this->classPrefix = (string) $classPrefix;
+ protected final function setClassPrefix (string $classPrefix) {
+ $this->classPrefix = $classPrefix;
}
/**
$this->resolvedInstance = $resolvedInstance;
}
- /**
- * Setter for controller instance (this surely breaks a bit the MVC patterm)
- *
- * @param $controllerInstance An instance of the controller
- * @return void
- */
- public final function setControllerInstance (Controller $controllerInstance) {
- $this->controllerInstance = $controllerInstance;
- }
-
- /**
- * Getter for controller instance (this surely breaks a bit the MVC patterm)
- *
- * @return $controllerInstance An instance of the controller
- */
- public final function getControllerInstance () {
- return $this->controllerInstance;
- }
-
}
use Org\Mxchange\CoreFramework\Controller\DefaultControllerException;
use Org\Mxchange\CoreFramework\Controller\InvalidControllerException;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Resolver\BaseResolver;
use Org\Mxchange\CoreFramework\Resolver\Controller\ControllerResolver;
// Cache default controller
$defaultController = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('default_' . strtolower($this->getClassPrefix()) . '_controller');
- // Init controller instance
- $controllerInstance = NULL;
-
// Create full class name
$className = sprintf(
'%s\%sDefaultNewsController',
$resolverConfigEntry,
array(
$controllerName,
- GenericRegistry::getRegistry()->getInstance('application')
+ ApplicationHelper::getSelfInstance()
)
);
+
+ // Get controller instance
$controllerInstance = ObjectFactory::createObjectByName(
$this->getClassName(),
array($resolverInstance)
public function resolveController () {
// Init variables
$controllerName = $this->getControllerName();
- $controllerInstance = NULL;
// Get the controller
$controllerInstance = $this->loadController($controllerName);
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
* @param $status New response status
* @return void
*/
- public final function setResponseStatus ($status) {
- $this->responseStatus = (string) $status;
+ public final function setResponseStatus (string $status) {
+ $this->responseStatus = $status;
}
/**
* @param $value Value of header element
* @return void
*/
- public final function addHeader ($name, $value) {
+ public final function addHeader (string $name, $value) {
$this->responseHeaders[$name] = $value;
}
* @param $output Output we shall sent in the HTTP response
* @return void
*/
- public final function writeToBody ($output) {
+ public final function writeToBody (string $output) {
$this->responseBody .= $output;
}
* @param $responseType Response type
* @return void
*/
- protected final function setResponseType ($responseType) {
+ protected final function setResponseType (string $responseType) {
$this->responseType = $responseType;
}
* @param $messageId The message id we shall add
* @return void
*/
- public final function addFatalMessage ($messageId) {
+ public final function addFatalMessage (string $messageId) {
// Adds the resolved message id to the fatal message list
$this->addFatalMessagePlain(FrameworkBootstrap::getLanguageInstance()->getMessage($messageId));
}
* @param $message The plain message we shall add
* @return void
*/
- public final function addFatalMessagePlain ($message) {
+ public final function addFatalMessagePlain (string $message) {
// Adds the resolved message id to the fatal message list
$this->pushValueToGenericArrayKey('fatal_messages', 'generic', 'message', $message);
}
* @throws ResponseHeadersAlreadySentException Thrown if headers are
* already sent
*/
- public function flushBuffer ($force = false) {
+ public function flushBuffer (bool $force = false) {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Headers already sent?
if ((headers_sent()) && ($force === false)) {
*/
public function determineDefaultCommand () {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Generate config key
$configKey = sprintf('default_%s_%s_command',
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Response\Responseable;
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
* @todo Encryption of cookie data not yet supported.
- * @todo Why are these parameters conflicting?
* @todo If the return statement is removed and setcookie() commented out,
* @todo this will send only one cookie out, the first one.
*/
*/
public function redirectToConfiguredUrl ($configEntry) {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Is the header not yet sent?
if (headers_sent()) {
* @param $cookieName Cookie to expire
* @return void
*/
- public function expireCookie ($cookieName) {
+ public function expireCookie (string $cookieName) {
// Is the cookie there?
if (isset($_COOKIE[$cookieName])) {
// Then expire it with 20 minutes past
* @param $cookieName Cookie to refresh
* @return void
*/
- public function refreshCookie ($cookieName) {
+ public function refreshCookie (string $cookieName) {
// Only update existing cookies
if (isset($_COOKIE[$cookieName])) {
// Update the cookie
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Image\BaseImage;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
* @todo Encryption of cookie data not yet supported.
- * @todo Why are these parameters conflicting?
* @todo If the return statement is removed and setcookie() commented out,
* @todo this will send only one cookie out, the first one.
*/
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- public function redirectToConfiguredUrl ($configEntry) {
+ public function redirectToConfiguredUrl (string $configEntry) {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Is the header not yet sent?
if (headers_sent()) {
* already sent with an exception
* @return void
*/
- public function flushBuffer ($force = false) {
+ public function flushBuffer (bool $force = false) {
// Finish the image
$this->getImageInstance()->finishImage();
* @param $cookieName Cookie to expire
* @return void
*/
- public function expireCookie ($cookieName) {
+ public function expireCookie (string $cookieName) {
// Is the cookie there?
if (isset($_COOKIE[$cookieName])) {
// Then expire it with 20 minutes past
* @param $cookieName Cookie to refresh
* @return void
*/
- public function refreshCookie ($cookieName) {
+ public function refreshCookie (string $cookieName) {
// Only update existing cookies
if (isset($_COOKIE[$cookieName])) {
// Update the cookie
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\FileNotFoundException;
use Org\Mxchange\CoreFramework\Generic\NullPointerException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Manager\ManageableApplication;
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
*/
public function assignApplicationData () {
// Get application instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Get long name and assign it
$this->assignVariable('app_full_name' , $applicationInstance->getAppName());
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
$templateInstance = new ConsoleTemplateEngine();
// Get the application instance from registry
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Determine base path
$templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
$templateInstance = new HtmlTemplateEngine();
// Get the application instance from registry
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Determine base path
$templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Image\BaseImage;
use Org\Mxchange\CoreFramework\Parser\Parseable;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
$templateInstance = new ImageTemplateEngine();
// Get the application instance from registry
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Determine base path
$templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
// Import framework stuff
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Mailer\DeliverableMail;
use Org\Mxchange\CoreFramework\Parser\Parseable;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
$templateInstance = new MailTemplateEngine();
// Get the application instance from registry
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Determine base path
$templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Filesystem\InvalidDirectoryException;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Menu\RenderableMenu;
use Org\Mxchange\CoreFramework\Parser\Parseable;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
$templateInstance = new MenuTemplateEngine();
// Get the application instance from registry
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Determine base path
$templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . $applicationInstance->getAppShortName(). '/';
*/
private function initMenu (string $templateDependency = '') {
// Get web template engine
- $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(GenericRegistry::getRegistry()->getInstance('application'))));
+ $this->setTemplateInstance(ObjectFactory::createObjectByConfiguredName('html_template_class', array(ApplicationHelper::getSelfInstance())));
// Handle the dependency template
$this->handleTemplateDependency('menu', $templateDependency);
*/
public function getMenuCacheFile () {
// Get the application instance from registry
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Get the file instance ready
$fileInstance = new SplFileInfo(sprintf('%s%smenus/_cache/%s.%s',
use Org\Mxchange\CoreFramework\Bootstrap\FrameworkBootstrap;
use Org\Mxchange\CoreFramework\Factory\ObjectFactory;
use Org\Mxchange\CoreFramework\Factory\Template\XmlTemplateEngineFactory;
+use Org\Mxchange\CoreFramework\Helper\Application\ApplicationHelper;
use Org\Mxchange\CoreFramework\Registry\GenericRegistry;
use Org\Mxchange\CoreFramework\Template\CompileableTemplate;
use Org\Mxchange\CoreFramework\Template\Engine\BaseTemplateEngine;
$this->typePrefix = $typePrefix;
// Get template instance
- $applicationInstance = GenericRegistry::getRegistry()->getInstance('application');
+ $applicationInstance = ApplicationHelper::getSelfInstance();
// Determine base path
$templateBasePath = FrameworkBootstrap::getConfigurationInstance()->getConfigEntry('application_base_path') . FrameworkBootstrap::getRequestInstance()->getRequestElement('app') . '/';
* @param $userName The username to set
* @return void
*/
- public final function setUserName ($userName) {
- $this->userName = (string) $userName;
+ public final function setUserName (string $userName) {
+ $this->userName = $userName;
}
/**
* @return void
* @todo Find a way of casting here. "(int)" might destroy the user id > 32766
*/
- public final function setUserId ($userId) {
+ public final function setUserId (int $userId) {
$this->userId = $userId;
}
* @param $email The email to set
* @return void
*/
- protected final function setEmail ($email) {
- $this->email = (string) $email;
+ protected final function setEmail (string $email) {
+ $this->email = $email;
}
/**
* @param $visitorMode New visitor mode to set
* @return void
*/
- protected final function setVisitorMode ($visitorMode) {
- $this->visitorMode = (string) $visitorMode;
+ protected final function setVisitorMode (string $visitorMode) {
+ $this->visitorMode = $visitorMode;
}
/**
* @param $status New response status
* @return void
*/
- function setResponseStatus ($status);
+ function setResponseStatus (string $status);
/**
* Adds a header to the response. This method "wraps" the direct header()
* @param $value Value of header element
* @return void
*/
- function addHeader ($name, $value);
+ function addHeader (string $name, $value);
/**
* "Writes" data to the response body
* @param $output Output we shall sent in the HTTP response
* @return void
*/
- function writeToBody ($output);
+ function writeToBody (string $output);
/**
* Flushs the cached HTTP response to the outer world
* @throws ResponseHeadersAlreadySentException Thrown if headers are
* already sent
*/
- function flushBuffer ($force = false);
+ function flushBuffer (bool $force = false);
/**
* Adds a fatal message id to the response. The added messages can then be
* @param $messageId The message id we shall add
* @return void
*/
- function addFatalMessage ($messageId);
+ function addFatalMessage (string $messageId);
/**
* Adds a cookie to the response
* @return void
* @throws ResponseHeadersAlreadySentException If headers are already sent
*/
- function redirectToConfiguredUrl ($configEntry);
+ function redirectToConfiguredUrl (string $configEntry);
/**
* Expires the given cookie if it is set
* @param $cookieName Cookie to expire
* @return void
*/
- function expireCookie ($cookieName);
+ function expireCookie (string $cookieName);
/**
* Refreshs a given cookie. This will make the cookie live longer
* @param $cookieName Cookie to refresh
* @return void
*/
- function refreshCookie ($cookieName);
+ function refreshCookie (string $cookieName);
}
<?php
// Own namespace
-namespace Wds66\Api;
+namespace Com\Wds66\Api;
// Import framework stuff
use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
/**
* Creates an instance of this API class
*
- * @param $cfg Configuration array
+ * @param $configArray Configuration array
* @return $apiInstance An instance of this API class
*/
- public static final function createWernisApi (array $cfg) {
+ public static final function createWernisApi (array $configArray) {
// Create a new instance
$apiInstance = new WernisApi();
- // Fix missing
- if (!isset($cfg['api_url'])) $cfg['api_url'] = self::$apiUrl;
+ // If not an api_url is given (e.g. on local development system)
+ if (!isset($configArray['api_url'])) {
+ // ... then set the productive URL
+ $configArray['api_url'] = self::$apiUrl;
+ }
// Konfiguration uebertragen
- $apiInstance->setCoonfigArray($cfg);
+ $apiInstance->setCoonfigArray($configArray);
// Return the instance
return $apiInstance;
* @param $w_pwd Clear password of the gamer
* @return void
*/
- public function setUser ($w_id, $w_pwd) {
+ public function setUser (int $w_id, string $w_pwd) {
// Set username (id)
$this->w_id = $w_id;
* The following methods are not yet rewritten! *
************************************************/
- public function einziehen ($amount) {
+ public function einziehen (int $amount) {
// amount auf Gueltigkeit pruefen
- $amount = isset($amount) ? $amount+0 : 0;
-
if ($amount < $this->config['mineinsatz']) {
$this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
return false;
return $this->executeWithdraw($amount);
}
- public function verschicken ($amount) {
+ public function verschicken (int $amount) {
// amount auf Gueltigkeit pruefen
- $amount = isset($amount) ? $amount+0 : 0;
-
if ($amount < $this->config['mineinsatz']) {
$this->setStatusMessage('low_stakes', sprintf('Dein Einsatz muss mindestens %d Wernis betragen.', $this->config['mineinsatz']));
return false;
}
// Sets a status message and code
- public function setStatusMessage ($msg, $status) {
+ public function setStatusMessage (string $msg, string $status) {
$this->statusArray['message'] = $msg;
$this->statusArray['status'] = $status;
}
}
// Sends out a request to the API and returns it's result
- private function sendRequest ($scriptName, array $requestData = array()) {
+ private function sendRequest (string $scriptName, array $requestData = []) {
// Is the requestData an array?
if (!is_array($requestData)) {
// Then abort here!
}
// Widthdraw this amount
- private function executeWithdraw ($amount) {
+ private function executeWithdraw (int $amount) {
// First all fails...
$result = false;
}
// Payout this amount
- private function executePayout ($amount) {
+ private function executePayout (int $amount) {
// First all fails...
$result = false;
}
// Send raw GET request
- private function sendRawRequest ($script) {
+ private function sendRawRequest (string $script) {
// Use the hostname from script URL as new hostname
$url = substr($script, 7);
$extract = explode('/', $url);