function drush_salesforce_sf_create_object in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 salesforce.drush.inc \drush_salesforce_sf_create_object()
- 8.3 salesforce.drush.inc \drush_salesforce_sf_create_object()
- 7.3 salesforce.drush.inc \drush_salesforce_sf_create_object()
Create a Salesforce object available to the logged-in user.
Parameters
string $name: The object type name, e.g. Account.
string $data: The object data, or '-' to read from stdin.
File
- ./
salesforce.drush.inc, line 339 - Drush integration for Salesforce.
Code
function drush_salesforce_sf_create_object($name, $data) {
_drush_salesforce_deprecated();
if ($data == '-') {
$data = stream_get_contents(STDIN);
}
$format = drush_get_option('format', 'json');
$params = [];
switch ($format) {
case 'query':
parse_str($data, $params);
break;
case 'json':
$params = json_decode($data, TRUE);
break;
default:
drush_log(dt('Invalid format'), 'error');
return;
}
$salesforce = \Drupal::service('salesforce.client');
try {
if ($result = $salesforce
->objectCreate($name, $params)) {
drush_print_r($result);
}
} catch (SalesforceException $e) {
drush_log($e
->getMessage(), 'error');
}
}