Skip to content

Commit 1854b9c

Browse files
committed
Merge commit '2248f2d'
2 parents 70ea169 + 2248f2d commit 1854b9c

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Bridges/SymfonyConsole/CreateCommand.php

+17-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Console\Input\InputInterface;
1717
use Symfony\Component\Console\Input\InputOption;
1818
use Symfony\Component\Console\Output\OutputInterface;
19+
use Symfony\Component\String\Slugger\AsciiSlugger;
1920

2021

2122
class CreateCommand extends BaseCommand
@@ -118,7 +119,7 @@ protected function getGroup($type)
118119

119120
$matchedGroups = [];
120121
foreach ($this->config->getGroups() as $group) {
121-
if (Strings::match($group->name, $groupNamePattern)) {
122+
if (preg_match($groupNamePattern, $group->name)) {
122123
$matchedGroups[] = $group;
123124
}
124125
}
@@ -148,7 +149,21 @@ protected function getGroup($type)
148149
*/
149150
protected function getFileName($label, $extension)
150151
{
151-
return date('Y-m-d-His-') . Strings::webalize($label, '.') . '.' . $extension;
152+
if (preg_match('#^[a-z0-9.-]++$#i', $label)) {
153+
$slug = strtolower($label);
154+
155+
} elseif (class_exists('Nette\Utils\Strings')) {
156+
$slug = Strings::webalize($label, '.');
157+
158+
} elseif (class_exists('Symfony\Component\String\Slugger\AsciiSlugger')) {
159+
$slugger = new AsciiSlugger('en');
160+
$slug = $slugger->slug($label)->toString();
161+
162+
} else {
163+
throw new Nextras\Migrations\LogicException("Provided label '$label' contains invalid characters.");
164+
}
165+
166+
return date('Y-m-d-His-') . $slug . '.' . $extension;
152167
}
153168

154169

src/Configurations/Configuration.php

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Nextras\Migrations\Configurations;
1111

12-
use Nette\Utils\Validators;
1312
use Nextras\Migrations\Entities\Group;
1413
use Nextras\Migrations\IConfiguration;
1514
use Nextras\Migrations\IExtensionHandler;

0 commit comments

Comments
 (0)