3 namespace Org\Mxchange\CoreFramework\Helper;
5 // Import framework stuff
6 use Org\Mxchange\CoreFramework\Factory\Object\ObjectFactory;
7 use Org\Mxchange\CoreFramework\Generic\FrameworkInterface;
8 use Org\Mxchange\CoreFramework\Generic\NullPointerException;
9 use Org\Mxchange\CoreFramework\Object\BaseFrameworkSystem;
10 use Org\Mxchange\CoreFramework\Registry\Object\ObjectRegistry;
11 use Org\Mxchange\CoreFramework\Utils\Strings\StringUtils;
14 use \BasMethodCallException;
15 use \InvalidArgumentException;
18 * A generic helper class with generic methods
20 * @author Roland Haeder <webmaster@shipsimu.org>
22 * @copyright Copyright (c) 2007, 2008 Roland Haeder, 2009 - 2023 Core Developer Team
23 * @license GNU GPL 3.0 or any newer version
24 * @link http://www.shipsimu.org
26 * This program is free software: you can redistribute it and/or modify
27 * it under the terms of the GNU General Public License as published by
28 * the Free Software Foundation, either version 3 of the License, or
29 * (at your option) any later version.
31 * This program is distributed in the hope that it will be useful,
32 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public License
37 * along with this program. If not, see <http://www.gnu.org/licenses/>.
39 abstract class BaseHelper extends BaseFrameworkSystem {
41 * Instance to the class which provides field values
43 private $valueInstance = NULL;
46 * Extra instance to the class which provides field values
48 private $extraInstance = NULL;
51 * Rendered content created by the helper class
53 private $content = '';
61 * Array with sub group
63 private $subGroups = [];
66 * Previously opened group
68 private $previousGroupId = '';
71 * Previously opened sub group
73 private $previousSubGroupId = '';
76 * Total counter for groups and sub groups
78 private $totalCounter = 0;
80 // Exception constants
81 const EXCEPTION_GROUP_NOT_OPENED = 0x1e0;
82 const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e1;
83 const EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED = 0x1e2;
84 const EXCEPTION_NO_PREVIOUS_GROUP_OPENED = 0x1e3;
87 * Protected constructor
89 * @param $className Real name of the class
92 protected function __construct (string $className) {
93 // Call parent constructor
94 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: className=%s - CONSTRUCTED!', $className));
95 parent::__construct($className);
98 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
102 * Adds content directly
104 * @param $newContent New content to add
106 * @throws InvalidArgumentException If a parameter has an invalid value
108 protected final function addContent (string $newContent) {
110 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: newContent=%s - CALLED!', $newContent));
111 if (empty(trim($newContent))) {
113 throw new InvalidArgumentException('Parameter "newContent" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
116 // Append content with EOL
117 $this->content .= trim($newContent) . PHP_EOL;
120 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: this->content()=%d - EXIT!', strlen($this->content)));
124 * Add header content to the helper
126 * @param $content Content to to the base
128 * @throws InvalidArgumentException If a parameter has an invalid value
130 protected function addHeaderContent (string $content) {
132 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: content=%s - CALLED!', $content));
133 if (empty(trim($content))) {
135 throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
138 // Add the header content
139 $this->groups['header']['content'] = trim($content);
142 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
146 * Add footer content to the helper
148 * @param $content Content to to the base
150 * @throws InvalidArgumentException If a parameter has an invalid value
152 protected function addFooterContent (string $content) {
154 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage(sprintf('BASE-HELPER: content=%s - CALLED!', $content));
155 if (empty(trim($content))) {
157 throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
160 // Add the footer content
161 $this->groups['footer']['content'] = trim($content);
164 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->traceMessage('BASE-HELPER: EXIT!');
168 * Adds content to the previously opened group or sub group. If a sub group
169 * was found it will be taken. If no group/sub group is opened at the moment
170 * the code will be passed to addContent().
172 * @param $newContent New content to add
174 * @throws InvalidArgumentException If a parameter has an invalid value
176 protected final function addContentToPreviousGroup (string $newContent) {
177 // Check on parameter
178 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: newContent=%s - CALLED!', $newContent));
179 if (empty($newContent)) {
181 throw new InvalidArgumentException('Parameter "newContent" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
184 // Check for sub/group
185 if ($this->ifSubGroupOpenedPreviously()) {
187 $subGroupId = $this->getPreviousSubGroupId();
190 $this->subGroups[$subGroupId]['content'] .= $newContent;
191 } elseif ($this->ifGroupOpenedPreviously()) {
193 $groupId = $this->getPreviousGroupId();
196 $this->groups[$groupId]['content'] .= $newContent;
199 $this->addContent($newContent);
203 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
209 * @return $content The rendered content by this helper
211 protected final function getContent () {
212 return $this->content;
216 * Public setter for extra instance
218 * @param $extraInstance An extra instance of FrameworkInterface to set
221 public final function setExtraInstance (FrameworkInterface $extraInstance) {
222 $this->extraInstance = $extraInstance;
226 * Assigns a field from the value instance with a template variable
228 * @param $fieldName Name of the field to assign
230 * @throws InvalidArgumentException If a parameter has an invalid value
232 public function assignField (string $fieldName) {
233 // Check on parameter
234 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s - CALLED!', $fieldName));
235 if (empty($fieldName)) {
237 throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
240 // Get the value from value instance
241 $fieldValue = $this->getValueField($fieldName);
243 // Assign it with a template variable
244 $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $fieldValue);
247 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
251 * Assigns a field from the value instance with a template variable but
252 * parses its content through a given filter method of the value instance
254 * @param $fieldName Name of the field to assign
255 * @param $filterMethod Method name to call of the value instance
257 * @throws InvalidArgumentException If a parameter has an invalid value
258 * @todo Rewrite this method using a helper class for filtering data
260 public function assignFieldWithFilter (string $fieldName, string $filterMethod) {
261 // Validate parameter
262 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s,filterMethod=%s - CALLED!', $fieldName, $filterMethod));
263 if (empty($fieldName)) {
265 throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
266 } elseif (empty($filterMethod)) {
268 throw new InvalidArgumentException('Parameter "filterMethod" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
272 $fieldValue = $this->getValueField($fieldName);
274 // Now filter it through the value through the filter method
275 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: %s[%s]=%s', $fieldName, gettype($fieldValue), $fieldValue));
276 $filteredValue = call_user_func_array(array($this, 'doFilter' . StringUtils::convertToClassName($filterMethod)), array($fieldValue));
278 // Assign it with a template variable
279 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: filteredValue[%s]=%s', gettype($filteredValue), $filteredValue));
280 $this->getTemplateInstance()->assignVariable('block_' . $fieldName, $filteredValue);
283 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
287 * Pre-fetches field default values from the given registry key instance into this class
289 * @param $registryKey Registry key which holds an object with values
290 * @param $extraKey Extra value instance key used if registryKey is null
292 * @throws InvalidArgumentException If a parameter has an invalid value
294 public function prefetchValueInstance (string $registryKey, string $extraKey = NULL) {
295 // Validate parameter
296 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: registryKey=%s,extraKey[%s]=%s - CALLED!', $registryKey, gettype($extraKey), $extraKey));
297 if (empty($registryKey)) {
299 throw new InvalidArgumentException('Parameter "registryKey" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
303 // Get the required instance
304 $this->valueInstance = ObjectRegistry::getRegistry('generic')->getInstance($registryKey);
305 } catch (NullPointerException $e) {
306 // Not set in registry
307 //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: registryKey=%s returned no instance (NPE thrown)', $registryKey));
310 // Shall we get an extra instance?
311 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey[%s]=%s', gettype($extraKey), $extraKey));
312 if (!is_null($extraKey)) {
314 // Get the extra instance.
315 $this->extraInstance = ObjectRegistry::getRegistry('generic')->getInstance($extraKey);
316 } catch (NullPointerException $e) {
318 //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey=%s returned no instance (NPE thrown), this->valueInstance[]=%s', $extraKey, gettype($this->valueInstance)));
319 $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', [$this->valueInstance]);
321 //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: extraKey=%s,this->extraInstance[%s]=%s', $extraKey, gettype($this->extraInstance), $this->extraInstance));
324 // Is the value instance valid?
325 //* NOSIY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->valueInstance[]=%s - BEFORE!', gettype($this->valueInstance)));
326 if (is_null($this->valueInstance)) {
327 // Get the requested instance
328 $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance));
332 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->valueInstance[]=%s - AFTER/EXIT!', gettype($this->valueInstance)));
336 * Opens a helper group with given group id and content or throws an
337 * exception if that group is already found regardless if it is open or
340 * @param $groupId Group id to open
341 * @param $content Initial content to add to the group
342 * @param $tag HTML tag used to open this group
344 * @throws InvalidArgumentException If a parameter has an invalid value
345 * @throws BadMethodCallException If the group was already created before
347 protected function openGroupByIdContent (string $groupId, string $content, string $tag) {
348 // Is the group already there?
349 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: groupdId=%s,content=%s,tag=%s - CALLED!', $groupdId, $content, $tag));
350 if (empty($groupId)) {
352 throw new InvalidArgumentException('Parameter "groupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
353 } elseif (isset($this->groups[$groupId])) {
354 // Then throw an exception here
355 throw new BadMethodCallException(sprintf('[%s:%d]: groupId=%s is already opened.', $this->__toString(), $groupId), FrameworkInterface::EXCEPTION_BAD_METHOD_CALL);
356 } elseif (empty($content)) {
358 throw new InvalidArgumentException('Parameter "content" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
359 } elseif (empty($tag)) {
361 throw new InvalidArgumentException('Parameter "tag" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
365 $this->totalCounter++;
367 // Add the group to the stack
368 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: this->totalCounter=%d', $this->totalCounter));
369 $this->groups[$this->totalCounter] = $groupId;
370 $this->groups[$groupId]['opened'] = true;
371 $this->groups[$groupId]['content'] = sprintf(
372 '<!-- group %s opened (length: %s, tag: %s) //-->%s' . PHP_EOL,
378 $this->groups[$groupId]['tag'] = $tag;
380 // Mark this group as previously opened
381 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: Setting this->previousGroupId=%s ...', $groupId));
382 $this->setPreviousGroupId($groupId);
385 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('BASE-HELPER: EXIT!');
389 * Closes the previously opened group by added given content to it or
390 * throws an exception if no previous group was opened
392 * @param $content Content for previously opened group, or empty to use tag of opener
394 * @throws HelperNoPreviousOpenedGroupException If no previously opened group was found
396 public function closePreviousGroupByContent (string $content = '') {
397 // Check if any sub group was opened before
398 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: content(%d)=%s - CALLED!', strlen($content), $content));
399 if ($this->ifSubGroupOpenedPreviously()) {
400 // Close it automatically
401 $this->closePreviousSubGroupByContent();
404 // Check if any group was opened before
405 if ($this->ifGroupOpenedPreviously() === false) {
406 // Then throw an exception
407 throw new HelperNoPreviousOpenedGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
410 // Get previous group
411 $groupId = $this->getPreviousGroupId();
413 // Is the content empty?
414 if ((empty($content)) && (!empty($this->groups[$groupId]['tag']))) {
415 // Get it from opener
417 "<!-- group %s auto-closed //--></%s>",
419 $this->groups[$groupId]['tag']
423 // Add content to it and mark it as closed
424 $this->groups[$groupId]['content'] .= sprintf(
425 "<!-- group %s closed (length: %s, tag: %s) //-->%s\n",
428 $this->groups[$groupId]['tag'],
431 $this->groups[$groupId]['opened'] = false;
433 // Mark previous group as closed
434 $this->setPreviousGroupId('');
435 //* NOISY-DEBUG: */ echo "CLOSE:groupId={$groupId}<br />\n";
439 * Opens a helper sub group with given group id and content or throws an
440 * exception if that sub group is already found regardless if it is open or
443 * @param $subGroupId Sub group id to open
444 * @param $content Initial content to add to the sub group
445 * @param $tag HTML tag used to open this group
447 * @throws HelperSubGroupAlreadyCreatedException If the sub group was already created before
449 protected function openSubGroupByIdContent (string $subGroupId, string $content, string $tag) {
450 //* NOISY-DEBUG: */ echo "OPEN:subGroupId={$subGroupId},content=".htmlentities($content)."<br />\n";
451 // Is the group already there?
452 if (empty($subGroupId)) {
454 throw new InvalidArgumentException('Parameter "subGroupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
455 } elseif (isset($this->subGroups[$subGroupId])) {
456 // Then throw an exception here
457 throw new HelperSubGroupAlreadyCreatedException(array($this, $subGroupId), self::EXCEPTION_SUB_GROUP_ALREADY_FOUND);
461 $this->totalCounter++;
463 // Add the group to the stack
464 $this->subGroups[$this->totalCounter] = $subGroupId;
465 $this->subGroups[$subGroupId]['opened'] = true;
466 $this->subGroups[$subGroupId]['content'] = sprintf("<!-- sub-group %s opened (length: %s, tag: %s) //-->%s\n", $subGroupId, strlen($content), $tag, $content);
467 $this->subGroups[$subGroupId]['tag'] = $tag;
469 // Mark this group as previously opened
470 $this->setPreviousSubGroupId($subGroupId);
474 * Closes the previously opened sub group by added given content to it or
475 * throws an exception if no previous sub group was opened
477 * @param $content Content for previously opened sub group, or leave empty to use div/span of openener
479 * @throws HelperNoPreviousOpenedSubGroupException If no previously opened sub group was found
481 public function closePreviousSubGroupByContent (string $content = '') {
482 // Check if any sub group was opened before
483 if ($this->ifSubGroupOpenedPreviously() === false) {
484 // Then throw an exception
485 throw new HelperNoPreviousOpenedSubGroupException(array($this, $content), self::EXCEPTION_NO_PREVIOUS_SUB_GROUP_OPENED);
488 // Get previous sub group
489 $subGroupId = $this->getPreviousSubGroupId();
491 // Is the content empty?
492 if ((empty($content)) && (!empty($this->subGroups[$subGroupId]['tag']))) {
493 // Get it from opener
494 $content = sprintf('<!-- sub-group %s auto-closed //--></%s>', $subGroupId, $this->subGroups[$subGroupId]['tag']);
497 // Add content to it and mark it as closed
498 $this->subGroups[$subGroupId]['content'] .= sprintf('<!-- sub-group %s closed (length: %s, tag: %s) //-->%s' . PHP_EOL, $subGroupId, strlen($content), $this->subGroups[$subGroupId]['tag'], $content);
499 $this->subGroups[$subGroupId]['opened'] = false
502 // Mark previous sub group as closed
503 $this->setPreviousSubGroupId('');
504 //* NOISY-DEBUG: */ echo "CLOSE:subGroupId={$subGroupId}<br />\n";
508 * Renders all group and sub group in their order
510 * @return $content Rendered HTML content
512 public function renderContent () {
513 // Initialize content
516 // Is header content there?
517 if (isset($this->groups['header'])) {
519 $content .= $this->groups['header']['content'] . PHP_EOL;
523 $content .= $this->getContent();
525 // Now "walk" through all groups and sub-groups
526 for ($idx = 1; $idx <= $this->totalCounter; $idx++) {
527 // Is this a sub/group and is it closed?
528 if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) {
529 // Then add it's content
530 $groupContent = trim($this->groups[$this->groups[$idx]]['content']);
531 //* NOISY-DEBUG: */ echo "group={$this->groups[$idx]},content=<pre>".htmlentities($groupContent)."</pre><br />\n";
532 $content .= $groupContent;
533 } elseif ((isset($this->subGroups[$idx])) && ($this->subGroups[$this->subGroups[$idx]]['opened'] === false)) {
534 // Then add it's content
535 $subGroupContent = $this->subGroups[$this->subGroups[$idx]]['content'];
536 //* NOISY-DEBUG: */ echo "subgroup={$this->subGroups[$idx]},content=<pre>".htmlentities($subGroupContent)."</pre><br />\n";
537 $content .= trim($subGroupContent);
539 // Something went wrong
540 $this->debugInstance(__METHOD__ . '(): Something unexpected happened here.');
544 // Is footer content there?
545 if (isset($this->groups['footer'])) {
547 $content .= $this->groups['footer']['content'] . PHP_EOL;
551 //* NOISY-DEBUG: */ echo "content=<pre>".htmlentities($content)."</pre> (".strlen($content).")<br />\n";
556 * Checks whether the specified group is opened
558 * @param $groupId Id of group to check
559 * @return $isOpened Whether the specified group is open
560 * @throws InvalidArgumentException If a parameter has an invalid value
562 protected function ifGroupIsOpened (string $groupId) {
563 // Check on parameter
564 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: groupId=%s - CALLED!', $groupId));
565 if (empty($groupId)) {
567 throw new InvalidArgumentException('Parameter "groupId" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
570 // Is the group open?
571 $isOpened = ((isset($this->groups[$groupId])) && ($this->groups[$groupId]['opened'] === true));
574 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: isOpened=%d - EXIT!', intval($isOpened)));
579 * Getter for direct field values
581 * @param $fieldName Name of the field we shall fetch
582 * @return $fieldValue Value from field
583 * @throws InvalidArgumentException If a parameter has an invalid value
584 * @throws NullPointerException Thrown if $valueInstance is null
586 public function getValueField (string $fieldName) {
588 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldName=%s - CALLED!', $fieldName));
589 if (empty($fieldName)) {
591 throw new InvalidArgumentException('Parameter "fieldName" is empty', FrameworkInterface::EXCEPTION_INVALID_ARGUMENT);
597 // The $valueInstance attribute should not be null!
598 if (is_null($this->getValueInstance())) {
599 // Throws an exception here
600 throw new NullPointerException($this, FrameworkInterface::EXCEPTION_IS_NULL_POINTER);
604 if ($this->getValueInstance()->isFieldSet($fieldName)) {
605 // Get the field value
606 $fieldValue = $this->getValueInstance()->getField($fieldName);
607 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Value instance!');
608 } elseif ((!is_null($this->extraInstance)) && ($this->extraInstance->isFieldSet($fieldName))) {
609 // So try the extra instance
610 $fieldValue = $this->extraInstance->getField($fieldName);
611 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).') - Extra instance!');
614 $this->debugOutput('BASE-HELPER: fieldName=' . $fieldName . ' is not set! - @TODO');
618 //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('BASE-HELPER: fieldValue[%s]=%s - EXIT!', gettype($fieldValue), $fieldValue));
623 * Getter for value instance
625 * @return $valueInstance Instance of the class holding our values
627 public final function getValueInstance () {
628 return $this->valueInstance;
632 * Check whether a group was opened previously
634 * @return $groupOpened Whether any group was opened before
636 protected final function ifGroupOpenedPreviously () {
637 $groupOpened = (!empty($this->previousGroupId));
642 * Check whether a group was opened previously
644 * @return $subGroupOpened Whether any group was opened before
646 protected final function ifSubGroupOpenedPreviously () {
647 $subGroupOpened = (!empty($this->previousSubGroupId));
648 return $subGroupOpened;
652 * Getter for previous group id
654 * @return $previousGroupId Id of previously opened group
656 protected final function getPreviousGroupId () {
657 return $this->previousGroupId;
661 * Setter for previous group id
663 * @param $previousGroupId Id of previously opened group
666 protected final function setPreviousGroupId (string $previousGroupId) {
667 $this->previousGroupId = $previousGroupId;
671 * Getter for previous sub group id
673 * @return $previousSubGroupId Id of previously opened sub group
675 protected final function getPreviousSubGroupId () {
676 return $this->previousSubGroupId;
680 * Setter for previous sub group id
682 * @param $previousSubGroupId Id of previously opened sub group
685 protected final function setPreviousSubGroupId (string $previousSubGroupId) {
686 $this->previousSubGroupId = $previousSubGroupId;