/** * Outputs serialized entities * * @param Request $request */ protected function export(Request $request) { $iterator = $this->queryGenerator->createQueryBuilder($request, $this->configuration->getName())->getQuery()->iterate(); $headersSent = false; $manager = $this->doctrine->getManagerForClass($this->configuration->getEntityClass()); foreach ($iterator as $index => $item) { if (!count($item[0])) { continue; } $norm = $this->serializer->normalize($item[0], $this->options['serializer_format'], $this->options['serializer_context']); if (!$headersSent) { echo $this->serializer->encode(array_keys($norm), $this->options['serializer_format'], $this->options['serializer_context']); $headersSent = true; } echo $this->serializer->encode($norm, $this->options['serializer_format'], $this->options['serializer_context']); flush(); if (0 === ($index + 100) % $this->options['batch_size']) { $manager->clear(); } } }
/** * {@inheritdoc} */ protected function getTemplateVars(Request $request, FormInterface $form) { return ['objectCount' => $this->queryGenerator->getCount($request, $this->configuration->getName()), 'formAction' => $this->getActionUrl($this->getType(), $form->getData(), $this->getGridUrlParameters($request))] + parent::getTemplateVars($request, $form); }