Declaration of App\PostRoute::match(Nette\Http\IRequest $httpRequest) must be compatible
- vanaveno
- Člen | 144
Ahojte,
přešel jsem na Nette 3 a začala mi to u routování hlásit:
Declaration of App\PostRoute::match(Nette\Http\IRequest $httpRequest) must be compatible with Nette\Application\Routers\Route::match(Nette\Http\IRequest $httpRequest): ?array
<?php
namespace App;
use Nette;
use App\Model\PostManager;
class PostRoute extends \Nette\Application\Routers\Route
{
/** @var PostManager @inject */
public $postManager;
public function match(Nette\Http\IRequest $httpRequest)
{
$appRequest = parent::match($httpRequest);
if (!isset($appRequest->parameters['id'])) {
return null;
}
$id = $appRequest->parameters['id'];
if (!is_numeric($id)) {
$post = null;
try {
$post = $this->postManager->getPosts()->get($id)->slug;
} catch (Nette\Application\BadRequestException $exc) {
return null;
}
$appRequest->parameters['id'] = $post->id;
}
return $appRequest;
}
}
?>
Jak by to mělo prosím správně vypadat? Děkuji