Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #49 from fmosca/master

Added customConfig to configuration options
  • Loading branch information...
commit d464cb617f0c118a5b40f559e9b43048f3828cb3 2 parents 3a218fb + 64a18d0
Trent Steel authored
6 DependencyInjection/Configuration.php
@@ -242,6 +242,12 @@ public function getConfigTreeBuilder()
242 242 ->end()
243 243 ->end()
244 244 ->children()
  245 + ->scalarNode('customConfig')
  246 + ->defaultNull()
  247 + ->info("The path of the custom config.js to use for the editor setup.")
  248 + ->end()
  249 + ->end()
  250 + ->children()
245 251 ->arrayNode('external_plugins')
246 252 ->useAttributeAsKey(true)
247 253 ->prototype('array')
1  DependencyInjection/TrsteelCkeditorExtension.php
@@ -66,6 +66,7 @@ public function load(array $configs, ContainerBuilder $container)
66 66 $container->setParameter('trsteel_ckeditor.ckeditor.entities_latin', $config['entities_latin']);
67 67 $container->setParameter('trsteel_ckeditor.ckeditor.startup_mode', $config['startup_mode']);
68 68 $container->setParameter('trsteel_ckeditor.ckeditor.external_plugins', $config['external_plugins']);
  69 + $container->setParameter('trsteel_ckeditor.ckeditor.customConfig', $config['customConfig']);
69 70 }
70 71
71 72 private function getDefaultGroups()
2  Form/Type/CkeditorType.php
@@ -127,6 +127,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
127 127 $view->vars['entities_latin'] = $options['entities_latin'];
128 128 $view->vars['startup_mode'] = $options['startup_mode'];
129 129 $view->vars['external_plugins'] = $options['external_plugins'];
  130 + $view->vars['customConfig'] = $options['customConfig'];
130 131 }
131 132
132 133 /**
@@ -162,6 +163,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
162 163 'entities_latin' => $this->container->getParameter('trsteel_ckeditor.ckeditor.entities_latin'),
163 164 'startup_mode' => $this->container->getParameter('trsteel_ckeditor.ckeditor.startup_mode'),
164 165 'external_plugins' => $this->container->getParameter('trsteel_ckeditor.ckeditor.external_plugins'),
  166 + 'customConfig' => $this->container->getParameter('trsteel_ckeditor.ckeditor.customConfig'),
165 167 ));
166 168
167 169 $resolver->setAllowedValues(array(
3  Resources/views/Form/ckeditor_widget.html.twig
@@ -101,6 +101,9 @@
101 101 {% if plugins %}
102 102 extraPlugins: '{{ plugins }}',
103 103 {% endif %}
  104 + {% if customConfig %}
  105 + customConfig: '{{ asset(customConfig) }}',
  106 + {% endif %}
104 107 toolbar: {{ toolbar | json_encode | raw }}
105 108 });
106 109 {% endautoescape %}
29 Tests/Form/CkeditorTypeTest.php
@@ -749,4 +749,31 @@ public function testExternalPlugins()
749 749 ),
750 750 ));
751 751 }
752   -}
  752 +
  753 + /**
  754 + * Check default customConfig property
  755 + */
  756 + public function testDefaultCustomConfig()
  757 + {
  758 + $form = $this->factory->create('ckeditor');
  759 + $view = $form->createView();
  760 + $customConfig = $view->vars['customConfig'];
  761 +
  762 + $this->assertNull($customConfig);
  763 + }
  764 +
  765 + /**
  766 + * Checks customConfig property
  767 + */
  768 + public function testCustomConfig()
  769 + {
  770 + $form = $this->factory->create('ckeditor', null, array(
  771 + 'customConfig' => 'someconfig.js'
  772 + ));
  773 +
  774 + $view = $form->createView();
  775 + $customConfig = $view->vars['customConfig'];
  776 +
  777 + $this->assertEquals($customConfig, 'someconfig.js');
  778 + }
  779 +}

0 comments on commit d464cb6

Please sign in to comment.
Something went wrong with that request. Please try again.