public function MigrateListJSON::computeCount in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/sources/json.inc \MigrateListJSON::computeCount()
Return a count of all available IDs from the source listing. The default implementation assumes the count of top-level elements reflects the number of IDs available - in many cases, you will need to override this to reflect your particular JSON structure.
Overrides MigrateList::computeCount
File
- plugins/
sources/ json.inc, line 85 - Support for migration from JSON sources.
Class
- MigrateListJSON
- Implementation of MigrateList, for retrieving a list of IDs to be migrated from a JSON object.
Code
public function computeCount() {
$count = 0;
if (empty($this->httpOptions)) {
$json = file_get_contents($this->listUrl);
}
else {
$response = drupal_http_request($this->listUrl, $this->httpOptions);
$json = $response->data;
}
if ($json) {
$data = drupal_json_decode($json);
if ($data) {
$count = count($this
->getIDsFromJSON($data));
}
}
return $count;
}