Permalink
Browse files

Merge pull request #49 from fmosca/master

Added customConfig to configuration options
  • Loading branch information...
2 parents 3a218fb + 64a18d0 commit d464cb617f0c118a5b40f559e9b43048f3828cb3 @trsteel88 committed Apr 5, 2013
@@ -242,6 +242,12 @@ public function getConfigTreeBuilder()
->end()
->end()
->children()
+ ->scalarNode('customConfig')
+ ->defaultNull()
+ ->info("The path of the custom config.js to use for the editor setup.")
+ ->end()
+ ->end()
+ ->children()
->arrayNode('external_plugins')
->useAttributeAsKey(true)
->prototype('array')
@@ -66,6 +66,7 @@ public function load(array $configs, ContainerBuilder $container)
$container->setParameter('trsteel_ckeditor.ckeditor.entities_latin', $config['entities_latin']);
$container->setParameter('trsteel_ckeditor.ckeditor.startup_mode', $config['startup_mode']);
$container->setParameter('trsteel_ckeditor.ckeditor.external_plugins', $config['external_plugins']);
+ $container->setParameter('trsteel_ckeditor.ckeditor.customConfig', $config['customConfig']);
}
private function getDefaultGroups()
@@ -127,6 +127,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['entities_latin'] = $options['entities_latin'];
$view->vars['startup_mode'] = $options['startup_mode'];
$view->vars['external_plugins'] = $options['external_plugins'];
+ $view->vars['customConfig'] = $options['customConfig'];
}
/**
@@ -162,6 +163,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'entities_latin' => $this->container->getParameter('trsteel_ckeditor.ckeditor.entities_latin'),
'startup_mode' => $this->container->getParameter('trsteel_ckeditor.ckeditor.startup_mode'),
'external_plugins' => $this->container->getParameter('trsteel_ckeditor.ckeditor.external_plugins'),
+ 'customConfig' => $this->container->getParameter('trsteel_ckeditor.ckeditor.customConfig'),
));
$resolver->setAllowedValues(array(
@@ -101,6 +101,9 @@
{% if plugins %}
extraPlugins: '{{ plugins }}',
{% endif %}
+ {% if customConfig %}
+ customConfig: '{{ asset(customConfig) }}',
+ {% endif %}
toolbar: {{ toolbar | json_encode | raw }}
});
{% endautoescape %}
@@ -749,4 +749,31 @@ public function testExternalPlugins()
),
));
}
-}
+
+ /**
+ * Check default customConfig property
+ */
+ public function testDefaultCustomConfig()
+ {
+ $form = $this->factory->create('ckeditor');
+ $view = $form->createView();
+ $customConfig = $view->vars['customConfig'];
+
+ $this->assertNull($customConfig);
+ }
+
+ /**
+ * Checks customConfig property
+ */
+ public function testCustomConfig()
+ {
+ $form = $this->factory->create('ckeditor', null, array(
+ 'customConfig' => 'someconfig.js'
+ ));
+
+ $view = $form->createView();
+ $customConfig = $view->vars['customConfig'];
+
+ $this->assertEquals($customConfig, 'someconfig.js');
+ }
+}

0 comments on commit d464cb6

Please sign in to comment.