mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 21:43:18 +00:00
Add API get collection route
Conflicts: lib/Alchemy/Phrasea/Controller/Api/V1.php lib/classes/API/V1/adapter.php Conflicts: lib/classes/appbox.php
This commit is contained in:
@@ -367,7 +367,7 @@ class appbox extends base
|
||||
|
||||
return $this->databoxes;
|
||||
}
|
||||
|
||||
|
||||
public function get_databox($sbas_id)
|
||||
{
|
||||
$databoxes = $this->get_databoxes();
|
||||
@@ -379,6 +379,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