From bf202b51db83789e33428b61b18e2bf8612a11ff Mon Sep 17 00:00:00 2001 From: dantleech Date: Fri, 12 Feb 2016 10:20:55 +0000 Subject: [PATCH] Option to preserve slashes when slugifying --- AdapterInterface.php | 1 + TokenProvider/ContentMethodProvider.php | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/AdapterInterface.php b/AdapterInterface.php index bd06bc8..2eead61 100644 --- a/AdapterInterface.php +++ b/AdapterInterface.php @@ -12,6 +12,7 @@ namespace Symfony\Cmf\Component\RoutingAuto; use Symfony\Cmf\Component\RoutingAuto\Model\AutoRouteInterface; +use Sulu\Component\DocumentManager\ClassNameInflector; /** * Adapters will abstract all persistence operations. diff --git a/TokenProvider/ContentMethodProvider.php b/TokenProvider/ContentMethodProvider.php index 9aebec5..4314129 100644 --- a/TokenProvider/ContentMethodProvider.php +++ b/TokenProvider/ContentMethodProvider.php @@ -29,11 +29,18 @@ public function __construct(SlugifierInterface $slugifier) */ protected function normalizeValue($value, UriContext $uriContext, $options) { + $values = array($value); + if ($options['preserve_slashes']) { + $values = explode('/', $value); + } + if ($options['slugify']) { - $value = $this->slugifier->slugify($value); + foreach ($values as &$value) { + $value = $this->slugifier->slugify($value); + } } - return $value; + return implode('/', $values); } /** @@ -45,6 +52,7 @@ public function configureOptions(OptionsResolverInterface $optionsResolver) $optionsResolver->setDefaults(array( 'slugify' => true, + 'preserve_slashes' => false, )); $newApi = method_exists($optionsResolver, 'setDefined');