Skip to content

Commit 69a9638

Browse files
committed
Include legacy interface in this package
1 parent 9a86001 commit 69a9638

File tree

5 files changed

+54
-10
lines changed

5 files changed

+54
-10
lines changed

CoreBundle/CallbackSlugifier.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2016 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Cmf\Bundle\CoreBundle\Slugifier;
13+
14+
use Symfony\Cmf\Api\Slugifier\CallbackSlugifier as ApiCallbackSlugifier;
15+
16+
/**
17+
* Slugifier service which uses a callback.
18+
*
19+
* @author Daniel Leech <[email protected]>
20+
*/
21+
class CallbackSlugifier extends ApiCallbackSlugifier
22+
{
23+
public function __construct($callback)
24+
{
25+
trigger_error('The '.__CLASS__.' is deprecated as of version 1.0 and will be removed in 2.0. Use Symfony\Cmf\Api\Slugifier\CallbackSlugifier instead.', E_USER_DEPRECATED);
26+
27+
parent::__construct($callback);
28+
}
29+
}

CoreBundle/SlugifierInterface.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Symfony\Cmf\Bundle\CoreBundle\Slugifier;
4+
5+
/**
6+
* @deprecated Since 1.0, to be removed in 2.0. Use Symfony\Cmf\Api\Slugifier\SlugifierInterface instead.
7+
*/
8+
interface SlugifierInterface {
9+
/**
10+
* Return a slugified (or urlized) representation of a given string.
11+
*
12+
* @param string $string
13+
*
14+
* @return string
15+
*/
16+
public function slugify($string);
17+
}

SlugifierInterface.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@
1616
*
1717
* @author Daniel Leech <[email protected]>
1818
*/
19-
interface SlugifierInterface
19+
interface SlugifierInterface extends \Symfony\Cmf\Bundle\CoreBundle\Slugifier\SlugifierInterface
2020
{
21-
/**
22-
* Return a slugified (or urlized) representation of a given string.
23-
*
24-
* @param string $string
25-
*
26-
* @return string
27-
*/
28-
public function slugify($string);
2921
}

Tests/CallbackSlugifierTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public function testSlugify()
2929
$this->assertEquals('this-is-slugified', $this->slugifier->slugify('this is slugified'));
3030
}
3131

32+
public function testLegacyInterface()
33+
{
34+
$this->assertInstanceOf('Symfony\Cmf\Bundle\CoreBundle\Slugifier\SlugifierInterface', $this->slugifier);
35+
}
36+
3237
public static function slugify($val)
3338
{
3439
return str_replace(' ', '-', $val);

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
},
1616
"autoload": {
1717
"psr-4": {
18-
"Symfony\\Cmf\\Api\\Slugifier\\": ""
18+
"Symfony\\Cmf\\Api\\Slugifier\\": "",
19+
"Symfony\\Cmf\\Bundle\\CoreBundle\\Slugifier\\": "CoreBundle"
1920
}
2021
},
2122
"extra": {

0 commit comments

Comments
 (0)