Skip to content

Commit

Permalink
Merge pull request #250 from franmomu/symfony_support
Browse files Browse the repository at this point in the history
Update Symfony Support
  • Loading branch information
florianeckerstorfer authored Dec 5, 2019
2 parents 0129bfb + b35b8ea commit 34924a7
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 207 deletions.
32 changes: 2 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Developed by [Florian Eckerstorfer](https://florian.ec) in Vienna, Europe with t
characters. Instead of removing these characters, Slugify approximates them (e.g., `ae` replaces `ä`).
- No external dependencies.
- PSR-4 compatible.
- Compatible with PHP >= 5.5.9 and PHP 7.
- Integrations for [Symfony (2 and 3)](https://symfony.com), [Silex (1 and 2)](https://silex.sensiolabs.org), [Laravel](https://laravel.com),
- Compatible with PHP >= 7.
- Integrations for [Symfony (3, 4 and 5)](https://symfony.com), [Laravel](https://laravel.com),
[Twig (1 and 2)](https://twig.sensiolabs.org), [Zend Framework 2](https://framework.zend.com/), [Nette Framework](https://nette.org/),
[Latte](https://latte.nette.org/) and [Plum](https://github.com/plumphp/plum).

Expand Down Expand Up @@ -292,34 +292,6 @@ Slugify extension using a closure:
You can find more information about registering extensions in the
[Twig documentation](https://twig.sensiolabs.org/doc/advanced.html#creating-an-extension).

### Silex

Slugify also provides a service provider to integrate into Silex.

```php
// For Silex version 1
$app->register(new Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider());
```

```php
// For Silex version 2
$app->register(new Cocur\Slugify\Bridge\Silex2\SlugifyServiceProvider());
```

You can use the `slugify` method in your controllers:

```php
$app->get('/', function () {
return $app['slugify']->slugify('welcome to the homepage');
});
```

And if you use Silex in combination with Twig register the `SlugifyServiceProvider` after the `Silex\Provider\TwigServiceProvider` to add the Twig extension to your environment and use the `slugify` filter in your templates.

```twig
{{ 'welcome to the homepage'|slugify }}
```

### Mustache.php

We don't need an additional integration to use Slugify in [Mustache.php](https://github.com/bobthecow/mustache.php).
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@
"phpunit/phpunit": "^5.7.27",
"pimple/pimple": "~1.1",
"plumphp/plum": "~0.1",
"silex/silex": "~1.3",
"symfony/config": "~2.4 || ~3.0 || ~4.0",
"symfony/dependency-injection": "~2.4 || ~3.0 || ~4.0",
"symfony/http-kernel": "~2.4 || ~3.0 || ~4.0",
"symfony/config": "^3.4 || ^4.3 || ^5.0",
"symfony/dependency-injection": "^3.4 || ^4.3 || ^5.0",
"symfony/http-kernel": "^3.4 || ^4.3 || ^5.0",
"twig/twig": "^1.42.4 || ^2.12.1 || ~3.0",
"zendframework/zend-modulemanager": "~2.2",
"zendframework/zend-servicemanager": "~2.2",
Expand Down
57 changes: 0 additions & 57 deletions src/Bridge/Silex/SlugifyServiceProvider.php

This file was deleted.

48 changes: 0 additions & 48 deletions src/Bridge/Silex2/SlugifyServiceProvider.php

This file was deleted.

7 changes: 1 addition & 6 deletions src/Bridge/Symfony/CocurSlugifyExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\HttpKernel\Kernel;

/**
* CocurSlugifyExtension
Expand Down Expand Up @@ -58,10 +57,6 @@ public function load(array $configs, ContainerBuilder $container)
->addTag('twig.extension')
->setPublic(false);
$container->setAlias('slugify', 'cocur_slugify');

// for symfony versions >= 3.3
if (Kernel::VERSION_ID >= 30300) {
$container->setAlias('Cocur\Slugify\SlugifyInterface', 'cocur_slugify');
}
$container->setAlias('Cocur\Slugify\SlugifyInterface', 'cocur_slugify');
}
}
62 changes: 0 additions & 62 deletions tests/Bridge/Silex/SlugifySilexProviderTest.php

This file was deleted.

4 changes: 4 additions & 0 deletions tests/Bridge/Symfony/CocurSlugifyExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public function testLoad()
->shouldReceive('setAlias')
->with('slugify', 'cocur_slugify')
->once();
$container
->shouldReceive('setAlias')
->with('Cocur\Slugify\SlugifyInterface', 'cocur_slugify')
->once();

$this->extension->load([], $container);
}
Expand Down

0 comments on commit 34924a7

Please sign in to comment.