public function batchActionPublish(ProxyQueryInterface $query)
    {
        try {
            $objects = $query->select('DISTINCT '.$query->getRootAlias())->getQuery()->iterate();
            $i       = 0;
            $em      = $this->get('doctrine')->getManager();
            foreach ($objects as $object) {
                $object[0]->publish();
                $em->persist($object[0]);
                if ((++$i % 20) == 0) {
                    $em->flush();
                    $em->clear();
                }
            }
            $em->flush();
            $em->clear();
            $this->addFlash('sonata_flash_success', 'flash.success.batch_publish');
        } catch (ModelManagerException $e) {
            $this->addFlash('sonata_flash_error', 'flash.error.batch_publish');
        }

        return new RedirectResponse($this->admin->generateUrl('list', array('filter' => $this->admin->getFilterParameters())));
    }