mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 14:03:27 +00:00
Merge pull request #1425 from aztech-dev/api-collections-4.0
Add API get collection route
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user