Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

move to FOSCKEditor-Bundle #135

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .phpunit/.gitemtpy.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>

</body>
</html>
5 changes: 4 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ before_install:
- if [ "$SYMFONY_VERSION" != "" ]; then composer require symfony/symfony:${SYMFONY_VERSION} --no-update; fi
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)

install: travis_wait composer update --prefer-dist $COMPOSER_FLAGS
install:
- phpenv config-add travis.php.ini
- php -ini | grep memory_limit
- travis_wait composer update --prefer-dist $COMPOSER_FLAGS

script:
- if [ "${TEST_INSTALLATION}" == true ]; then make test_installation; else make test; fi
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": "^7.1",
"symfony/framework-bundle": "^2.8 || ^3.3 || ^4.0",
"sonata-project/doctrine-phpcr-admin-bundle": "^2.1",
"sonata-project/doctrine-phpcr-admin-bundle": "^2.2",
"sonata-project/admin-bundle": "^3.6.0",
"symfony-cmf/tree-browser-bundle": "^2.0"
},
Expand All @@ -37,10 +37,10 @@
"matthiasnoback/symfony-dependency-injection-test": "^1.1",
"matthiasnoback/symfony-config-test": "^2.1",
"burgov/key-value-form-bundle": "^1.0",
"egeloen/ckeditor-bundle": "^4.0",
"symfony/asset": "^2.8 || ^3.3 || ^4.0",
"symfony/browser-kit": "^2.8 || ^3.3 || ^4.0",
"symfony/css-selector": "^2.8 || ^3.3 || ^4.0"
"symfony/css-selector": "^2.8 || ^3.3 || ^4.0",
"friendsofsymfony/ckeditor-bundle": "^1.0"
},
"suggest": {
"symfony-cmf/routing-bundle": "To make use of the alternate locale provider.",
Expand Down
5 changes: 0 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,4 @@
</exclude>
</whitelist>
</filter>

<php>
<server name="KERNEL_DIR" value="tests/Resources/app" />
</php>

</phpunit>
4 changes: 2 additions & 2 deletions src/Admin/Content/StaticContentAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\Admin\Content;

use Ivory\CKEditorBundle\Form\Type\CKEditorType;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function getExportFormats()
/**
* Set configuration for CKEditorType.
*
* Documentation: http://symfony.com/doc/master/bundles/IvoryCKEditorBundle/usage/config.html
* Documentation: http://symfony.com/doc/master/bundles/FOSCKEditorBundle/usage/config.html
*
* @param array $config configuration for CKEditorType
*/
Expand Down
32 changes: 23 additions & 9 deletions src/DependencyInjection/Factory/ContentAdminFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Cmf\Bundle\SonataPhpcrAdminIntegrationBundle\DependencyInjection\Factory;

use Ivory\CKEditorBundle\IvoryCKEditorBundle;
use FOS\CKEditorBundle\FOSCKEditorBundle;
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
use Symfony\Component\DependencyInjection\ContainerBuilder;
Expand Down Expand Up @@ -39,6 +39,7 @@ public function addConfiguration(NodeBuilder $builder)
{
$builder
->arrayNode('ivory_ckeditor')
->setDeprecated('IvoryCKEditorBundle was moved into the FOSCKeditorBundle. Pleas this one will not do anything at the end')
->treatFalseLike(['enabled' => false])
->treatTrueLike(['enabled' => true])
->treatNullLike(['enabled' => 'auto'])
Expand All @@ -52,6 +53,19 @@ public function addConfiguration(NodeBuilder $builder)
->scalarNode('config_name')->end()
->end()
->end()
->arrayNode('fos_ck_editor')
->treatFalseLike(['enabled' => false])
->treatTrueLike(['enabled' => true])
->treatNullLike(['enabled' => 'auto'])
->addDefaultsIfNotSet()
->ignoreExtraKeys()
->children()
->enumNode('enabled')
->values([true, false, 'auto'])
->defaultValue('auto')
->end()
->scalarNode('config_name')->end()
->end()
;
}

Expand All @@ -62,22 +76,22 @@ public function create(array $config, ContainerBuilder $container, XmlFileLoader
{
$loader->load('content.xml');

$message = 'IvoryCKEditorBundle integration was explicitely enabled, but the bundle is not available.';
if (class_exists(IvoryCKEditorBundle::class)) {
$message = 'FOSCKEditorBundle integration was explicitely enabled, but the bundle is not available.';
if (class_exists(FOSCKEditorBundle::class)) {
$message .= ' (did you forget to register the bundle in the AppKernel?)';
}

$ckeditorConfig = [];
if ($this->isConfigEnabledAuto($container, $config['ivory_ckeditor']['enabled'], 'IvoryCKEditorBundle', $message)) {
if (!isset($config['ivory_ckeditor']['config_name'])) {
throw new InvalidConfigurationException('The cmf_sonata_phpcr_admin_integration.bundles.content.ivory_ckeditor.config_name setting has to be defined when IvoryCKEditorBundle integration is enabled.');
if ($this->isConfigEnabledAuto($container, $config['fos_ck_editor']['enabled'], 'FOSCKEditorBundle', $message)) {
if (!isset($config['fos_ck_editor']['config_name'])) {
throw new InvalidConfigurationException('The cmf_sonata_phpcr_admin_integration.bundles.content.fos_ck_editor.config_name setting has to be defined when FOSCKEditorBundle integration is enabled.');
}

unset($config['ivory_ckeditor']['enabled']);
unset($config['fos_ck_editor']['enabled']);

$ckeditorConfig = $config['ivory_ckeditor'];
$ckeditorConfig = $config['fos_ck_editor'];
}

$container->setParameter('cmf_sonata_phpcr_admin_integration.content.ivory_ckeditor', $ckeditorConfig);
$container->setParameter('cmf_sonata_phpcr_admin_integration.content.fos_ck_editor', $ckeditorConfig);
}
}
2 changes: 1 addition & 1 deletion src/Resources/config/content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</call>

<call method="setCkEditorConfig">
<argument>%cmf_sonata_phpcr_admin_integration.content.ivory_ckeditor%</argument>
<argument>%cmf_sonata_phpcr_admin_integration.content.fos_ck_editor%</argument>
</call>
</service>
</services>
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/App/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* file that was distributed with this source code.
*/

use FOS\CKEditorBundle\FOSCKEditorBundle;
use Knp\Bundle\MenuBundle\KnpMenuBundle;
use Sonata\AdminBundle\SonataAdminBundle;
use Sonata\BlockBundle\SonataBlockBundle;
Expand All @@ -27,11 +28,11 @@
Symfony\Cmf\Bundle\MenuBundle\CmfMenuBundle::class => ['all' => true],
Symfony\Cmf\Bundle\ContentBundle\CmfContentBundle::class => ['all' => true],
JMS\SerializerBundle\JMSSerializerBundle::class => ['all' => true],
Ivory\CKEditorBundle\IvoryCKEditorBundle::class => ['all' => true],
SonataBlockBundle::class => ['all' => true],
SonataCoreBundle::class => ['all' => true],
SonataAdminBundle::class => ['all' => true],
KnpMenuBundle::class => ['all' => true],
SonataDoctrinePHPCRAdminBundle::class => ['all' => true],
CmfTreeBrowserBundle::class => ['all' => true],
FOSCKEditorBundle::class => ['all' => true],
];
4 changes: 2 additions & 2 deletions tests/Fixtures/App/config/cmf_sonata_admin_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmf_sonata_phpcr_admin_integration:
core: ~
menu: ~
content:
ivory_ckeditor: { config_name: cmf_sonata_admin_integration }
fos_ck_editor: { config_name: cmf_sonata_admin_integration }

routing:
basepath: /test/routing
Expand Down Expand Up @@ -44,7 +44,7 @@ cmf_core:
multilang:
locales: [en, de]

ivory_ck_editor:
fos_ck_editor:
configs:
cmf_sonata_admin_integration: { toolbar: standard }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ protected function setUp()
{
$this->factory = new ContentAdminFactory();
$this->container = new ContainerBuilder();
$this->container->setParameter('kernel.bundles', ['IvoryCKEditorBundle' => true]);
$this->container->setParameter('kernel.bundles', ['FOSCKEditorBundle' => true]);
$this->fileLoader = $this->createMock(XmlFileLoader::class);
}

/**
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
* @expectedExceptionMessage config_name setting has to be defined when IvoryCKEditorBundle integration is enabled
* @expectedExceptionMessage config_name setting has to be defined when FOSCKEditorBundle integration is enabled
*/
public function testInvalidCKEditorEnabledWithoutConfigName()
{
Expand All @@ -56,26 +56,26 @@ public function testCKEditorDisabledWithoutConfigName()
{
$config = $this->process($this->buildConfig(), [[
'bundles' => [
'content' => ['ivory_ckeditor' => false],
'content' => ['fos_ck_editor' => false],
],
]]);

$this->create($config);

$this->assertEquals([], $this->container->getParameter('cmf_sonata_phpcr_admin_integration.content.ivory_ckeditor'));
$this->assertEquals([], $this->container->getParameter('cmf_sonata_phpcr_admin_integration.content.fos_ck_editor'));
}

public function testCKEditorEnabledWithConfigName()
{
$config = $this->process($this->buildConfig(), [[
'bundles' => [
'content' => ['ivory_ckeditor' => ['config_name' => 'default']],
'content' => ['fos_ck_editor' => ['config_name' => 'default']],
],
]]);

$this->create($config);

$this->assertEquals(['config_name' => 'default'], $this->container->getParameter('cmf_sonata_phpcr_admin_integration.content.ivory_ckeditor'));
$this->assertEquals(['config_name' => 'default'], $this->container->getParameter('cmf_sonata_phpcr_admin_integration.content.fos_ck_editor'));
}

protected function buildConfig()
Expand Down
1 change: 1 addition & 0 deletions travis.php.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
memory_limit = -1