/** * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->setAttribute('enable', $options['enable']); if ($builder->getAttribute('enable')) { $builder->setAttribute('autoload', $options['autoload']); $builder->setAttribute('inline', $options['inline']); $builder->setAttribute('jquery', $options['jquery']); $builder->setAttribute('input_sync', $options['input_sync']); $builder->setAttribute('base_path', $options['base_path']); $builder->setAttribute('js_path', $options['js_path']); $builder->setAttribute('jquery_path', $options['jquery_path']); $config = $options['config']; if ($options['config_name'] === null) { $name = uniqid('ivory', true); $options['config_name'] = $name; $this->configManager->setConfig($name, $config); } else { $this->configManager->mergeConfig($options['config_name'], $config); } $this->pluginManager->setPlugins($options['plugins']); $this->stylesSetManager->setStylesSets($options['styles']); $this->templateManager->setTemplates($options['templates']); $builder->setAttribute('config', $this->configManager->getConfig($options['config_name'])); $builder->setAttribute('plugins', $this->pluginManager->getPlugins()); $builder->setAttribute('styles', $this->stylesSetManager->getStylesSets()); $builder->setAttribute('templates', $this->templateManager->getTemplates()); } }
public function testTemplatesWithConfiguredAndExplicitTemplates() { $configuredTemplates = array('default' => array('imagesPath' => '/my/path', 'templates' => array(array('title' => 'My Template', 'html' => '<h1>Template</h1><p>Type your text here.</p>')))); $explicitTemplates = array('extra' => array('templates' => array(array('title' => 'My Extra Template', 'html' => '<h2>Template</h2><p>Type your text here.</p>')))); $this->templateManagerMock->expects($this->once())->method('setTemplates')->with($this->equalTo($explicitTemplates)); $this->templateManagerMock->expects($this->once())->method('getTemplates')->will($this->returnValue(array_merge($explicitTemplates, $configuredTemplates))); $form = $this->factory->create('ckeditor', null, array('templates' => $explicitTemplates)); $view = $form->createView(); $this->assertSame(array_merge($explicitTemplates, $configuredTemplates), $view->vars['templates']); }