/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { $ckeditorConfiguration = array('toolbar' => array_values($options['ckeditor_toolbar_icons'])); if ($options['ckeditor_context']) { $contextConfig = $this->configManager->getConfig($options['ckeditor_context']); $ckeditorConfiguration = array_merge($ckeditorConfiguration, $contextConfig); } $view->vars['ckeditor_configuration'] = $ckeditorConfiguration; $view->vars['ckeditor_basepath'] = $options['ckeditor_basepath']; }
/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { if (is_array($options['source_field'])) { list($sourceField) = $options['source_field']; $view->vars['source_field'] = $sourceField; } else { $view->vars['source_field'] = $options['source_field']; } if (is_array($options['format_field'])) { list($formatField) = $options['format_field']; $view->vars['format_field'] = $formatField; } else { $view->vars['format_field'] = $options['format_field']; } $view->vars['format_field_options'] = $options['format_field_options']; $defaultConfig = $this->configManager->getDefaultConfig(); if ($this->configManager->hasConfig($defaultConfig)) { $ckeditorConfiguration = $this->configManager->getConfig($defaultConfig); } else { $ckeditorConfiguration = array(); } if (!array_key_exists('toolbar', $ckeditorConfiguration)) { $ckeditorConfiguration['toolbar'] = array_values($options['ckeditor_toolbar_icons']); } if ($options['ckeditor_context']) { $contextConfig = $this->configManager->getConfig($options['ckeditor_context']); $ckeditorConfiguration = array_merge($ckeditorConfiguration, $contextConfig); } $view->vars['ckeditor_configuration'] = $ckeditorConfiguration; $view->vars['ckeditor_basepath'] = $options['ckeditor_basepath']; $view->vars['source_id'] = str_replace($view->vars['name'], $view->vars['source_field'], $view->vars['id']); }
public function testConfigWithExplicitAndConfiguredConfig() { $configuredConfig = array('toolbar' => 'default', 'uiColor' => '#ffffff'); $explicitConfig = array('uiColor' => '#000000'); $this->configManagerMock->expects($this->once())->method('mergeConfig')->with($this->equalTo('default'), $this->equalTo($explicitConfig)); $this->configManagerMock->expects($this->once())->method('getConfig')->with('default')->will($this->returnValue(array_merge($configuredConfig, $explicitConfig))); $form = $this->factory->create('ckeditor', null, array('config_name' => 'default', 'config' => $explicitConfig)); $view = $form->createView(); $this->assertArrayHasKey('config', $view->vars); $this->assertSame(array_merge($configuredConfig, $explicitConfig), $view->vars['config']); }
/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array('enable' => $this->enable, 'autoload' => $this->autoload, 'inline' => $this->inline, 'jquery' => $this->jquery, 'input_sync' => $this->inputSync, 'base_path' => $this->basePath, 'js_path' => $this->jsPath, 'jquery_path' => $this->jqueryPath, 'config_name' => $this->configManager->getDefaultConfig(), 'config' => array(), 'plugins' => array(), 'styles' => array(), 'templates' => array())); $allowedTypesMap = array('enable' => 'bool', 'autoload' => 'bool', 'inline' => 'bool', 'jquery' => 'bool', 'input_sync' => 'bool', 'config_name' => array('string', 'null'), 'base_path' => 'string', 'js_path' => 'string', 'jquery_path' => 'string', 'config' => 'array', 'plugins' => 'array', 'styles' => 'array', 'templates' => 'array'); if (Kernel::VERSION_ID >= 20600) { foreach ($allowedTypesMap as $option => $allowedTypes) { $resolver->addAllowedTypes($option, $allowedTypes); } } else { $resolver->addAllowedTypes($allowedTypesMap); } }
/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array('enable' => $this->enable, 'async' => $this->async, 'autoload' => $this->autoload, 'auto_inline' => $this->autoInline, 'inline' => $this->inline, 'jquery' => $this->jquery, 'require_js' => $this->requireJs, 'input_sync' => $this->inputSync, 'filebrowsers' => $this->filebrowsers, 'base_path' => $this->basePath, 'js_path' => $this->jsPath, 'jquery_path' => $this->jqueryPath, 'config_name' => $this->configManager->getDefaultConfig(), 'config' => array(), 'plugins' => array(), 'styles' => array(), 'templates' => array())); $allowedTypesMap = array('enable' => 'bool', 'async' => 'bool', 'autoload' => 'bool', 'auto_inline' => 'bool', 'inline' => 'bool', 'jquery' => 'bool', 'require_js' => 'bool', 'input_sync' => 'bool', 'filebrowsers' => 'array', 'config_name' => array('string', 'null'), 'base_path' => 'string', 'js_path' => 'string', 'jquery_path' => 'string', 'config' => 'array', 'plugins' => 'array', 'styles' => 'array', 'templates' => 'array'); $normalizers = array('base_path' => function (Options $options, $value) { if (substr($value, -1) !== '/') { $value .= '/'; } return $value; }); if (Kernel::VERSION_ID >= 20600) { foreach ($allowedTypesMap as $option => $allowedTypes) { $resolver->addAllowedTypes($option, $allowedTypes); } foreach ($normalizers as $option => $normalizer) { $resolver->setNormalizer($option, $normalizer); } } else { $resolver->addAllowedTypes($allowedTypesMap)->setNormalizers($normalizers); } }
/** * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array('enable' => $this->enable, 'base_path' => $this->basePath, 'js_path' => $this->jsPath, 'config_name' => $this->configManager->getDefaultConfig(), 'config' => array(), 'plugins' => array(), 'styles' => array(), 'templates' => array()))->addAllowedTypes(array('enable' => 'bool', 'config_name' => array('string', 'null'), 'base_path' => array('string'), 'js_path' => array('string'), 'config' => 'array', 'plugins' => 'array', 'styles' => 'array', 'templates' => 'array')); }