public function TripalEntityCollection::load
3.x TripalEntityCollection.inc | public TripalEntityCollection::load($collection_id) |
Loads an existing collection using a collection ID.
Parameters
$collection_id: The ID of the collection to load.
Throws
Exception
2 calls to TripalEntityCollection::load()
- TripalEntityCollection::addBundle in tripal/
includes/ TripalEntityCollection.inc - Creates a new tripal_collection_bundle entry.
- TripalEntityCollection::create in tripal/
includes/ TripalEntityCollection.inc - Creates a new data collection.
File
- tripal/
includes/ TripalEntityCollection.inc, line 101
Class
Code
public function load($collection_id) {
// Make sure we have a numeric job_id.
if (!$collection_id or !is_numeric($collection_id)) {
throw new Exception("You must provide the collection_id to load the collection.");
}
$collection = db_select('tripal_collection', 'tc')
->fields('tc')
->condition('collection_id', $collection_id)
->execute()
->fetchObject();
if (!$collection) {
throw new Exception("Cannot find a collection with the ID provided.");
}
// Fix the date/time fields.
$this->collection_name = $collection->collection_name;
$this->create_date = $collection->create_date;
$this->user = user_load($collection->uid);
$this->description = $collection->description;
$this->collection_id = $collection->collection_id;
// Now get the bundles in this collection.
$bundles = db_select('tripal_collection_bundle', 'tcb')
->fields('tcb')
->condition('collection_id', $collection->collection_id)
->execute();
// If more than one bundle plop into associative array.
while ($bundle = $bundles->fetchObject()) {
$bundle_name = $bundle->bundle_name;
$this->bundles[$bundle_name] = $bundle;
$this->ids[$bundle_name] = unserialize($bundle->ids);
$this->fields[$bundle_name] = unserialize($bundle->fields);
}
// Iterate through the fields and find out what download formats are
// supported for this basket.
$this->formatters = $this->setFormatters();
}