Skip to content

Commit

Permalink
Route, SimpleRouter: flags is deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 25, 2020
1 parent f6427bb commit fca1e15
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/Application/Routers/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public function __construct(string $mask, $metadata = [], int $flags = 0)
];
}

if ($flags) {
trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::addRoute(..., ..., $flags) instead.', E_USER_DEPRECATED);
}

$this->defaultMeta = $this->defaultMeta + self::UI_META;
$this->flags = $flags;
parent::__construct($mask, $metadata);
Expand Down Expand Up @@ -141,11 +145,10 @@ public function getConstantParameters(): array
}


/**
* Returns flags.
*/
/** @deprecated */
public function getFlags(): int
{
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
return $this->flags;
}

Expand Down
7 changes: 4 additions & 3 deletions src/Application/Routers/SimpleRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public function __construct($defaults = [], int $flags = 0)

if (isset($defaults[self::MODULE_KEY])) {
throw new Nette\DeprecatedException(__METHOD__ . '() parameter module is deprecated, use RouteList::withModule() instead.');
} elseif ($flags) {
trigger_error(__METHOD__ . '() parameter $flags is deprecated, use RouteList::add(..., $flags) instead.', E_USER_DEPRECATED);
}

$this->flags = $flags;
Expand All @@ -60,11 +62,10 @@ public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?stri
}


/**
* Returns flags.
*/
/** @deprecated */
public function getFlags(): int
{
trigger_error(__METHOD__ . '() is deprecated.', E_USER_DEPRECATED);
return $this->flags;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Routers/Route.oneWay.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require __DIR__ . '/../bootstrap.php';
require __DIR__ . '/Route.php';


$route = new Route('<presenter>/<action>', [
@$route = new Route('<presenter>/<action>', [ // @ is deprecated
'presenter' => 'Default',
'action' => 'default',
], Route::ONE_WAY);
Expand Down

0 comments on commit fca1e15

Please sign in to comment.