Added basic blog functionality
Signed-off-by: Gergely Polonkai (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
43
src/GergelyPolonkai/FrontBundle/Service/Slugifier.php
Normal file
43
src/GergelyPolonkai/FrontBundle/Service/Slugifier.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace GergelyPolonkai\FrontBundle\Service;
|
||||
|
||||
use JMS\DiExtraBundle\Annotation as DI;
|
||||
|
||||
/**
|
||||
* Description of Slugifier
|
||||
*
|
||||
* @author polonkai.gergely
|
||||
*
|
||||
* @DI\Service("slugifier")
|
||||
*/
|
||||
class Slugifier
|
||||
{
|
||||
public function slugify($string)
|
||||
{
|
||||
$string = strtolower(
|
||||
preg_replace(
|
||||
'/^-+/',
|
||||
'',
|
||||
preg_replace(
|
||||
'/-+$/',
|
||||
'',
|
||||
preg_replace(
|
||||
'/[^a-z]+/i',
|
||||
'-',
|
||||
preg_replace(
|
||||
'/([a-z])[":\']/i',
|
||||
'\1',
|
||||
iconv(
|
||||
'UTF-8',
|
||||
'ASCII//TRANSLIT',
|
||||
$string
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user