public static function create_tool_proxy($name, $registrationurl, $capabilityoffered, $serviceoffered) {
        $params = self::validate_parameters(self::create_tool_proxy_parameters(),
                                            array(
                                                'name' => $name,
                                                'regurl' => $registrationurl,
                                                'capabilityoffered' => $capabilityoffered,
                                                'serviceoffered' => $serviceoffered
                                            ));
        $name = $params['name'];
        $regurl = $params['regurl'];
        $capabilityoffered = $params['capabilityoffered'];
        $serviceoffered = $params['serviceoffered'];

        $context = context_system::instance();
        self::validate_context($context);
        require_capability('moodle/site:config', $context);

        // Can't create duplicate proxies with the same URL.
        $duplicates = lti_get_tool_proxies_from_registration_url($registrationurl);
        if (!empty($duplicates)) {
            throw new moodle_exception('duplicateregurl', 'mod_lti');
        }

        $config = new stdClass();
        $config->lti_registrationurl = $registrationurl;

        if (!empty($name)) {
            $config->lti_registrationname = $name;
        }

        if (!empty($capabilityoffered)) {
            $config->lti_capabilities = $capabilityoffered;
        }

        if (!empty($serviceoffered)) {
            $config->lti_services = $serviceoffered;
        }

        $id = lti_add_tool_proxy($config);
        $toolproxy = lti_get_tool_proxy($id);

        // Pending makes more sense than configured as the first state, since
        // the next step is to register, which requires the state be pending.
        $toolproxy->state = LTI_TOOL_PROXY_STATE_PENDING;
        lti_update_tool_proxy($toolproxy);

        return $toolproxy;
    }
public static function create_tool_proxy($name, $registrationurl, $capabilityoffered, $serviceoffered) {
        $params = self::validate_parameters(self::create_tool_proxy_parameters(),
                                            array(
                                                'name' => $name,
                                                'regurl' => $registrationurl,
                                                'capabilityoffered' => $capabilityoffered,
                                                'serviceoffered' => $serviceoffered
                                            ));
        $name = $params['name'];
        $regurl = $params['regurl'];
        $capabilityoffered = $params['capabilityoffered'];
        $serviceoffered = $params['serviceoffered'];

        $context = context_system::instance();
        self::validate_context($context);
        require_capability('moodle/site:config', $context);

        // Can't create duplicate proxies with the same URL.
        $duplicates = lti_get_tool_proxies_from_registration_url($registrationurl);
        if (!empty($duplicates)) {
            throw new moodle_exception('duplicateregurl', 'mod_lti');
        }

        $config = new stdClass();
        $config->lti_registrationurl = $registrationurl;

        if (!empty($name)) {
            $config->lti_registrationname = $name;
        }

        if (!empty($capabilityoffered)) {
            $config->lti_capabilities = $capabilityoffered;
        }

        if (!empty($serviceoffered)) {
            $config->lti_services = $serviceoffered;
        }

        $id = lti_add_tool_proxy($config);
        $toolproxy = lti_get_tool_proxy($id);

        // Pending makes more sense than configured as the first state, since
        // the next step is to register, which requires the state be pending.
        $toolproxy->state = LTI_TOOL_PROXY_STATE_PENDING;
        lti_update_tool_proxy($toolproxy);

        return $toolproxy;
    }
public static function create_tool_proxy ( $ name , $ registrationurl , $ capabilityoffered , $ serviceoffered ) { $ params = self :: validate_parameters ( self :: create_tool_proxy_parameters ( ) , array ( 'name' => $ name , 'regurl' => $ registrationurl , 'capabilityoffered' => $ capabilityoffered , 'serviceoffered' => $ serviceoffered ) ) ; $ name = $ params [ 'name' ] ; $ regurl = $ params [ 'regurl' ] ; $ capabilityoffered = $ params [ 'capabilityoffered' ] ; $ serviceoffered = $ params [ 'serviceoffered' ] ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; require_capability ( 'moodle/site:config' , $ context ) ; // Can't create duplicate proxies with the same URL. $ duplicates = lti_get_tool_proxies_from_registration_url ( $ registrationurl ) ; if ( ! empty ( $ duplicates ) ) { throw new moodle_exception ( 'duplicateregurl' , 'mod_lti' ) ; } $ config = new stdClass ( ) ; $ config -> lti_registrationurl = $ registrationurl ; if ( ! empty ( $ name ) ) { $ config -> lti_registrationname = $ name ; } if ( ! empty ( $ capabilityoffered ) ) { $ config -> lti_capabilities = $ capabilityoffered ; } if ( ! empty ( $ serviceoffered ) ) { $ config -> lti_services = $ serviceoffered ; } $ id = lti_add_tool_proxy ( $ config ) ; $ toolproxy = lti_get_tool_proxy ( $ id ) ; // Pending makes more sense than configured as the first state, since // the next step is to register, which requires the state be pending. $ toolproxy -> state = LTI_TOOL_PROXY_STATE_PENDING ; lti_update_tool_proxy ( $ toolproxy ) ; return $ toolproxy ; }
Creates a new tool proxy

@param string $name Tool proxy name
@param string $registrationurl Registration url
@param string[] $capabilityoffered List of capabilities this tool proxy should be offered
@param string[] $serviceoffered List of services this tool proxy should be offered
@return object The new tool proxy
@since Moodle 3.1
@throws moodle_exception
Creates a new tool proxy