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:
Thibaud Fabre
2015-07-07 18:52:51 +02:00
parent 57ae1ade77
commit 1bcefda9a1
4 changed files with 33 additions and 2 deletions

View File

@@ -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