public function beginRequest() { Yii::import('application.widgets.LanguageSelector'); LanguageSelector::setLanguage(); if (null === Yii::app()->session['region'] || !Region::model()->exists('id = :id', array(':id' => Yii::app()->session['region']))) { Yii::app()->session['region'] = Region::model()->getDefault()->id; assert(null !== Yii::app()->session['region']); } }
$app->get('/api/:lang/pois', function ($lang) use($app) { $app->contentType('application/json'); # return all POIs # preferred in $lang # fallback in english $languageSelector = new LanguageSelector(); $lang = $languageSelector->getLang($lang); $connector = new DrupalConnector($lang); echo $connector->getPois(); }); $app->get('/api/:lang/cities', function ($lang) use($app) { $app->contentType('application/json'); # return all POIs # preferred in $lang # fallback in english $languageSelector = new LanguageSelector(); $lang = $languageSelector->getLang($lang); $connector = new DrupalConnector($lang); echo $connector->getCities(); }); $app->get('/', function () { $template = <<<EOT <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <title>Slim Framework for PHP 5</title> <style> html,body,div,span,object,iframe, h1,h2,h3,h4,h5,h6,p,blockquote,pre, abbr,address,cite,code,