/** * @covers BackBee\Bundle\Theme\ThemeTool::getMetadataFromAnnotation() */ public function testReadAnnotations() { $complete = new Mock\MockComplete(); $empty = new Mock\MockEmpty(); $expected = ['identifier' => 'backbee/mock-theme', 'name' => 'Mock BackBee Theme', 'description' => 'Description for Mock BackBee Theme', 'tags' => ['mock', 'theme'], 'thumbnails' => ['img/unknown.png', 'data:image/png;base64,' . base64_encode(file_get_contents(__DIR__ . '/static/img/fake.png'))], 'author' => ['Charles Rouillon <*****@*****.**>'], 'version' => '1.0', 'license' => 'GNU', 'demo' => 'http://www.backbee.com', 'docs' => 'http://docs.backbee.com']; $this->assertEquals($expected, ThemeTool::getMetadataFromAnnotation($complete)); $this->assertNull(ThemeTool::getMetadataFromAnnotation($empty)); }
/** * Initializes and run theme feature. */ public function run() { if (false == $this->settings || !isset($this->settings['options'])) { return; } $theme = null; $selected = $this->defineSelectedThemeName($this->app->getSite()); foreach (ThemeTool::getThemesFromOptions($this->settings['options']) as $name => $obj) { if ($name === $selected) { $theme = $obj; } } $this->initializeTheme($theme); }
/** * Returns an array that contains every declared theme. * * @return array */ protected function getThemes() { $config = $this->app->getConfig()->getThemesConfig(); if (!is_array($config) || !isset($config['options']) || false == $config['options']) { $output->writeln("<info>No theme to install.</info>"); exit(0); } return ThemeTool::getThemesFromOptions($config['options']); }
public function showAction($theme) { $app = $this->getApplication(); $all = $this->getBundle()->listThemes(); $result = []; foreach ($all as $key => $class) { $result[$key] = ThemeTool::getMetadataFromAnnotation($class); } $isSelected = ''; if (false !== ($selectedTheme = $this->getBundle()->defineSelectedThemeName($app->getSite()))) { $isSelected = $selectedTheme == $theme ? true : false; } return $this->render('Admin/Detail.twig', ['theme' => $theme, 'class' => $result[$theme], 'isSelected' => $isSelected]); }