Skip to content

Commit

Permalink
Merge commit '2248f2d'
Browse files Browse the repository at this point in the history
  • Loading branch information
JanTvrdik committed Jun 14, 2022
2 parents 70ea169 + 2248f2d commit 1854b9c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
19 changes: 17 additions & 2 deletions src/Bridges/SymfonyConsole/CreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\String\Slugger\AsciiSlugger;


class CreateCommand extends BaseCommand
Expand Down Expand Up @@ -118,7 +119,7 @@ protected function getGroup($type)

$matchedGroups = [];
foreach ($this->config->getGroups() as $group) {
if (Strings::match($group->name, $groupNamePattern)) {
if (preg_match($groupNamePattern, $group->name)) {
$matchedGroups[] = $group;
}
}
Expand Down Expand Up @@ -148,7 +149,21 @@ protected function getGroup($type)
*/
protected function getFileName($label, $extension)
{
return date('Y-m-d-His-') . Strings::webalize($label, '.') . '.' . $extension;
if (preg_match('#^[a-z0-9.-]++$#i', $label)) {
$slug = strtolower($label);

} elseif (class_exists('Nette\Utils\Strings')) {
$slug = Strings::webalize($label, '.');

} elseif (class_exists('Symfony\Component\String\Slugger\AsciiSlugger')) {
$slugger = new AsciiSlugger('en');
$slug = $slugger->slug($label)->toString();

} else {
throw new Nextras\Migrations\LogicException("Provided label '$label' contains invalid characters.");
}

return date('Y-m-d-His-') . $slug . '.' . $extension;
}


Expand Down
1 change: 0 additions & 1 deletion src/Configurations/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Nextras\Migrations\Configurations;

use Nette\Utils\Validators;
use Nextras\Migrations\Entities\Group;
use Nextras\Migrations\IConfiguration;
use Nextras\Migrations\IExtensionHandler;
Expand Down

0 comments on commit 1854b9c

Please sign in to comment.