public function testSetting() { $block = new Block(); $block->setSetting('foo', 'bar'); $this->assertEquals('void', $block->getSetting('fake', 'void')); $this->assertNull($block->getSetting('fake')); $this->assertEquals('bar', $block->getSetting('foo')); }
/** * @param BlockEvent $event */ public function onBlock(BlockEvent $event) { if (!$this->optionService->get('twomartens.core', 'showSystemStats')->getValue()) { return; } $variables = ['systemData' => [['key' => $this->translator->trans('acp.dashboard.blocks.systemstats.os', [], 'TwoMartensCoreBundle'), 'value' => PHP_OS], ['key' => $this->translator->trans('acp.dashboard.blocks.systemstats.webserver', [], 'TwoMartensCoreBundle'), 'value' => isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : ''], ['key' => $this->translator->trans('acp.dashboard.blocks.systemstats.php', [], 'TwoMartensCoreBundle'), 'value' => PHP_VERSION]]]; $content = $this->templating->render('TwoMartensCoreBundle:blocks:systemStatsBlock.html.twig', $variables); $block = new Block(); $block->setId(uniqid()); $block->setSetting('content', $content); $block->setType('sonata.block.service.text'); $event->addBlock($block); }