/**
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function exportAction(Request $request)
 {
     if (false === $this->admin->isGranted('EXPORT')) {
         throw new AccessDeniedException();
     }
     $format = $request->get('format');
     $filename = sprintf('export_%s_%s.%s', strtolower(substr($this->admin->getClass(), strripos($this->admin->getClass(), '\\') + 1)), date('Y_m_d_H_i_s', strtotime('now')), $format);
     return $this->get('sonata.admin.exporter')->getResponse($format, $filename, $this->admin->getDataSourceIterator());
 }
 /**
  * Export data to specified format.
  *
  * @param Request $request
  *
  * @return Response
  *
  * @throws AccessDeniedException If access is not granted
  * @throws \RuntimeException     If the export format is invalid
  */
 public function exportAction(Request $request)
 {
     $this->admin->checkAccess('export');
     $format = $request->get('format');
     $allowedExportFormats = (array) $this->admin->getExportFormats();
     if (!in_array($format, $allowedExportFormats)) {
         throw new \RuntimeException(sprintf('Export in format `%s` is not allowed for class: `%s`. Allowed formats are: `%s`', $format, $this->admin->getClass(), implode(', ', $allowedExportFormats)));
     }
     $filename = sprintf('export_%s_%s.%s', strtolower(substr($this->admin->getClass(), strripos($this->admin->getClass(), '\\') + 1)), date('Y_m_d_H_i_s', strtotime('now')), $format);
     return $this->get('sonata.admin.exporter')->getResponse($format, $filename, $this->admin->getDataSourceIterator());
 }