public static function get_overrides_for_purpose(purpose $purpose) : array {
        $cache = \cache::make('tool_dataprivacy', 'purpose_overrides');

        $overrides = [];
        $alldata = $cache->get($purpose->get('id'));
        if (false === $alldata) {
            $tocache = [];
            foreach (self::get_records(['purposeid' => $purpose->get('id')]) as $override) {
                $tocache[] = $override->to_record();
                $overrides[$override->get('roleid')] = $override;
            }
            $cache->set($purpose->get('id'), $tocache);
        } else {
            foreach ($alldata as $data) {
                $override = new self(0, $data);
                $overrides[$override->get('roleid')] = $override;
            }
        }

        return $overrides;
    }