/** * @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); }
/** * @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); }
/** * test the block's form builders. */ public function testFormBuilder() { $templating = new FakeTemplating(); $service = new ContainerBlockService('core.container', $templating); $block = new Block(); $block->setName('block.name'); $block->setType('core.container'); $block->setSettings(array('name' => 'block.code')); $formMapper = $this->getMock('Sonata\\AdminBundle\\Form\\FormMapper', array(), array(), '', false); $formMapper->expects($this->exactly(6))->method('add'); $service->buildCreateForm($formMapper, $block); $service->buildEditForm($formMapper, $block); }
public function testSetterGetter() { $time = new \DateTime(); $parent = $this->getMockBuilder('Sonata\\BlockBundle\\Model\\Block')->getMock(); $block = new Block(); $block->setName('my.block.name'); $block->setCreatedAt($time); $block->setUpdatedAt($time); $block->setEnabled(true); $block->setPosition(1); $block->setType('foo.bar'); $block->setParent($parent); $this->assertEquals('my.block.name', $block->getName()); $this->assertEquals($time, $block->getCreatedAt()); $this->assertEquals($time, $block->getUpdatedAt()); $this->assertTrue($block->getEnabled()); $this->assertEquals(1, $block->getPosition()); $this->assertEquals('foo.bar', $block->getType()); $this->assertEquals($parent, $block->getParent()); }