PHP code example of genesis-global / salesforce-bundle

1. Go to this page and download the library: Download genesis-global/salesforce-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

genesis-global / salesforce-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new GenesisGlobal\Salesforce\SalesforceBundle\SalesforceBundle(),
        );

        // ...
    }

    // ...
}

// custom class which implements SobjectInterface
$case = new Sobject();
$case->setName('Case');
$case->setContent(['someField' => 'someValue']);

$result = $this->get('salesforce.service')->create($case);  

// get salesforce id
$id = $result->getId();


try {
    $this->get('salesforce.service')->update('Account', '001D000000INjVe', [ 'someField' => 'someValue' ]);
    
} catch (UpdateSobjectException $e) {
    
    // update failed
    echo $e->getMessage();
}

// account object
$account = new \stdClass();
$account->Current_Balance__c = '21023';
$account->Current_Count_of_Deposit__c = 0;
$account->Number_of_Active_Days__c = 12;
 
// account sObject ready to send to salesforce
$accountSobject = new Sobject();
$accountSobject->setName('Account');
$accountSobject->setContent($account);

$result = $this->get('salesforce.service')->upsert($sObject, 'Player_Account__c', '123132');

$metaData = $this->get('salesforce.service')->getMetaDataForSobject('Account');