Skip to content

Commit

Permalink
removed some deprecated stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Oct 15, 2020
1 parent 9931036 commit a95acad
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 139 deletions.
8 changes: 0 additions & 8 deletions src/Application/Routers/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class Route extends Nette\Routing\Route implements Nette\Application\IRouter
],
];

/** @deprecated */
public static $styles = [];

/** @var int */
private $flags;

Expand Down Expand Up @@ -70,11 +67,6 @@ public function __construct(string $mask, $metadata = [], int $flags = 0)
}

$this->defaultMeta = $this->defaultMeta + self::UI_META;
if (self::$styles) {
trigger_error('Route::$styles is deprecated.', E_USER_DEPRECATED);
array_replace_recursive($this->defaultMeta, self::$styles);
}

$this->flags = $flags;
parent::__construct($mask, $metadata);
}
Expand Down
27 changes: 1 addition & 26 deletions src/Application/Routers/SimpleRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ final class SimpleRouter extends Nette\Routing\SimpleRouter implements Nette\App
PRESENTER_KEY = 'presenter',
MODULE_KEY = 'module';

/** @var string */
private $module = '';

/** @var int */
private $flags;

Expand All @@ -43,31 +40,14 @@ public function __construct($defaults = [], int $flags = 0)
}

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

$this->flags = $flags;
parent::__construct($defaults);
}


/**
* Maps HTTP request to an array.
*/
public function match(Nette\Http\IRequest $httpRequest): ?array
{
$params = parent::match($httpRequest);
$presenter = $params[self::PRESENTER_KEY] ?? null;
if (is_string($presenter)) {
$params[self::PRESENTER_KEY] = $this->module . $presenter;
}

return $params;
}


/**
* Constructs absolute URL from array.
*/
Expand All @@ -76,11 +56,6 @@ public function constructUrl(array $params, Nette\Http\UrlScript $refUrl): ?stri
if ($this->flags & self::ONE_WAY) {
return null;
}

if (strncmp($params[self::PRESENTER_KEY], $this->module, strlen($this->module)) !== 0) {
return null;
}
$params[self::PRESENTER_KEY] = substr($params[self::PRESENTER_KEY], strlen($this->module));
return parent::constructUrl($params, $refUrl);
}

Expand Down
24 changes: 3 additions & 21 deletions src/Application/UI/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,6 @@ final public function getParameterId(string $name): string
}


/** @deprecated */
final public function getParam($name = null, $default = null)
{
trigger_error(__METHOD__ . '() is deprecated; use getParameter() or getParameters() instead.', E_USER_DEPRECATED);
return func_num_args() ? $this->getParameter($name, $default) : $this->getParameters();
}


/********************* interface ISignalReceiver ****************d*g**/


Expand Down Expand Up @@ -287,21 +279,11 @@ public function isLinkCurrent(string $destination = null, $args = []): bool
* @param array|mixed $args
* @throws Nette\Application\AbortException
*/
public function redirect(/*int $code, string */$destination, $args = []): void
public function redirect($destination, $args = []): void
{
if (is_numeric($destination)) {
trigger_error(__METHOD__ . '() first parameter $code is deprecated; use redirectPermanent() for 301 redirect.', E_USER_DEPRECATED);
[$code, $destination, $args] = func_get_args() + [null, null, []];
if (func_num_args() > 3 || !is_array($args)) {
$args = array_slice(func_get_args(), 2);
}
} else {
$code = null;
$args = func_num_args() < 3 && is_array($args) ? $args : array_slice(func_get_args(), 1);
}

$args = func_num_args() < 3 && is_array($args) ? $args : array_slice(func_get_args(), 1);
$presenter = $this->getPresenter();
$presenter->redirectUrl($presenter->createRequest($this, $destination, $args, 'redirect'), $code);
$presenter->redirectUrl($presenter->createRequest($this, $destination, $args, 'redirect'));
}


Expand Down
16 changes: 0 additions & 16 deletions src/Application/UI/Presenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,22 +312,6 @@ protected function shutdown(Application\IResponse $response)
}


/**
* Checks authorization.
*/
public function checkRequirements($element): void
{
parent::checkRequirements($element);
$user = (array) ComponentReflection::parseAnnotation($element, 'User');
if (in_array('loggedIn', $user, true)) {
trigger_error(__METHOD__ . '() annotation @User is deprecated', E_USER_DEPRECATED);
if (!$this->getUser()->isLoggedIn()) {
throw new Application\ForbiddenRequestException;
}
}
}


/**
* This method will be called when CSRF is detected.
*/
Expand Down
13 changes: 0 additions & 13 deletions src/Bridges/ApplicationLatte/TemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,6 @@ public function createTemplate(UI\Control $control = null): UI\ITemplate
}
});

$latte->addFilter('url', function (string $s): string {
trigger_error('Filter |url is deprecated, use |escapeUrl.', E_USER_DEPRECATED);
return rawurlencode($s);
});
foreach (['normalize', 'toAscii'] as $name) {
$latte->addFilter($name, function (string $s) use ($name): string {
trigger_error("Filter |$name is deprecated.", E_USER_DEPRECATED);
return [Nette\Utils\Strings::class, $name]($s);
});
}
$latte->addFilter('null', function (): void {
trigger_error('Filter |null is deprecated.', E_USER_DEPRECATED);
});
$latte->addFilter('modifyDate', function ($time, $delta, $unit = null) {
return $time == null ? null : Nette\Utils\DateTime::from($time)->modify($delta . $unit); // intentionally ==
});
Expand Down
5 changes: 0 additions & 5 deletions tests/Bridges.Latte/TemplateFactory.filters.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,3 @@ Assert::same('1978-01-24 11:40:00', (string) $latte->invokeFilter('modifyDate',
Assert::same('1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', ['1978-05-05', '+1 day']));
Assert::same('1978-05-06 00:00:00', (string) $latte->invokeFilter('modifyDate', [new DateTime('1978-05-05'), '1day']));
Assert::same('1978-01-22 11:40:00', (string) $latte->invokeFilter('modifyDate', [254400000, -1, 'day']));


Assert::same('%25', @$latte->invokeFilter('url', ['%'])); // @ is deprecated
Assert::null(@$latte->invokeFilter('null', ['x'])); // @ is deprecated
Assert::same('', @$latte->invokeFilter('normalize', [' '])); // @ is deprecated
34 changes: 0 additions & 34 deletions tests/Routers/SimpleRouter.module.phpt

This file was deleted.

16 changes: 0 additions & 16 deletions tests/UI/Component.redirect().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,6 @@ test('', function () use ($presenter) {
});


test('', function () use ($presenter) {
@$presenter->redirect(301, 'foo', ['arg' => 1]); // @ is deprecated
Assert::type(Nette\Application\Responses\RedirectResponse::class, $presenter->response);
Assert::same(301, $presenter->response->getCode());
Assert::same('http://localhost/?arg=1&action=foo&presenter=test', $presenter->response->getUrl());
});


test('', function () use ($presenter) {
@$presenter->redirect(301, 'foo', 2); // @ is deprecated
Assert::type(Nette\Application\Responses\RedirectResponse::class, $presenter->response);
Assert::same(301, $presenter->response->getCode());
Assert::same('http://localhost/?val=2&action=foo&presenter=test', $presenter->response->getUrl());
});


test('', function () use ($presenter) {
$presenter->redirectPermanent('foo', 2);
Assert::type(Nette\Application\Responses\RedirectResponse::class, $presenter->response);
Expand Down

0 comments on commit a95acad

Please sign in to comment.