AdminPageFrameworkLoader_AdminPage_Tool_Generator_Generator::validate PHP Метод

validate() публичный Метод

Validates the submitted form data.
С версии: 3.5.4
public validate ( $aInput, $aOldInput, $oAdminPage, $aSubmitInfo )
    public function validate($aInput, $aOldInput, $oAdminPage, $aSubmitInfo)
    {
        $_bVerified = true;
        $_aErrors = array();
        $aInput = $this->_sanitizeFieldValues($aInput, $oAdminPage);
        // the class prefix must not contain white spaces and some other characters not supported in PHP class names.
        preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $aInput['class_prefix'], $_aMatches);
        if ($aInput['class_prefix'] && empty($_aMatches)) {
            $_aErrors[$this->sSectionID]['class_prefix'] = __('The prefix must consist of alphanumeric with underscores.', 'admin-page-framework-loader');
            $_bVerified = false;
        }
        if (!$aInput['text_domain']) {
            $_aErrors[$this->sSectionID]['text_domain'] = __('The text domain cannot be empty.', 'admin-page-framework-loader');
            $_bVerified = false;
        }
        // An invalid value is found. Set a field error array and an admin notice and return the old values.
        if (!$_bVerified) {
            $oAdminPage->setFieldErrors($_aErrors);
            $oAdminPage->setSettingNotice(__('There was something wrong with your input.', 'admin-page-framework-loader'));
            return $aOldInput;
        }
        return $aInput;
    }