X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=framework%2Fmain%2Fclasses%2Fhelper%2Fclass_BaseHelper.php;h=67cd01e89179e2102a6dbc1424283e18ddf5b4f0;hb=6305d3a9d677845ba03079483afb4756764cb42c;hp=1ab249c50956c6eae75fcaa0b3af57583c682ece;hpb=2882b57ca6f372b822f96034ff2fe6aafd7daeb8;p=core.git diff --git a/framework/main/classes/helper/class_BaseHelper.php b/framework/main/classes/helper/class_BaseHelper.php index 1ab249c5..67cd01e8 100644 --- a/framework/main/classes/helper/class_BaseHelper.php +++ b/framework/main/classes/helper/class_BaseHelper.php @@ -7,14 +7,15 @@ use Org\Mxchange\CoreFramework\Factory\ObjectFactory; use Org\Mxchange\CoreFramework\Generic\FrameworkInterface; use Org\Mxchange\CoreFramework\Generic\NullPointerException; use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem; -use Org\Mxchange\CoreFramework\Registry\Registry; +use Org\Mxchange\CoreFramework\Registry\GenericRegistry; +use Org\Mxchange\CoreFramework\Utils\String\StringUtils; /** * A generic helper class with generic methods * * @author Roland Haeder * @version 0.0.0 - * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2017 Core Developer Team + * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2020 Core Developer Team * @license GNU GPL 3.0 or any newer version * @link http://www.shipsimu.org * @@ -50,12 +51,12 @@ abstract class BaseHelper extends BaseFrameworkSystem { /** * Array with groups */ - private $groups = array(); + private $groups = []; /** * Array with sub group */ - private $subGroups = array(); + private $subGroups = []; /** * Previously opened group @@ -85,7 +86,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $className Real name of the class * @return void */ - protected function __construct ($className) { + protected function __construct (string $className) { // Call parent constructor parent::__construct($className); } @@ -96,8 +97,8 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $newContent New content to add * @return void */ - protected final function addContent ($newContent) { - $this->content .= (string) trim($newContent) . PHP_EOL; + protected final function addContent (string $newContent) { + $this->content .= trim($newContent) . PHP_EOL; } /** @@ -106,9 +107,9 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $content Content to to the base * @return void */ - protected function addHeaderContent ($content) { + protected function addHeaderContent (string $content) { // Add the header content - $this->groups['header']['content'] = (string) trim($content); + $this->groups['header']['content'] = trim($content); } /** @@ -117,9 +118,9 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $content Content to to the base * @return void */ - protected function addFooterContent ($content) { + protected function addFooterContent (string $content) { // Add the footer content - $this->groups['footer']['content'] = (string) trim($content); + $this->groups['footer']['content'] = trim($content); } /** @@ -130,7 +131,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $newContent New content to add * @return void */ - protected final function addContentToPreviousGroup ($newContent) { + protected final function addContentToPreviousGroup (string $newContent) { // Check for sub/group if ($this->ifSubGroupOpenedPreviously()) { // Get sub group id @@ -175,7 +176,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $fieldName Name of the field to assign * @return void */ - public function assignField ($fieldName) { + public function assignField (string $fieldName) { // Get the value from value instance $fieldValue = $this->getValueField($fieldName); @@ -192,13 +193,13 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @todo Rewrite this method using a helper class for filtering data */ - public function assignFieldWithFilter ($fieldName, $filterMethod) { + public function assignFieldWithFilter (string $fieldName, string $filterMethod) { // Get the value $fieldValue = $this->getValueField($fieldName); //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'='.$fieldValue); // Now filter it through the value through the filter method - $filteredValue = call_user_func_array(array($this, 'doFilter' . self::convertToClassName($filterMethod)), array($fieldValue)); + $filteredValue = call_user_func_array(array($this, 'doFilter' . StringUtils::convertToClassName($filterMethod)), array($fieldValue)); // Assign it with a template variable $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $filteredValue); @@ -212,11 +213,11 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws NullPointerException If recovery of requested value instance failed */ - public function prefetchValueInstance ($registryKey, $extraKey = NULL) { + public function prefetchValueInstance (string $registryKey, string $extraKey = NULL) { //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('O:'.$registryKey.'/'.$extraKey); try { // Get the required instance - $this->valueInstance = Registry::getRegistry()->getInstance($registryKey); + $this->valueInstance = GenericRegistry::getRegistry()->getInstance($registryKey); } catch (NullPointerException $e) { // Not set in registry // @TODO Try to log it here @@ -227,7 +228,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { if (!is_null($extraKey)) { try { // Get the extra instance. - $this->extraInstance = Registry::getRegistry()->getInstance($extraKey); + $this->extraInstance = GenericRegistry::getRegistry()->getInstance($extraKey); } catch (NullPointerException $e) { // Try to create it $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance)); @@ -253,7 +254,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperGroupAlreadyCreatedException If the group was already created before */ - protected function openGroupByIdContent ($groupId, $content, $tag) { + protected function openGroupByIdContent (string $groupId, string $content, string $tag) { //* DEBUG: */ echo "OPEN:groupId={$groupId},content=
".htmlentities($content)."
\n"; // Is the group already there? if (isset($this->groups[$groupId])) { @@ -288,7 +289,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found */ - public function closePreviousGroupByContent ($content = '') { + public function closePreviousGroupByContent (string $content = '') { // Check if any sub group was opened before if ($this->ifSubGroupOpenedPreviously()) { // Close it automatically @@ -340,7 +341,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before */ - protected function openSubGroupByIdContent ($subGroupId, $content, $tag) { + protected function openSubGroupByIdContent (string $subGroupId, string $content, string $tag) { //* DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."
\n"; // Is the group already there? if (isset($this->subGroups[$subGroupId])) { @@ -369,7 +370,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return void * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found */ - public function closePreviousSubGroupByContent ($content = '') { + public function closePreviousSubGroupByContent (string $content = '') { // Check if any sub group was opened before if ($this->ifSubGroupOpenedPreviously() === false) { // Then throw an exception @@ -449,7 +450,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $groupId Id of group to check * @return $isOpened Whether the specified group is open */ - protected function ifGroupIsOpened ($groupId) { + protected function ifGroupIsOpened (string $groupId) { // Is the group open? $isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === true)); @@ -464,7 +465,7 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @return $fieldValue Value from field * @throws NullPointerException Thrown if $valueInstance is null */ - public function getValueField ($fieldName) { + public function getValueField (string $fieldName) { // Init value $fieldValue = NULL; @@ -485,8 +486,8 @@ abstract class BaseHelper extends BaseFrameworkSystem { //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!'); } else { // Field is not set - $this->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] fieldName=' . $fieldName . ' is not set! - @TODO'); - } // END - if + $this->debugOutput('BASE-HELPER: fieldName=' . $fieldName . ' is not set! - @TODO'); + } // Return it return $fieldValue; @@ -536,8 +537,8 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $previousGroupId Id of previously opened group * @return void */ - protected final function setPreviousGroupId ($previousGroupId) { - $this->previousGroupId = (string) $previousGroupId; + protected final function setPreviousGroupId (string $previousGroupId) { + $this->previousGroupId = $previousGroupId; } /** @@ -555,8 +556,8 @@ abstract class BaseHelper extends BaseFrameworkSystem { * @param $previousSubGroupId Id of previously opened sub group * @return void */ - protected final function setPreviousSubGroupId ($previousSubGroupId) { - $this->previousSubGroupId = (string) $previousSubGroupId; + protected final function setPreviousSubGroupId (string $previousSubGroupId) { + $this->previousSubGroupId = $previousSubGroupId; } }