Example #1
0
 /**
  * {@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 testPluginsWithConfiguredAndExplicitStylesSets()
 {
     $configuredStylesSets = array('foo' => array(array('name' => 'Blue Title', 'element' => 'h2', 'styles' => array('color' => 'Blue'))));
     $explicitStylesSets = array('bar' => array(array('name' => 'CSS Style', 'element' => 'span', 'attributes' => array('class' => 'my_style'))));
     $this->stylesSetManagerMock->expects($this->once())->method('setStylesSets')->with($this->equalTo($explicitStylesSets));
     $this->stylesSetManagerMock->expects($this->once())->method('getStylesSets')->will($this->returnValue(array_merge($explicitStylesSets, $configuredStylesSets)));
     $form = $this->factory->create('ckeditor', null, array('styles' => $explicitStylesSets));
     $view = $form->createView();
     $this->assertSame(array_merge($explicitStylesSets, $configuredStylesSets), $view->vars['styles']);
 }