The report viewer serves as an additional layer on top of the Jasper Report Bundle and provides a visual interface for displaying and running reports, and viewing report history. It requires the Jasper Report Bundle in order to work.
The report viewer bundle requires the report bundle to have been set up in order to work. If the report bundle is not yet installed, go here
The first step is to add the bundle to the composer.json of the application.
"require": {
"mesd/jasper-report-viewer-bundle": "~1.0"
}
In order for the application to load the bundle, it needs to be registered in the AppKernel.
public function registerBundles() {
$bundles = array(
...
new Mesd\Jasper\ReportViewerBundle\MesdJasperReportViewerBundle(),
)
}
To have assets work, the bundle has to be registered with assetic. This is done in the config file where the rest of assetic is setup. Example:
assetic:
...
bundles:
- MesdJasperReportViewerBundle
The final step is to include the report viewer's routing file in the main application's routing file. Look at the example below:
MESDJasperReportViewerBundle:
resource: "@MesdJasperReportViewerBundle/Resources/config/routing.yml"
prefix: /reportviewer
To add links to the report home and report viewer use the following twig functions
{# report home link #}
{{ mesd_jasper_reportviewer_home('Link Text') }}
{# report viewer link #}
{{ mesd_jasper_reportviewer_report_link('/reports/uri_of_report', 'Link Text') }}
{# stored report link #}
{{ mesd_jasper_reportviewer_stored_report_link('/reports/uri_of_report', 'requestId', 'Link Text') }}
These routes may also be used in controllers:
public function indexAction( Request $request ) {
$sc = $this->get('security.context');
if ( $sc->isGranted('ROLE_REPORT') ) {
return $this->redirect($this->generateUrl('MesdJasperReportViewerBundle_home'));
}
}
or:
public function indexAction( Request $request ) {
$sc = $this->get('security.context');
if ( $sc->isGranted('ROLE_REPORT') ) {
return $this->redirect(
$this->generateUrl(
'MesdJasperReportViewerBundle_home',
array( 'openInNewTab' => true )
)
);
}
A further look at each function:
Generated documentation exists in the bundle under the docs directory.
This project is licensed under the MIT license. See the LICENSE.md file for more information.