mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-09 11:03:17 +00:00
add /records/caption/ route to API
This commit is contained in:
@@ -315,6 +315,19 @@ return call_user_func(function()
|
|||||||
return $app['response']($result);
|
return $app['response']($result);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$route = '/records/{databox_id}/{record_id}/caption/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->caption_records($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/caption/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -204,6 +204,25 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function caption_records(Request $request, $databox_id, $record_id)
|
||||||
|
{
|
||||||
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
|
$record = $this->appbox->get_databox($databox_id)->get_record($record_id);
|
||||||
|
$fields = $record->get_caption()->get_fields();
|
||||||
|
$ret = array();
|
||||||
|
foreach ($fields as $field)
|
||||||
|
{
|
||||||
|
$ret[$field->get_meta_struct_id()] = array(
|
||||||
|
'meta_structure_id' => $field->get_meta_struct_id()
|
||||||
|
, 'name' => $field->get_name()
|
||||||
|
, 'value' => $field->get_serialized_values(";")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$result->set_datas($ret);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an API_V1_result containing the results of a records search
|
* Get an API_V1_result containing the results of a records search
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user