123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- /*
- * This file is part of the Sonata project.
- *
- * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Sonata\AdminBundle\Block;
- use Symfony\Component\HttpFoundation\Response;
- use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
- use Sonata\AdminBundle\Form\FormMapper;
- use Sonata\AdminBundle\Validator\ErrorElement;
- use Sonata\AdminBundle\Admin\Pool;
- use Sonata\BlockBundle\Model\BlockInterface;
- use Sonata\BlockBundle\Block\BaseBlockService;
- /**
- *
- * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
- */
- class AdminListBlockService extends BaseBlockService
- {
- protected $pool;
- /**
- * @param string $name
- * @param \Symfony\Bundle\FrameworkBundle\Templating\EngineInterface $templating
- * @param \Sonata\AdminBundle\Admin\Pool $pool
- */
- public function __construct($name, EngineInterface $templating, Pool $pool)
- {
- parent::__construct($name, $templating);
- $this->pool = $pool;
- }
- /**
- * {@inheritdoc}
- */
- public function execute(BlockInterface $block, Response $response = null)
- {
- $settings = array_merge($this->getDefaultSettings(), $block->getSettings());
- $dashboardGroups = $this->pool->getDashboardGroups();
- $visibleGroups = array();
- foreach ($dashboardGroups as $name => $dashboardGroup) {
- if (!$settings['groups'] || in_array($name, $settings['groups'])) {
- $visibleGroups[] = $dashboardGroup;
- }
- }
- return $this->renderResponse('SonataAdminBundle:Block:block_admin_list.html.twig', array(
- 'block' => $block,
- 'settings' => $settings,
- 'admin_pool' => $this->pool,
- 'groups' => $visibleGroups
- ), $response);
- }
- /**
- * {@inheritdoc}
- */
- public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
- {
- // TODO: Implement validateBlock() method.
- }
- /**
- * {@inheritdoc}
- */
- public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
- {
- }
- /**
- * {@inheritdoc}
- */
- public function getName()
- {
- return 'Admin List';
- }
- /**
- * {@inheritdoc}
- */
- public function getDefaultSettings()
- {
- return array(
- 'groups' => false
- );
- }
- }
|