Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

POC Option to preserve slashes when slugifying #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 10 additions & 2 deletions TokenProvider/ContentMethodProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -45,6 +52,7 @@ public function configureOptions(OptionsResolverInterface $optionsResolver)

$optionsResolver->setDefaults(array(
'slugify' => true,
'preserve_slashes' => false,
));

$newApi = method_exists($optionsResolver, 'setDefined');
Expand Down