public function RestClient::objects in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objects()
- 8.3 src/Rest/RestClient.php \Drupal\salesforce\Rest\RestClient::objects()
Available objects and their metadata for your organization's data.
Parameters
array $conditions: Associative array of filters to apply to the returned objects. Filters are applied after the list is returned from Salesforce.
bool $reset: Whether to reset the cache and retrieve a fresh version from Salesforce.
Return value
array Available objects and metadata.
Overrides RestClientInterface::objects
1 call to RestClient::objects()
- RestClient::getObjectTypeName in src/
Rest/ RestClient.php - Utility function to determine object type for given SFID.
1 method overrides RestClient::objects()
- TestRestClient::objects in src/
Tests/ TestRestClient.php - Hard-code a short list of objects for testing.
File
- src/
Rest/ RestClient.php, line 421
Class
- RestClient
- Objects, properties, and methods to communicate with the Salesforce REST API.
Namespace
Drupal\salesforce\RestCode
public function objects(array $conditions = [
'updateable' => TRUE,
], $reset = FALSE) {
// Use the cached data if we have it.
if (!$reset && ($cache = $this->cache
->get('salesforce:objects'))) {
$result = $cache->data;
}
else {
$result = $this
->apiCall('sobjects');
$this->cache
->set('salesforce:objects', $result, $this
->getRequestTime() + $this
->getShortTermCacheLifetime(), [
'salesforce',
]);
}
// print_r($result);
$sobjects = [];
// Filter the list by conditions, and assign SF table names as array keys.
foreach ($result['sobjects'] as $key => $object) {
if (empty($object['name'])) {
print_r($object);
}
if (!empty($conditions)) {
foreach ($conditions as $condition => $value) {
if ($object[$condition] == $value) {
$sobjects[$object['name']] = $object;
}
}
}
else {
$sobjects[$object['name']] = $object;
}
}
return $sobjects;
}