Various classes to improve input handling.
<?php
$strValue = \Haste\Input\Input::getAutoItem('items');
This will check if auto_item
is activated on the given key,
and return it's value automatically.
In this example, 12 is the ID of a news item: http://example.com/item/12-news-title.html
<?php
$intId = \Haste\Input\UrlId::get('items');
$objItem = \NewsModel::findByPk($intId);
if (null === $objItem) {
// Generate 404 page
}
// Validate the news title in the URL
\Haste\Input\UrlId::validate('items', $intId, $objItem->title);
If the given name is not correct, (e.g. it would be "the-news-title"), the visitor is automatically redirected to the correct URL (using a 301 redirect).