dpepbjp126917 2011-04-23 07:02
浏览 45
已采纳

在不使用chdir的情况下在SugarCRM模块中定义自己的REST API

I would like to define my own API to Sugar instances via a Module Loader module. How can I define my own SOAP/REST API in a SugarCRM module without using the chdir command?

In the documentation, the way it is explained, to extend the REST APIs in an upgrade-safe manner includes the chdir command: http://developers.sugarcrm.com/docs/OS/6.1/-docs-Developer_Guides-Sugar_Developer_Guide_6.1.0-Chapter%202%20Application%20Framework.html#9001337

However the chdir command is banned by installations that use Module Loader restrictions: http://developers.sugarcrm.com/wordpress/2009/08/14/module-loader-restrictions/

Having a chdir command in the code is not allowed when these restrictions are switched on, which is the case for example for Sugar on Demand instances.

Are there any other ways to define custom REST APIs? How can I add REST APIs to SugarCRM via using a module only? Thank you.

  • 写回答

2条回答 默认 最新

  • douqi3913 2011-04-28 06:30
    关注

    For those that will run into the same issue, I have found an adequate workaround.

    The file that defines the REST (or SOAP) API can be placed in the Sugar base path. That way a chdir isn't necessary. You can call it for example myapi.php:

    <?php
    $webservice_class = 'SugarRestService_v2_custom';
    $webservice_path = 'custom/myapi/v2/SugarRestService_v2_custom.php';
    $registry_class = 'registry_custom';
    $registry_path = 'custom/myapi/v2/registry_custom.php';
    $webservice_impl_class = 'SugarRestServiceImpl_v2_custom';
    $location = 'custom/myapi/v2/rest.php';
    require_once('service/core/webservice.php');
    

    Place the file into a special directory in your module, for example call it basepath. Then, in your manifest.php file you declare it like this:

    'copy' => array (
    0 => 
    array (
      'from' => '<basepath>/basepath',
      'to' => '.',
    ),
    ...
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度