CoreController.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\AdminBundle\Controller;
  11. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  12. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  13. use Symfony\Component\HttpFoundation\Response;
  14. class CoreController extends Controller
  15. {
  16. /**
  17. * @return string
  18. */
  19. public function getBaseTemplate()
  20. {
  21. if ($this->getRequest()->isXmlHttpRequest()) {
  22. return $this->container->get('sonata.admin.pool')->getTemplate('ajax');
  23. }
  24. return $this->container->get('sonata.admin.pool')->getTemplate('layout');
  25. }
  26. /**
  27. * @return \Symfony\Bundle\FrameworkBundle\Controller\Response
  28. */
  29. public function dashboardAction()
  30. {
  31. return $this->render('SonataAdminBundle:Core:dashboard.html.twig', array(
  32. 'groups' => $this->get('sonata.admin.pool')->getDashboardGroups(),
  33. 'base_template' => $this->getBaseTemplate(),
  34. 'admin_pool' => $this->container->get('sonata.admin.pool')
  35. ));
  36. }
  37. }