/**
  * @param BlockEvent $event
  *
  * @return BlockInterface
  */
 public function onBlock(BlockEvent $event)
 {
     $block = new Block();
     $block->setSettings($event->getSettings());
     $block->setType($this->getName());
     $event->addBlock($block);
 }
 /**
  * @param BlockEvent
  */
 public function onBlock(BlockEvent $event)
 {
     $block = new Block();
     $block->setSettings($event->getSettings());
     $block->setName('sonata_translation.block.locale_switcher');
     $block->setType('sonata_translation.block.locale_switcher');
     $event->addBlock($block);
 }
 public function onBlock(BlockEvent $blockEvent)
 {
     $block = new Block();
     $block->setId(uniqid());
     // set a fake id
     $block->setSettings($blockEvent->getSettings());
     $block->setType('admin.form_javascripts.block');
     $blockEvent->addBlock($block);
 }
 public function testBlockEvent()
 {
     $blockEvent = new BlockEvent();
     $this->assertEmpty($blockEvent->getSettings());
     $blockEvent->addBlock($this->getMock('Sonata\\BlockBundle\\Model\\BlockInterface'));
     $this->assertCount(1, $blockEvent->getBlocks());
     $blockEvent->addBlock($this->getMock('Sonata\\BlockBundle\\Model\\BlockInterface'));
     $this->assertCount(2, $blockEvent->getBlocks());
     $this->assertNull($blockEvent->getSetting('fake'));
     $this->assertEquals(1, $blockEvent->getSetting('fake', 1));
 }
 /**
  * @param BlockEvent $event
  */
 public function onBlock(BlockEvent $event, $eventName)
 {
     $settings = $event->getSettings();
     if ($eventName == 'sonata.block.event.sonata.admin.show.top') {
         $settings['locale_switcher_route'] = 'show';
     }
     $block = new Block();
     $block->setSettings($settings);
     $block->setName('sonata_translation.block.locale_switcher');
     $block->setType('sonata_translation.block.locale_switcher');
     $event->addBlock($block);
 }
 /**
  * Add blocks services to event.
  *
  * @param BlockEvent $event
  */
 public function onBlock(BlockEvent $event)
 {
     $identifier = $event->getSetting('id', null);
     if ($identifier == null) {
         return;
     }
     $block = new Block();
     $block->setId(uniqid());
     $block->setSettings($event->getSettings());
     $block->setType($this->blockService->getName());
     $event->addBlock($block);
 }
 /**
  * Add context related BlockService, if found.
  *
  * @param BlockEvent $event
  */
 public function onBlock(BlockEvent $event)
 {
     $context = $event->getSetting('context', null);
     if ($context == null) {
         return;
     }
     foreach ($this->blockServices as $type => $blockService) {
         if ($blockService->handleContext($context)) {
             $block = new Block();
             $block->setId(uniqid());
             $block->setSettings($event->getSettings());
             $block->setType($type);
             $event->addBlock($block);
             return;
         }
     }
 }