定制 mncee/salesforce-sync 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

mncee/salesforce-sync

Composer 安装命令:

composer require mncee/salesforce-sync

包简介

Package for syncing Salesforce objects with local data

README 文档

README

This package is for syncing Salesforce objects with local data in a Laravel app.

Works with Laravel 9, 10, and 11.

Use version ^1.0 for Laravel 5

Installation

This package can be installed via Composer by requiring the mncee/salesforce-sync package.

composer require mncee/salesforce-sync

For Laravel 5

composer require mncee/salesforce-sync:^1.0

Laravel Configuration

Environment Variables

Include the following environment variables in the .env file:

SALESFORCE_USERNAME=#your salesfore username#
SALESFORCE_PASSWORD=#your salesfore password#
SALESFORCE_TOKEN=#your salesfore token#
SALESFORCE_WSDL=#path to the wsdl stored in the storage/app/ directory#

Place your your Enterprise WSDL file into your app storage/app/ directory you specified in the .env file.

IMPORTANT: This package only works with Enterprise WSDL

Package Discovery

This packages Service Provider and Facade alias should be auto-discovered when requiring it with composer.

But if you need to add them manually, you can do so with the following instructions:

For Laravel 11

In the bootstrap/providers.php file add CEE\Salesforce\Laravel\SalesforceServiceProvider::class to the returned array.

// bootstrap/providers.php

return [
    App\Providers\AppServiceProvider::class,
    CEE\Salesforce\Laravel\SalesforceServiceProvider::class,
];

In the config/app.php file add these corresponding lines to the returned array.

// config/app.php

return [
    
    //...
    
    'aliases' => Facade::defaultAliases()->merge([
        'Salesforce' => \CEE\Salesforce\Laravel\Facades\Salesforce::class,
    ])->toArray(),
]

For Laravel 9 and 10

Find the providers key and aliases key in your config/app.php and add these corresponding lines to the returned array.

// config/app.php

return [
    
    //...
    
    'providers' => [
        // ...
        CEE\Salesforce\Laravel\SalesforceServiceProvider::class,
    ],
    
    'aliases' => [
        // ...
        'Salesforce' => \CEE\Salesforce\Laravel\Facades\Salesforce::class,
    ],
    
];

The SyncObject Class

This is the class to use for syncing local data with remote Salesforce objects.

Sub-class usage

Classes that inherit this class can perform functions for syncing (pushing and pulling) with a remote Salesforce object.

class Contact extends SyncObject
{
    public $objectName = 'Contact'; // Saleforce Object Name
    ...
}

$salesforceContact = new Contact();
$salesforceContact->push();
$salesforceContact->pull();

Functions need to be defined for pushing and pulling Salesforce object fields, and must use this naming convention:

public function push_<Salesforce field name>()
public function pull_<Salesforce field name>($value)

The push_...() functions should return a value that is to be pushed to the corresponding <Salesforce field name> of the remote Salesforce object.

    public function push_FirstName() {
        return DB::table('contact')->where('id', 1)->value('first_name');
    }

The pull_...($value) functions will have an argument containing the value corresponding to the <Salesforce field name> of the remote Salesforce object that can be used to update local data.

    public function pull_FirstName($firstName) {
        DB::table('contact')->where('id', 1)->update(['first_name' => $firstName]);
    }

It is not required to have both a push_...() and a pull_...() function for a given Salesforce field. Either or both can be used according to what is needed for syncing in either direction.

Static objectName() function and chaining usage

This class can also be used on it's own using the chaining functions:

SyncObject::objectName('Contact')
	->id('00A10000001aBCde')
	->pushFields(['FirstName' => 'John', 'LastName' => 'Doe'])
	->push();
	
$salesforceContact = SyncObject::objectName('Contact')
	->id('00A10000001aBCde')
	->pullFields(['FirstName', 'LastName'])
	->pull();

统计信息

  • 总下载量: 2.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固