protected function prepare_policy($policyid, $versionid) {

        if ($versionid) {
            $this->policy = api::get_policy_version($versionid);

        } else {
            $this->policy = array_reduce(api::list_current_versions(), function ($carry, $current) use ($policyid) {
                if ($current->policyid == $policyid) {
                    return $current;
                }
                return $carry;
            });
        }

        if (empty($this->policy)) {
            throw new \moodle_exception('errorpolicyversionnotfound', 'tool_policy');
        }
    }
protected function prepare_policy($policyid, $versionid) {

        if ($versionid) {
            $this->policy = api::get_policy_version($versionid);

        } else {
            $this->policy = array_reduce(api::list_current_versions(), function ($carry, $current) use ($policyid) {
                if ($current->policyid == $policyid) {
                    return $current;
                }
                return $carry;
            });
        }

        if (empty($this->policy)) {
            throw new \moodle_exception('errorpolicyversionnotfound', 'tool_policy');
        }
    }
protected function prepare_policy ( $ policyid , $ versionid ) { if ( $ versionid ) { $ this -> policy = api :: get_policy_version ( $ versionid ) ; } else { $ this -> policy = array_reduce ( api :: list_current_versions ( ) , function ( $ carry , $ current ) use ( $ policyid ) { if ( $ current -> policyid == $ policyid ) { return $ current ; } return $ carry ; } ) ; } if ( empty ( $ this -> policy ) ) { throw new \ moodle_exception ( 'errorpolicyversionnotfound' , 'tool_policy' ) ; } }
Loads the policy version to display on the page.

@param int $policyid The policy id for this page.
@param int $versionid The version id to show. Empty tries to load the current one.
Loads the policy version to display on the page .