static function overrideArray( $siteAccess = false )
    {

        if ( $siteAccess === false and self::$overrideArrayCache !== null )
        {
            return self::$overrideArrayCache;
        }

        $bases = eZTemplateDesignResource::allDesignBases( $siteAccess );

        // fetch the override array from a specific siteacces
        if ( $siteAccess )
        {
            $overrideINI = eZSiteAccess::getIni( $siteAccess, 'override.ini' );
        }
        else
        {
            $overrideINI = eZINI::instance( 'override.ini' );
        }

        $designStartPath = eZTemplateDesignResource::designStartPath();

        // Generate match cache for all templates

        // Build arrays of available files, start with standard design and end with most prefered design
        $matchFileArray = array();

        $reverseBases = array_reverse( $bases );

        foreach ( $reverseBases as $base )
        {
            $templateResource = $base . '/templates';
            $sourceFileArray = eZDir::recursiveFindRelative( $templateResource, "",  "tpl" );
            foreach ( $sourceFileArray as $source )
            {
                $matchFileArray[$source]['base_dir'] = $templateResource;
                $matchFileArray[$source]['template'] = $source;
            }
        }

        // Load override templates
        $overrideSettingGroups = $overrideINI->groups();
        if ( isset( $GLOBALS['eZDesignOverrides'] ) )
        {
            $overrideSettingGroups = array_merge( $overrideSettingGroups, $GLOBALS['eZDesignOverrides'] );
        }

        foreach ( $overrideSettingGroups as $overrideName => $overrideSetting )
        {
            if( !isset( $overrideSetting['Source'] ) )
            {
                continue;
            }
            $overrideSource = "/" . $overrideSetting['Source'];
            $overrideMatchFile = $overrideSetting['MatchFile'];

            // Find the matching file in the available resources
            $triedFiles = array();
            $fileInfo = eZTemplateDesignResource::fileMatch( $bases, 'override/templates', $overrideMatchFile, $triedFiles );

            $resourceInUse = is_array( $fileInfo ) ? $fileInfo['resource'] : false;
            $overrideMatchFilePath = is_array( $fileInfo ) ? $fileInfo['path'] : false;

            // if the override template is not found
            // then we probably shouldn't use it
            // there should be added a check around the following code
            // if ( $overrideMatchFilePath )
            // {
            $customMatchArray = array();
            $customMatchArray['conditions'] = isset( $overrideSetting['Match'] ) ? $overrideSetting['Match'] : null;
            $customMatchArray['match_file'] = $overrideMatchFilePath;
            $customMatchArray['override_name'] = $overrideName;

            $matchFileArray[$overrideSource]['custom_match'][] = $customMatchArray;
            // }

            // if overriding a non-existing template
            // then we use the override template as main template
            // this code should probably be removed
            // because we should not allow an override if the main template is missing
            if ( $resourceInUse && !isset( $matchFileArray[$overrideSource]['base_dir'] ) )
            {
                $matchFileArray[$overrideSource]['base_dir'] = $resourceInUse;
                $matchFileArray[$overrideSource]['template'] = $overrideSource;
            }

            if ( ! $overrideMatchFilePath )
            {
                eZDebug::writeError( "Custom match file: path '$overrideMatchFile' not found in any resource. Check the template settings in settings/override.ini", __METHOD__ );
                eZDebug::writeError( implode( ', ', $triedFiles ), __METHOD__ . ' tried files' );
            }

        }

        if ( $siteAccess === false )
        {
            self::$overrideArrayCache = $matchFileArray;
        }

        return $matchFileArray;
    }