protected function checkPageTypeOrEmpty(
        $fieldName,
        $canUseFlexforms,
        $sheet,
        $explanation,
        $typeCondition
    ) {
        $this->checkIfPidListOrEmpty(
            $fieldName,
            $canUseFlexforms,
            $sheet,
            $explanation
        );

        if ($this->objectToCheck->hasConfValueString($fieldName, $sheet)) {
            $pids = $this->objectToCheck->getConfValueString($fieldName, $sheet);

            $offendingPids = \Tx_Oelib_Db::selectColumnForMultiple(
                'uid',
                'pages',
                'uid IN (' . $pids . ') AND NOT (doktype' . $typeCondition . ')' .
                \Tx_Oelib_Db::enableFields('pages')
            );
            $dbResultCount = count($offendingPids);

            if ($dbResultCount > 0) {
                $pageIdPlural = ($dbResultCount > 1) ? 's' : '';
                $bePlural = ($dbResultCount > 1) ? 'are' : 'is';

                $message = 'The TS setup variable <strong>' .
                    $this->getTSSetupPath() . $fieldName .
                    '</strong> contains the page ID' . $pageIdPlural .
                    ' <strong>' . implode(',', $offendingPids) . '</strong> ' .
                    'which ' . $bePlural . ' of an incorrect page type. ' .
                    $explanation . '<br />';
                $this->setErrorMessageAndRequestCorrection(
                    $fieldName,
                    $canUseFlexforms,
                    $message
                );
            }
        }
    }