inetprocess/libsugarcrm 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

inetprocess/libsugarcrm

Composer 安装命令:

composer require inetprocess/libsugarcrm

包简介

This library provides a various classes to interact with SugarCRM

README 文档

README

That library allows anybody to interact with a SugarCRM application, outside that application. Suppose you need to do a importation script, running every night, with a very specific set of transformations or check. Then you need that kind of tools to be able to "Login" to SugarCRM, create or update beans, do SQL queries, etc ...

Warning

  • Be very careful that Sugar doesn't do a very "clean" job so it's better to deactivate the strict standards erorr reporting in PHP to be able to use it. When I launch my script, I usualy do something like:
php -d 'error_reporting=E_ALL & ~E_STRICT'  test.php
  • If you are not using my classes in another class (if you do like in examples below, directly calling the library), be more careful: don't name your variables like sugar does, else you'll overwrite it (example: $db or $log).

  • Last but not the least: you'll be able to instanciate the EntryPoint for only one instance of Sugar ! It uses GLOBALS variable such as $GLOBALS['db'] and I let you imagine what will happen if it's overwritten by another Instance of SugarCRM ;)

Classes

Inet\SugarCRM\Application

Gives general information about SugarCRM Installation. Others classes depends on this one.

Usage Example:

<?php
require_once 'vendor/autoload.php';
use Psr\Log\NullLogger;
use Inet\SugarCRM\Application;

$sugarApp = new Application(new NullLogger(), '/home/sugarcrm/www');
echo $sugarApp->getPath();
if ($sugarApp->isValid()) {
    echo $sugarApp->getVersion();
}

Inet\SugarCRM\EntryPoint

It says where is Sugar and does the basic steps to "login" into SugarCRM. EntryPoint needs a logger because other classes log a lot of stuff. The EntryPoint can only be loaded once for the entire program.

Usage Example:

<?php
require_once 'vendor/autoload.php';
use Psr\Log\NullLogger;
use Inet\SugarCRM\Application;
use Inet\SugarCRM\EntryPoint;

if (!EntryPoint::isCreated()) {
    $nullLogger = new NullLogger;
    $sugarApp = new Application($nullLogger, '/home/sugarcrm/www');
    // enter sugar
    EntryPoint::createInstance($sugarApp, '1');
}
$sugarEP = EntryPoint::getInstance();

Inet\SugarCRM\Bean

Most complete class to :

  • Get a list of available modules (getBeansList())
  • Get an Bean (getBean())
  • Create a Bean (newBean())
  • Get a list of records for a module (getList())
  • ...

Usage Example:

<?php
require_once 'vendor/autoload.php';
use Psr\Log\NullLogger;
use Inet\SugarCRM\EntryPoint;
use Inet\SugarCRM\Bean;

if (!EntryPoint::isCreated()) {
    $nullLogger = new NullLogger;
    $sugarApp = new Application($nullLogger, '/home/sugarcrm/www');
    // enter sugar
    EntryPoint::createInstance($sugarApp, '1');
}
$sugarEP = EntryPoint::getInstance();

// instanciate the Bean class to retrieve User with id 1
$inetSugarBean = new Bean($sugarEP);
$adminUser = $inetSugarBean->getBean('Users', 1);
echo $adminUser->name;

Inet\SugarCRM\BeanFactoryCache

Don't use it directly, it's directly used by Inet\SugarCRM\Bean to clean the cache during long loops.

Inet\SugarCRM\DB

Useful to query SugarCRM DB directly.

Usage Example:

<?php
require_once 'vendor/autoload.php';
use Inet\SugarCRM\EntryPoint;
use Inet\SugarCRM\DB;

// get the DB Class
$inetSugarDB = new DB(EntryPoint::getInstance());
$users = $inetSugarDB->query('SELECT * FROM users');
echo count($users);

Inet\SugarCRM\Utils

Various Utils to create labels, dropdown, encode or decode multiselect, etc...

Usage Example:

<?php
require_once 'vendor/autoload.php';
use Inet\SugarCRM\EntryPoint;
use Inet\SugarCRM\Utils;

// get the Utils Class
$inetSugarUtils = new Utils(EntryPoint::getInstance());
// Convert an array to a multiselect
$convertedArray = $inetSugarUtils->arrayToMultiselect(array('test' => 'inet'));
echo $convertedArray;

Inet\SugarCRM\SugarQueryIterator

Iterator class to iterate in a memory safe way SugarQuery results.

Usage Example: Loop records 100 to 300

<?php
$query = new \SugarQuery();
// setup $query

$iter = new SugarQueryIterator($query);
$iter->setStartOffset(100);
foreach ($iter as $id => $bean) {
   // Do something with $bean
   if ($iter->getIterationCounter() >= 200) {
       break;
   }
}

统计信息

  • 总下载量: 9.13k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 9
  • 点击次数: 0
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 9
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2016-01-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固