Skip to content

Commit

Permalink
Merge pull request #110 from Th3Mouk/master
Browse files Browse the repository at this point in the history
[UPT] CKEditor dependency to ~3.0
  • Loading branch information
OskarStark committed Feb 25, 2016
2 parents fb42dec + 8182809 commit a665525
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ A [BC BREAK] means the update will break the project for many reasons:
* new dependencies
* class refactoring

### 2015-10-05

* Update [IvoryCKEditorBundle](https://github.com/egeloen/IvoryCKEditorBundle) to version 3.x.

### 2014-09-01

* [BC BREAK] Dependency to SonataMarkItUpBundle has been set to require-dev only. You'll need to update your assets path as follows:
Expand Down
6 changes: 6 additions & 0 deletions Resources/config/twig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
<service id="sonata.formatter.twig.control_flow" class="Sonata\FormatterBundle\Extension\ControlFlowExtension" public="true">

</service>

<!--Bridge to keep BC between 2.x and 3.x-->
<service id="sonata.formatter.twig.ck_editor" class="Sonata\FormatterBundle\Twig\Extension\CKEditorExtension">
<argument type="service" id="ivory_ck_editor.templating.helper" />
<tag name="twig.extension" />
</service>
</services>

</container>
7 changes: 4 additions & 3 deletions Resources/views/Form/formatter.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
appendClass = 'html';
break;
case 'richhtml':
{{ source_id }}_rich_instance = {{ ckeditor_replace(form.children[source_field].vars.id, ckeditor_configuration) }};
{{ source_id }}_rich_instance = {{
ckeditor_widget(form.children[source_field].vars.id, ckeditor_configuration)
}};
}
var parent = elms.parents('div.markItUp');
Expand Down Expand Up @@ -98,7 +99,7 @@
{% elseif format == 'rawhtml' %}
elms.markItUp(markitup_sonataHtmlSettings);
{% elseif format == 'richhtml' %}
{{ ckeditor_replace(form.vars.id, ckeditor_configuration) }};
{{ ckeditor_widget(form.vars.id, ckeditor_configuration) }};
{% endif %}
var parent = elms.parents('div.markItUp');
Expand Down
69 changes: 69 additions & 0 deletions Twig/Extension/CKEditorExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Sonata\FormatterBundle\Twig\Extension;

use Ivory\CKEditorBundle\Templating\CKEditorHelper;

/**
* @author Marodon Jérémy <marodon.jeremy@gmail.com>
*/
class CKEditorExtension extends \Twig_Extension
{
/**
* @var CKEditorHelper
*/
private $helper;

/**
* Creates a CKEditor extension bridge for BC.
*
* @param CKEditorHelper $helper The CKEditor helper.
*/
public function __construct(CKEditorHelper $helper)
{
$this->helper = $helper;
}

/**
* {@inheritdoc}
*/
public function getFunctions()
{
$options = array('is_safe' => array('html'));

return array(
new \Twig_SimpleFunction('ckeditor_replace', array($this, 'renderReplace'), $options),
);
}

/**
* @param string $identifier The identifier.
* @param array $config The config.
*
* @return string The rendered replace.
*/
public function renderReplace($identifier, array $config)
{
@trigger_error('The ckeditor_replace twig function is now deprecated
and will be removed in 3.0. Use ckeditor_widget instead.', E_USER_DEPRECATED);

return $this->helper->renderWidget($identifier, $config);
}

/**
* {@inheritdoc}
*/
public function getName()
{
return 'ck_editor';
}
}
14 changes: 14 additions & 0 deletions UPGRADE-2.4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
UPGRADE FROM 2.3 to 2.4
=======================

Update [IvoryCKEditorBundle](https://github.com/egeloen/IvoryCKEditorBundle) to version 3.x.

The old ```{{ ckeditor_replace() }}``` twig function has been replaced by ```{{ckeditor_widget() }}```.

[BC] is kept due to a CKEditorExtension, which bridge the old tag ```{{ckeditor_replace() }}```
to the new helper method `renderWidget`.

This introduce the new `inline` option of CKEditor plugin.

All related changes are available here [IvoryCKEditorUPGRADE]
(https://github.com/egeloen/IvoryCKEditorBundle/blob/master/UPGRADE.md#25-to-30)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"symfony/property-access": "~2.3|~3.0",
"twig/twig": "~1.12",
"knplabs/knp-markdown-bundle": "~1.4",
"egeloen/ckeditor-bundle": "~2.2",
"egeloen/ckeditor-bundle": "^2.2|^3.0",
"sonata-project/block-bundle": "~2.2,>=2.2.1",
"sonata-project/core-bundle": "~2.3,>=2.3.1"
},
Expand Down

0 comments on commit a665525

Please sign in to comment.