AdminListBlockService.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /*
  3. * This file is part of the Sonata project.
  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\Block;
  11. use Symfony\Component\HttpFoundation\Response;
  12. use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
  13. use Sonata\AdminBundle\Form\FormMapper;
  14. use Sonata\AdminBundle\Validator\ErrorElement;
  15. use Sonata\AdminBundle\Admin\Pool;
  16. use Sonata\BlockBundle\Model\BlockInterface;
  17. use Sonata\BlockBundle\Block\BaseBlockService;
  18. /**
  19. *
  20. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  21. */
  22. class AdminListBlockService extends BaseBlockService
  23. {
  24. protected $pool;
  25. /**
  26. * @param $name
  27. * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating
  28. * @param \Sonata\AdminBundle\Admin\Pool $pool
  29. */
  30. public function __construct($name, EngineInterface $templating, Pool $pool)
  31. {
  32. parent::__construct($name, $templating);
  33. $this->pool = $pool;
  34. }
  35. /**
  36. * {@inheritdoc}
  37. */
  38. public function execute(BlockInterface $block, Response $response = null)
  39. {
  40. $settings = array_merge($this->getDefaultSettings(), $block->getSettings());
  41. return $this->renderResponse('SonataAdminBundle:Block:block_admin_list.html.twig', array(
  42. 'block' => $block,
  43. 'settings' => $settings,
  44. 'admin_pool' => $this->pool
  45. ), $response);
  46. }
  47. /**
  48. * {@inheritdoc}
  49. */
  50. public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
  51. {
  52. // TODO: Implement validateBlock() method.
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
  58. {
  59. }
  60. /**
  61. * {@inheritdoc}
  62. */
  63. public function getName()
  64. {
  65. return 'Admin List';
  66. }
  67. /**
  68. * {@inheritdoc}
  69. */
  70. function getDefaultSettings()
  71. {
  72. return array();
  73. }
  74. }