application/Espo/Core/Utils/Util.php
public static function unsetInArray(array $content, $unsets, $unsetParentEmptyArray = false)
    {
        if (empty($unsets)) {
            return $content;
        }

        if (is_string($unsets)) {
            $unsets = (array) $unsets;
        }

        foreach ($unsets as $rootKey => $unsetItem) {
            $unsetItem = is_array($unsetItem) ? $unsetItem : (array) $unsetItem;

            foreach ($unsetItem as $unsetString) {
                if (is_string($rootKey)) {
                    $unsetString = $rootKey . '.' . $unsetString;
                }

                $keyArr = explode('.', $unsetString);
                $keyChainCount = count($keyArr) - 1;

                $elem = &$content;

                $elementArr = [];
                $elementArr[] = &$elem;
                for ($i = 0; $i <= $keyChainCount; $i++) {

                    if (is_array($elem) && array_key_exists($keyArr[$i], $elem)) {
                        if ($i == $keyChainCount) {
                            unset($elem[$keyArr[$i]]);

                            if ($unsetParentEmptyArray) {
                                for ($j = count($elementArr); $j > 0; $j--) {
                                    $pointer =& $elementArr[$j];
                                    if (is_array($pointer) && empty($pointer)) {
                                        $previous =& $elementArr[$j - 1];
                                        unset($previous[$keyArr[$j - 1]]);
                                    }
                                }
                            }

                        } else if (is_array($elem[$keyArr[$i]])) {
                            $elem = &$elem[$keyArr[$i]];
                            $elementArr[] = &$elem;
                        }

                    }
                }
            }
        }

        return $content;
    }
public static function unsetInArray(array $content, $unsets, $unsetParentEmptyArray = false)
    {
        if (empty($unsets)) {
            return $content;
        }

        if (is_string($unsets)) {
            $unsets = (array) $unsets;
        }

        foreach ($unsets as $rootKey => $unsetItem) {
            $unsetItem = is_array($unsetItem) ? $unsetItem : (array) $unsetItem;

            foreach ($unsetItem as $unsetString) {
                if (is_string($rootKey)) {
                    $unsetString = $rootKey . '.' . $unsetString;
                }

                $keyArr = explode('.', $unsetString);
                $keyChainCount = count($keyArr) - 1;

                $elem = &$content;

                $elementArr = [];
                $elementArr[] = &$elem;
                for ($i = 0; $i <= $keyChainCount; $i++) {

                    if (is_array($elem) && array_key_exists($keyArr[$i], $elem)) {
                        if ($i == $keyChainCount) {
                            unset($elem[$keyArr[$i]]);

                            if ($unsetParentEmptyArray) {
                                for ($j = count($elementArr); $j > 0; $j--) {
                                    $pointer =& $elementArr[$j];
                                    if (is_array($pointer) && empty($pointer)) {
                                        $previous =& $elementArr[$j - 1];
                                        unset($previous[$keyArr[$j - 1]]);
                                    }
                                }
                            }

                        } else if (is_array($elem[$keyArr[$i]])) {
                            $elem = &$elem[$keyArr[$i]];
                            $elementArr[] = &$elem;
                        }

                    }
                }
            }
        }

        return $content;
    }
public static function unsetInArray ( array $ content , $ unsets , $ unsetParentEmptyArray = false ) { if ( empty ( $ unsets ) ) { return $ content ; } if ( is_string ( $ unsets ) ) { $ unsets = ( array ) $ unsets ; } foreach ( $ unsets as $ rootKey => $ unsetItem ) { $ unsetItem = is_array ( $ unsetItem ) ? $ unsetItem : ( array ) $ unsetItem ; foreach ( $ unsetItem as $ unsetString ) { if ( is_string ( $ rootKey ) ) { $ unsetString = $ rootKey . '.' . $ unsetString ; } $ keyArr = explode ( '.' , $ unsetString ) ; $ keyChainCount = count ( $ keyArr ) - 1 ; $ elem = & $ content ; $ elementArr = [ ] ; $ elementArr [ ] = & $ elem ; for ( $ i = 0 ; $ i <= $ keyChainCount ; $ i ++ ) { if ( is_array ( $ elem ) && array_key_exists ( $ keyArr [ $ i ] , $ elem ) ) { if ( $ i == $ keyChainCount ) { unset ( $ elem [ $ keyArr [ $ i ] ] ) ; if ( $ unsetParentEmptyArray ) { for ( $ j = count ( $ elementArr ) ; $ j > 0 ; $ j -- ) { $ pointer = & $ elementArr [ $ j ] ; if ( is_array ( $ pointer ) && empty ( $ pointer ) ) { $ previous = & $ elementArr [ $ j - 1 ] ; unset ( $ previous [ $ keyArr [ $ j - 1 ] ] ) ; } } } } else if ( is_array ( $ elem [ $ keyArr [ $ i ] ] ) ) { $ elem = & $ elem [ $ keyArr [ $ i ] ] ; $ elementArr [ ] = & $ elem ; } } } } } return $ content ; }
Unset content items defined in the unset.json

@param array $content
@param string | array $unsets in format
array(
'EntityName1' => array( 'unset1', 'unset2' ),
'EntityName2' => array( 'unset1', 'unset2' ),
)
OR
array('EntityName1.unset1', 'EntityName1.unset2', .....)
OR
'EntityName1.unset1'
@param bool $unsetParentEmptyArray - If unset empty parent array after unsets

@return array
Unset content items defined in the unset . json