Skip to content

Commit

Permalink
Merge pull request #113 from jmsche/doctrine-inflector
Browse files Browse the repository at this point in the history
Doctrine inflector upgrade
  • Loading branch information
sguionni authored May 14, 2020
2 parents e25e17e + e81711a commit b9d42d4
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG-3.x.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
CHANGELOG FOR 3.X
=================

3.1.0
-----

* Minimum PHP version set to 7.2
* Upgraded `doctrine/inflector` requirement from `^1.3` to `^1.4|2.0` to fix deprecations
* Added first test

3.0.3
-----

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The changelog is available here: [CHANGELOG-3.x.md](CHANGELOG-3.x.md).

## Migration to Froala Editor bundle v3 from v2

The Froala Editor bundle got a major upgrade from v2 to v3. It now supports only Symfony 4.3+ and requires PHP 7.1.3+.
The Froala Editor bundle got a major upgrade from v2 to v3. It now supports only Symfony 4.3+ and requires PHP 7.2+.

As the static files are no longer included (so you don't have to upgrade this bundle for each Froala release) you can
import assets the way you need (using the install command described below or eg. from your public directory).
Expand Down
23 changes: 19 additions & 4 deletions Service/PluginProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

namespace KMS\FroalaEditorBundle\Service;

use Doctrine\Common\Inflector\Inflector;
use Doctrine\Inflector\CachedWordInflector;
use Doctrine\Inflector\Inflector;
use Doctrine\Inflector\RulesetInflector;
use Doctrine\Inflector\Rules\English;

/**
* Class PluginProvider
Expand Down Expand Up @@ -70,6 +73,11 @@ class PluginProvider
private static $ARR_THIRD_PARTY_CONFIG =
array();

/**
* @var Inflector
*/
protected $inflector;

/**
* @const string
*/
Expand Down Expand Up @@ -97,8 +105,15 @@ class PluginProvider
*/
public function __construct()
{
//------------------------- DECLARE ---------------------------//
}
$this->inflector = new Inflector(
new CachedWordInflector(new RulesetInflector(
English\Rules::getSingularRuleset()
)),
new CachedWordInflector(new RulesetInflector(
English\Rules::getPluralRuleset()
))
);
}

//-------------------------------------------------------------//
//--------------------------- METHODS -------------------------//
Expand Down Expand Up @@ -180,7 +195,7 @@ public function obtainArrPluginCamelized( $p_arrPlugin )

foreach( $p_arrPlugin as $plugin )
{
$arrPlugin[] = Inflector::camelize( $plugin );
$arrPlugin[] = $this->inflector->camelize( $plugin );
}

return $arrPlugin;
Expand Down
26 changes: 26 additions & 0 deletions Tests/Service/PluginProviderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace KMS\FroalaEditorBundle\Tests\Service;

use KMS\FroalaEditorBundle\Service\PluginProvider;
use PHPUnit\Framework\TestCase;

final class PluginProviderTest extends TestCase
{
/**
* @var PluginProvider
*/
private $provider;

protected function setUp(): void
{
$this->provider = new PluginProvider();
}

public function testObtainArrPluginCamelized(): void
{
static::assertSame(['paragraphFormat'], $this->provider->obtainArrPluginCamelized(['paragraph_format']));
}
}
3 changes: 3 additions & 0 deletions Tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

require_once __DIR__ . '/../vendor/autoload.php';
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
}
],
"require": {
"php": "^7.1.3",
"php": "^7.2",
"ext-zip": "*",
"doctrine/inflector": "^1.3",
"doctrine/inflector": "^1.4|^2.0",
"symfony/console": "^4.3|^5.0",
"symfony/framework-bundle": "^4.3|^5.0",
"symfony/form": "^4.3|^5.0",
Expand All @@ -26,6 +26,7 @@
"twig/twig": "^1.1|^2.0|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.1",
"symfony/yaml": "^4.3|^5.0"
},
"autoload": {
Expand Down
11 changes: 11 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit
bootstrap="Tests/bootstrap.php"
>
<testsuites>
<testsuite name="KMSFroalaEditorBundle Test Suite">
<directory>./Tests/</directory>
</testsuite>
</testsuites>
</phpunit>

0 comments on commit b9d42d4

Please sign in to comment.