/**
  * Generating the per-menu-item configuration arrays based on the settings for item states (NO, RO, ACT, CUR etc) set in ->mconf (config for the current menu object)
  * Basically it will produce an individual array for each menu item based on the item states. BUT in addition the "optionSplit" syntax for the values is ALSO evaluated here so that all property-values are "option-splitted" and the output will thus be resolved.
  * Is called from the "generate" functions in the extension classes. The function is processor intensive due to the option split feature in particular. But since the generate function is not always called (since the ->result array may be cached, see makeMenu) it doesn't hurt so badly.
  *
  * @param integer $splitCount Number of menu items in the menu
  * @return array An array with two keys: array($NOconf,$ROconf) - where $NOconf contains the resolved configuration for each item when NOT rolled-over and $ROconf contains the ditto for the mouseover state (if any)
  * @access private
  * @todo Define visibility
  */
 public function procesItemStates($splitCount)
 {
     // Prepare normal settings
     if (!is_array($this->mconf['NO.']) && $this->mconf['NO']) {
         // Setting a blank array if NO=1 and there are no properties.
         $this->mconf['NO.'] = array();
     }
     $NOconf = $this->tmpl->splitConfArray($this->mconf['NO.'], $splitCount);
     // Prepare rollOver settings, overriding normal settings
     $ROconf = array();
     if ($this->mconf['RO']) {
         $ROconf = $this->tmpl->splitConfArray($this->mconf['RO.'], $splitCount);
     }
     // Prepare IFSUB settings, overriding normal settings
     // IFSUB is TRUE if there exist submenu items to the current item
     if ($this->mconf['IFSUB']) {
         // Flag: If $IFSUB is generated
         $IFSUBinit = 0;
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('IFSUB', $key)) {
                 // if this is the first IFSUB element, we must generate IFSUB.
                 if (!$IFSUBinit) {
                     $IFSUBconf = $this->tmpl->splitConfArray($this->mconf['IFSUB.'], $splitCount);
                     if ($this->mconf['IFSUBRO']) {
                         $IFSUBROconf = $this->tmpl->splitConfArray($this->mconf['IFSUBRO.'], $splitCount);
                     }
                     $IFSUBinit = 1;
                 }
                 // Substitute normal with ifsub
                 $NOconf[$key] = $IFSUBconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $IFSUBROconf[$key] ?: $IFSUBconf[$key];
                 }
             }
         }
     }
     // Prepare active settings, overriding normal settings
     if ($this->mconf['ACT']) {
         // Flag: If $ACT is generated
         $ACTinit = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('ACT', $key)) {
                 // If this is the first 'active', we must generate ACT.
                 if (!$ACTinit) {
                     $ACTconf = $this->tmpl->splitConfArray($this->mconf['ACT.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['ACTRO']) {
                         $ACTROconf = $this->tmpl->splitConfArray($this->mconf['ACTRO.'], $splitCount);
                     }
                     $ACTinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $ACTconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $ACTROconf[$key] ?: $ACTconf[$key];
                 }
             }
         }
     }
     // Prepare ACT (active)/IFSUB settings, overriding normal settings
     // ACTIFSUB is TRUE if there exist submenu items to the current item and the current item is active
     if ($this->mconf['ACTIFSUB']) {
         // Flag: If $ACTIFSUB is generated
         $ACTIFSUBinit = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('ACTIFSUB', $key)) {
                 // If this is the first 'active', we must generate ACTIFSUB.
                 if (!$ACTIFSUBinit) {
                     $ACTIFSUBconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUB.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['ACTIFSUBRO']) {
                         $ACTIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['ACTIFSUBRO.'], $splitCount);
                     }
                     $ACTIFSUBinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $ACTIFSUBconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $ACTIFSUBROconf[$key] ?: $ACTIFSUBconf[$key];
                 }
             }
         }
     }
     // Prepare CUR (current) settings, overriding normal settings
     // CUR is TRUE if the current page equals the item here!
     if ($this->mconf['CUR']) {
         // Flag: If $CUR is generated
         $CURinit = 0;
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('CUR', $key)) {
                 // if this is the first 'current', we must generate CUR. Basically this control is just inherited
                 // from the other implementations as current would only exist one time and thats it
                 // (unless you use special-features of HMENU)
                 if (!$CURinit) {
                     $CURconf = $this->tmpl->splitConfArray($this->mconf['CUR.'], $splitCount);
                     if ($this->mconf['CURRO']) {
                         $CURROconf = $this->tmpl->splitConfArray($this->mconf['CURRO.'], $splitCount);
                     }
                     $CURinit = 1;
                 }
                 // Substitute normal with current
                 $NOconf[$key] = $CURconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $CURROconf[$key] ?: $CURconf[$key];
                 }
             }
         }
     }
     // Prepare CUR (current)/IFSUB settings, overriding normal settings
     // CURIFSUB is TRUE if there exist submenu items to the current item and the current page equals the item here!
     if ($this->mconf['CURIFSUB']) {
         // Flag: If $CURIFSUB is generated
         $CURIFSUBinit = 0;
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('CURIFSUB', $key)) {
                 // If this is the first 'current', we must generate CURIFSUB.
                 if (!$CURIFSUBinit) {
                     $CURIFSUBconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUB.'], $splitCount);
                     // Prepare current rollOver settings, overriding normal current settings
                     if ($this->mconf['CURIFSUBRO']) {
                         $CURIFSUBROconf = $this->tmpl->splitConfArray($this->mconf['CURIFSUBRO.'], $splitCount);
                     }
                     $CURIFSUBinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $CURIFSUBconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the current
                 if ($ROconf) {
                     // If RollOver on current then apply this
                     $ROconf[$key] = $CURIFSUBROconf[$key] ?: $CURIFSUBconf[$key];
                 }
             }
         }
     }
     // Prepare active settings, overriding normal settings
     if ($this->mconf['USR']) {
         // Flag: If $USR is generated
         $USRinit = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('USR', $key)) {
                 // if this is the first active, we must generate USR.
                 if (!$USRinit) {
                     $USRconf = $this->tmpl->splitConfArray($this->mconf['USR.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['USRRO']) {
                         $USRROconf = $this->tmpl->splitConfArray($this->mconf['USRRO.'], $splitCount);
                     }
                     $USRinit = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $USRconf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $USRROconf[$key] ?: $USRconf[$key];
                 }
             }
         }
     }
     // Prepare spacer settings, overriding normal settings
     if ($this->mconf['SPC']) {
         // Flag: If $SPC is generated
         $SPCinit = 0;
         // Find spacers
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('SPC', $key)) {
                 // If this is the first spacer, we must generate SPC.
                 if (!$SPCinit) {
                     $SPCconf = $this->tmpl->splitConfArray($this->mconf['SPC.'], $splitCount);
                     $SPCinit = 1;
                 }
                 // Substitute normal with spacer
                 $NOconf[$key] = $SPCconf[$key];
             }
         }
     }
     // Prepare Userdefined settings
     if ($this->mconf['USERDEF1']) {
         // Flag: If $USERDEF1 is generated
         $USERDEF1init = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('USERDEF1', $key)) {
                 // If this is the first active, we must generate USERDEF1.
                 if (!$USERDEF1init) {
                     $USERDEF1conf = $this->tmpl->splitConfArray($this->mconf['USERDEF1.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['USERDEF1RO']) {
                         $USERDEF1ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF1RO.'], $splitCount);
                     }
                     $USERDEF1init = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $USERDEF1conf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $USERDEF1ROconf[$key] ?: $USERDEF1conf[$key];
                 }
             }
         }
     }
     // Prepare Userdefined settings
     if ($this->mconf['USERDEF2']) {
         // Flag: If $USERDEF2 is generated
         $USERDEF2init = 0;
         // Find active
         foreach ($NOconf as $key => $val) {
             if ($this->isItemState('USERDEF2', $key)) {
                 // If this is the first active, we must generate USERDEF2.
                 if (!$USERDEF2init) {
                     $USERDEF2conf = $this->tmpl->splitConfArray($this->mconf['USERDEF2.'], $splitCount);
                     // Prepare active rollOver settings, overriding normal active settings
                     if ($this->mconf['USERDEF2RO']) {
                         $USERDEF2ROconf = $this->tmpl->splitConfArray($this->mconf['USERDEF2RO.'], $splitCount);
                     }
                     $USERDEF2init = 1;
                 }
                 // Substitute normal with active
                 $NOconf[$key] = $USERDEF2conf[$key];
                 // If rollOver on normal, we must apply a state for rollOver on the active
                 if ($ROconf) {
                     // If RollOver on active then apply this
                     $ROconf[$key] = $USERDEF2ROconf[$key] ?: $USERDEF2conf[$key];
                 }
             }
         }
     }
     return array($NOconf, $ROconf);
 }
 /**
  * @test
  * @dataProvider splitConfDataProvider
  * @see https://docs.typo3.org/typo3cms/TyposcriptReference/ObjectsAndProperties/Index.html#objects-optionsplit
  */
 public function splitConfArraytest($configuration, $splitCount, $expected)
 {
     $actual = $this->templateService->splitConfArray($configuration, $splitCount);
     $this->assertSame($expected, $actual);
 }