i wrote a signalslot extension for tx_news which extends the detailAction. The dispatcher works as expected when a news in detail view is called. But when the detail page is called without valid parameters for a existing news entry i get the following error:
Oops, an error occurred!
Argument 1 passed to .....\Slots\NewsControllerSlot::detailActionSlot() must be an instance of GeorgRinger\News\Domain\Model\News, null given
The error is easy to understand:
public function detailActionSlot(News $newsItem, $currentPage, $demand, $settings, $extendedVariables)
the first parameter $newsItem is missing.
But how can i avoid the error? Thanks!
David Bruchmann gave me a hint:
public function detailActionSlot(News $newsItem = null, $currentPage, $demand, $settings, $extendedVariables)
{
if (is_object($newsItem)) {
// do stuff here
}
}
works perfectly even the 404 is thrown.