public function get_definitions_by_store($storename) {
        $definitions = array();

        // This function was accidentally made static at some stage in the past.
        // It was converted to an instance method but to be backwards compatible
        // we must step around this in code.
        if (!isset($this)) {
            $config = cache_config::instance();
        } else {
            $config = $this;
        }

        $stores = $config->get_all_stores();
        if (!array_key_exists($storename, $stores)) {
            // The store does not exist.
            return false;
        }

        $defmappings = $config->get_definition_mappings();
        // Create an associative array for the definition mappings.
        $thedefmappings = array();
        foreach ($defmappings as $defmapping) {
            $thedefmappings[$defmapping['definition']] = $defmapping;
        }

        // Search for matches in default mappings.
        $defs = $config->get_definitions();
        foreach($config->get_mode_mappings() as $modemapping) {
            if ($modemapping['store'] !== $storename) {
                continue;
            }
            foreach($defs as $id => $definition) {
                if ($definition['mode'] !== $modemapping['mode']) {
                    continue;
                }
                // Exclude custom definitions mapping: they will be managed few lines below.
                if (array_key_exists($id, $thedefmappings)) {
                    continue;
                }
                $definitions[$id] = $definition;
            }
        }

        // Search for matches in the custom definitions mapping
        foreach ($defmappings as $defmapping) {
            if ($defmapping['store'] !== $storename) {
                continue;
            }
            $definition = $config->get_definition_by_id($defmapping['definition']);
            if ($definition) {
                $definitions[$defmapping['definition']] = $definition;
            }
        }

        return $definitions;
    }