Merge pull request #1425 from aztech-dev/api-collections-4.0

Add API get collection route
This commit is contained in:
Benoît Burnichon
2015-09-28 09:50:59 +02:00
4 changed files with 30 additions and 0 deletions

View File

@@ -268,6 +268,26 @@ class appbox extends base
return $databoxes[$sbas_id];
}
public function get_collection($base_id)
{
$sbas_id = phrasea::sbasFromBas($this->app, $base_id);
if ($sbas_id === false) {
throw new \RuntimeException('Collection not found.');
}
$collections = $this->get_databox($sbas_id)->get_collections();
foreach ($collections as $collection) {
if ($collection->get_base_id() == $base_id) {
return $collection;
}
}
// This should not happen, but I'd rather be safe than sorry.
throw new \RuntimeException('Collection not found.');
}
/**
* @param string $option
* @return string