PHRAS-315 Do not expose not downloadable subdef

This commit is contained in:
Nicolas Le Goff
2015-01-12 16:00:01 +01:00
committed by Benoît Burnichon
parent 9b6e20c6c5
commit cd85d4fdf9
2 changed files with 11 additions and 1 deletions

View File

@@ -1019,6 +1019,17 @@ class V1Controller extends Controller
} }
} }
$databox = $record->getDatabox();
try {
$subDefDefinition = $databox->get_subdef_structure()->get_subdef($record->getType(), $media->get_name());
} catch (\Exception_Databox_SubdefNotFound $e) {
return null;
}
if (false === $subDefDefinition->is_downloadable()) {
return null;
}
if ($media->get_permalink() instanceof \media_Permalink_Adapter) { if ($media->get_permalink() instanceof \media_Permalink_Adapter) {
$permalink = $this->listPermalink($media->get_permalink()); $permalink = $this->listPermalink($media->get_permalink());
} else { } else {

View File

@@ -1052,7 +1052,6 @@ abstract class ApiTestCase extends \PhraseanetWebTestCase
$embedTypes = array_flip(array_map(function($subdef) {return $subdef['name'];}, $content['response']['embed'])); $embedTypes = array_flip(array_map(function($subdef) {return $subdef['name'];}, $content['response']['embed']));
//access to all subdefs //access to all subdefs
$this->assertArrayHasKey('document', $embedTypes);
$this->assertArrayHasKey('preview', $embedTypes); $this->assertArrayHasKey('preview', $embedTypes);
$this->assertArrayHasKey('thumbnail', $embedTypes); $this->assertArrayHasKey('thumbnail', $embedTypes);