Skip to content

Commit 9ced1ba

Browse files
committed
Route: removed support for #class in route mask (BC break)
#class manipulators Route::addStyle() and setStyleProperty() are deprecated since 2.1.
1 parent 7099d4c commit 9ced1ba

File tree

1 file changed

+9
-24
lines changed

1 file changed

+9
-24
lines changed

src/Application/Routers/Route.php

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -468,29 +468,22 @@ private function setMask($mask, array $metadata)
468468
}
469469

470470
// PARSE MASK
471-
// <parameter-name[=default] [pattern] [#class]> or [ or ] or ?...
472-
$parts = Strings::split($mask, '/<([^>#= ]+)(=[^># ]*)? *([^>#]*)(#?[^>\[\]]*)>|(\[!?|\]|\s*\?.*)/');
471+
// <parameter-name[=default] [pattern]> or [ or ] or ?...
472+
$parts = Strings::split($mask, '/<([^>= ]+)(=[^> ]*)? *([^>]*)>|(\[!?|\]|\s*\?.*)/');
473473

474474
$this->xlat = [];
475475
$i = count($parts) - 1;
476476

477477
// PARSE QUERY PART OF MASK
478478
if (isset($parts[$i - 1]) && substr(ltrim($parts[$i - 1]), 0, 1) === '?') {
479-
// name=<parameter-name [pattern][#class]>
480-
$matches = Strings::matchAll($parts[$i - 1], '/(?:([a-zA-Z0-9_.-]+)=)?<([^># ]+) *([^>#]*)(#?[^>]*)>/');
479+
// name=<parameter-name [pattern]>
480+
$matches = Strings::matchAll($parts[$i - 1], '/(?:([a-zA-Z0-9_.-]+)=)?<([^> ]+) *([^>]*)>/');
481481

482482
foreach ($matches as $match) {
483-
list(, $param, $name, $pattern, $class) = $match; // $pattern is not used
483+
list(, $param, $name, $pattern) = $match; // $pattern is not used
484484

485-
if ($class !== '') {
486-
if (!isset(static::$styles[$class])) {
487-
throw new Nette\InvalidStateException("Parameter '$name' has '$class' flag, but Route::\$styles['$class'] is not set.");
488-
}
489-
$meta = static::$styles[$class];
490-
491-
} elseif (isset(static::$styles['?' . $name])) {
485+
if (isset(static::$styles['?' . $name])) {
492486
$meta = static::$styles['?' . $name];
493-
494487
} else {
495488
$meta = static::$styles['?#'];
496489
}
@@ -511,7 +504,7 @@ private function setMask($mask, array $metadata)
511504
$this->xlat[$name] = $param;
512505
}
513506
}
514-
$i -= 6;
507+
$i -= 5;
515508
}
516509

517510
// PARSE PATH PART OF MASK
@@ -536,11 +529,10 @@ private function setMask($mask, array $metadata)
536529
}
537530
array_unshift($sequence, $part);
538531
$re = ($part[0] === '[' ? '(?:' : ')?') . $re;
539-
$i -= 5;
532+
$i -= 4;
540533
continue;
541534
}
542535

543-
$class = $parts[$i]; $i--; // validation class
544536
$pattern = trim($parts[$i]); $i--; // validation condition (as regexp)
545537
$default = $parts[$i]; $i--; // default value
546538
$name = $parts[$i]; $i--; // parameter name
@@ -554,15 +546,8 @@ private function setMask($mask, array $metadata)
554546
}
555547

556548
// pattern, condition & metadata
557-
if ($class !== '') {
558-
if (!isset(static::$styles[$class])) {
559-
throw new Nette\InvalidStateException("Parameter '$name' has '$class' flag, but Route::\$styles['$class'] is not set.");
560-
}
561-
$meta = static::$styles[$class];
562-
563-
} elseif (isset(static::$styles[$name])) {
549+
if (isset(static::$styles[$name])) {
564550
$meta = static::$styles[$name];
565-
566551
} else {
567552
$meta = static::$styles['#'];
568553
}

0 commit comments

Comments
 (0)