warent / convey-sugar
There is no license information available for the latest version (dev-master) of this package.
Extensions for SugarCRM to more easily and flexibly manipulate data
dev-master
2016-07-16 23:12 UTC
Requires
- spinegar/sugar7wrapper: dev-master
This package is not auto-updated.
Last update: 2025-03-29 22:59:32 UTC
README
License: MIT
1. About
- Designed to work with SugarCRM 7 and the v10 REST API
2. Installation
ConveySugar is available via Composer
$ composer require warent/convey-sugar
3. Usage Examples
<?php namespace App; use ConveySugar\Sugar; use ConveySugar\Utilities\Search; class ContactSearchingApp { private $sugar; public function __construct() { // Creating our Sugar connection instance. // Connection opens when newed up, // so be sure accepting functions accept sugar by reference. $this->sugar = new Sugar([ 'SUGAR_URL' => 'https://sugar/rest/v10/', 'SUGAR_USERNAME' => 'admin', 'SUGAR_PASSWORD' => 'password' ]); } public function searchContacts() { // Instantiating a new Sugar Utility // This one cycles through all records within a Sugar module $serchUtil = new Search(['resultsFn' => function($params) { $resultCount = count($params['results']); echo "$resultCount results from offset {$params['offset']}"; foreach ($params['results'] as $result) { print_r($Result); } }); // We execute our Search Utility on the module 'Contacts' $this->sugar->execute('Contacts', $searchUtil); } } ?>
4. Utilities
Count
Description
Return the number of records within a sugar module
Parameters
- None
Delete
Description
Delete a record by ID
Parameters
- recordID (Sugar ID [string]) Required
Insert
Description
Insert a new record
Parameters
- values (Assoc Array) Required
Related
Description
Cycle related records of one sugar record to another module
Parameters
- recordID (Sugar ID [string]) Required
- relation (Sugar Module [string]) Required
- type (Related::Type [static int])
- Related::TYPE_NORMAL
- Related::TYPE_NAKED
- Related::TYPE_BACK
- number (Integer)
- transform (Related::Transform [static int])
- Related::TRANSFORM_JSON
- Related::TRANSFORM_BOOL
- resultsFn (Function)
- Parameters (Assoc Array)
- results (Array)
- offset (Integer)
- Parameters (Assoc Array)
- offset (Integer)
- limit (Integer)
Search
Description
Cycle records of a sugar module
Parameters
- resultsFn (Function) Required
- Parameters (Assoc Array)
- results (Array)
- offset (Integer)
- Parameters (Assoc Array)
- offset (Integer)
- limit (Integer)
5. Extra Features
resultsFn
- Returning
false
in a resultsFn will stop/break the lookup
Related (Utility)
transform
will return JSON (Assoc Array) by default.TYPE_BOOL
willreturn true
if any results are found, otherwisereturn false
type
refers to theSugarCRM
formatting of relational queries. There are three (unofficial) known ways for this to happen in the Sugar API,NORMAL
,BACK
, andNAKED
: in aNORMAL
type the query is$module_$relation_$number
; in aBACK
type the query is$relation_$module_$number
; in aNAKED
type the query is simply$relation
.NORMAL
is the defaulttype
and1
is the defaultnumber
as these are the most common configurations.