SugarCRM自定義入口點


自定義入口點(探討請加微信:JiangHuKeyKe)

概述

如何創建自定義入口點。

創建自定義入口點

在 6.3.x, 可以使用擴展框架創建入口點。入口點擴展目錄位於./custom/Extension/application/Ext/EntryPointRegistry/。找到的入口點文件經過快速修復和重建將被編譯成 ./custom/application/Ext/EntryPointRegistry/entry_point_registry.ext.php 。在6.3.x 之前, 通過創建文件添加入口點./custom/include/MVC/Controller/entry_point_registry.php。創建入口點的方法仍然是兼容的, 但不是推薦的做法。

入口點註冊表包含兩個屬性:

  • file - 指向入口點的路徑。
  • auth - 一個布爾值,用來確定用戶是否必須通過身份驗證來訪問入口點。
$entry_point_registry['customEntryPoint'] = array(
    'file' => 'path/to/customEntryPoint.php',
    'auth' => true
);

示例

第一步是創建實際的入口點。這就是您的入口點的所有邏輯的位置。這個文件可以放在您選擇的任何地方。對於我的示例,我將創建:

./custom/customEntryPoint.php

<?php

    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    echo "Hello World!";

接下來, 我們將需要在應用程序擴展中創建我們的擴展。這將位於:
./custom/Extension/application/Ext/EntryPointRegistry/customEntryPoint.php

<?php

    $entry_point_registry['customEntryPoint'] = array(
        'file' => 'custom/customEntryPoint.php',
        'auth' => true
    );

最後, 導航到系統管理 > 修復 > 快速修復和重建。系統將生成文件./custom/application/Ext/EntryPointRegistry/entry_point_registry.ext.php 包含註冊表項。我們現在可以通過導航到以下位置來訪問我們的入口點:

http://{sugar url}/index.php?entryPoint=customEntryPoint

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章