Skip to content

Commit

Permalink
Added customConfig to configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Mosca committed Apr 5, 2013
1 parent 3a218fb commit 64a18d0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 1 deletion.
6 changes: 6 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ public function getConfigTreeBuilder()
->info("The mode to load at the editor startup. It depends on the plugins loaded. By default, the `wysiwyg` and `source` modes are available. ")
->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)
Expand Down
1 change: 1 addition & 0 deletions DependencyInjection/TrsteelCkeditorExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions Form/Type/CkeditorType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}

/**
Expand Down Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions Resources/views/Form/ckeditor_widget.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
{% if plugins %}
extraPlugins: '{{ plugins }}',
{% endif %}
{% if customConfig %}
customConfig: '{{ asset(customConfig) }}',
{% endif %}
toolbar: {{ toolbar | json_encode | raw }}
});
{% endautoescape %}
Expand Down
29 changes: 28 additions & 1 deletion Tests/Form/CkeditorTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 64a18d0

Please sign in to comment.