public renderFile ( Silex\Application $app, string $entity, string $id, string $field ) : |
||
$app | Silex\Application | the Silex application |
$entity | string | the current entity |
$id | string | the instance id |
$field | string | the field of the file to render of the instance |
return | the rendered file |
public function renderFile(Application $app, $entity, $id, $field)
{
$crudData = $app['crud']->getData($entity);
$instance = $crudData->get($id);
$definition = $crudData->getDefinition();
if (!$instance || $definition->getType($field) != 'file' || !$instance->get($field)) {
return $this->getNotFoundPage($app, $app['translator']->trans('crudlex.instanceNotFound'));
}
return $crudData->renderFile($instance, $entity, $field);
}