protected function enrichRulesNew(
        array $customRules,
        array $generatedRules,
        $replace,
        array $excludeKeys,
        array $keepDefaultKeys,
        array $generatedRulesMap
    ) {
        // so use them as a starting point.
        // If custom rules are configured, they should not overwritten by form field rules,
        $result = $customRules;

        // Include any generated rules explicitly marked for inclusion.
        foreach ($keepDefaultKeys as $key) {
            if ( ! array_key_exists($key, $generatedRules)) {
                continue;
            }

            $result[ $key ] = $generatedRules[ $key ];
        }


        // If the generated rules are explicitly replaced default rules, we don't have to merge them.
        // Otherwise, append any form field defined rule that is
        // not yet included and not marked for exclusion.
        if ( ! $replace) {

            foreach ($generatedRulesMap as $fieldKey => $ruleKeys) {

                // The field key or any of its nested child rules keys may be disabled.
                // If the field key itself is excluded, find the mapped keys for that
                // field and exclude any of them.

                // So skip any set of rules belonging to a field whose key has
                // been excluded (as a rule key).
                if (in_array($fieldKey, $excludeKeys)) {
                    continue;
                }

                foreach ($ruleKeys as $key) {

                    // Skip if ..
                    if (
                        // .. the key is already included, or marked for exclusion
                            in_array($key, $excludeKeys)
                        ||  in_array($key, $keepDefaultKeys)
                        // .. the result array already has an entry for the key
                        ||  array_key_exists($key, $result)
                        // .. no generated rule exists for the key (safeguard)
                        ||  ! array_key_exists($key, $generatedRules)
                    ) {
                        continue;
                    }

                    $result[ $key ] = $generatedRules[ $key ];
                }
            }
        }

        $result = $this->getRuleMerger()->convertRequiredForTranslatedFields($result);

        return $this->castValidationRulesToArray($result);
    }
protected function enrichRulesNew(
        array $customRules,
        array $generatedRules,
        $replace,
        array $excludeKeys,
        array $keepDefaultKeys,
        array $generatedRulesMap
    ) {
        // so use them as a starting point.
        // If custom rules are configured, they should not overwritten by form field rules,
        $result = $customRules;

        // Include any generated rules explicitly marked for inclusion.
        foreach ($keepDefaultKeys as $key) {
            if ( ! array_key_exists($key, $generatedRules)) {
                continue;
            }

            $result[ $key ] = $generatedRules[ $key ];
        }


        // If the generated rules are explicitly replaced default rules, we don't have to merge them.
        // Otherwise, append any form field defined rule that is
        // not yet included and not marked for exclusion.
        if ( ! $replace) {

            foreach ($generatedRulesMap as $fieldKey => $ruleKeys) {

                // The field key or any of its nested child rules keys may be disabled.
                // If the field key itself is excluded, find the mapped keys for that
                // field and exclude any of them.

                // So skip any set of rules belonging to a field whose key has
                // been excluded (as a rule key).
                if (in_array($fieldKey, $excludeKeys)) {
                    continue;
                }

                foreach ($ruleKeys as $key) {

                    // Skip if ..
                    if (
                        // .. the key is already included, or marked for exclusion
                            in_array($key, $excludeKeys)
                        ||  in_array($key, $keepDefaultKeys)
                        // .. the result array already has an entry for the key
                        ||  array_key_exists($key, $result)
                        // .. no generated rule exists for the key (safeguard)
                        ||  ! array_key_exists($key, $generatedRules)
                    ) {
                        continue;
                    }

                    $result[ $key ] = $generatedRules[ $key ];
                }
            }
        }

        $result = $this->getRuleMerger()->convertRequiredForTranslatedFields($result);

        return $this->castValidationRulesToArray($result);
    }
protected function enrichRulesNew ( array $ customRules , array $ generatedRules , $ replace , array $ excludeKeys , array $ keepDefaultKeys , array $ generatedRulesMap ) { // so use them as a starting point. // If custom rules are configured, they should not overwritten by form field rules, $ result = $ customRules ; // Include any generated rules explicitly marked for inclusion. foreach ( $ keepDefaultKeys as $ key ) { if ( ! array_key_exists ( $ key , $ generatedRules ) ) { continue ; } $ result [ $ key ] = $ generatedRules [ $ key ] ; } // If the generated rules are explicitly replaced default rules, we don't have to merge them. // Otherwise, append any form field defined rule that is // not yet included and not marked for exclusion. if ( ! $ replace ) { foreach ( $ generatedRulesMap as $ fieldKey => $ ruleKeys ) { // The field key or any of its nested child rules keys may be disabled. // If the field key itself is excluded, find the mapped keys for that // field and exclude any of them. // So skip any set of rules belonging to a field whose key has // been excluded (as a rule key). if ( in_array ( $ fieldKey , $ excludeKeys ) ) { continue ; } foreach ( $ ruleKeys as $ key ) { // Skip if .. if ( // .. the key is already included, or marked for exclusion in_array ( $ key , $ excludeKeys ) || in_array ( $ key , $ keepDefaultKeys ) // .. the result array already has an entry for the key || array_key_exists ( $ key , $ result ) // .. no generated rule exists for the key (safeguard) || ! array_key_exists ( $ key , $ generatedRules ) ) { continue ; } $ result [ $ key ] = $ generatedRules [ $ key ] ; } } } $ result = $ this -> getRuleMerger ( ) -> convertRequiredForTranslatedFields ( $ result ) ; return $ this -> castValidationRulesToArray ( $ result ) ; }
Enriches rules and returns the enriched rules array.

@param array    $customRules         rules custom-defined in the configuration, normalized
@param array    $generatedRules      rules generated by the CMS, normalized
@param bool     $replace             whether to replace rules entirely (and not enricht non-present rules)
@param string[] $excludeKeys         keys for rules that should be excluded
@param string[] $keepDefaultKeys     keys for rules that should be kept as generated by default
@param array[]  $generatedRulesMap   the mapped rules per form field for generated rules
@return array
Enriches rules and returns the enriched rules array .