/** * @param RouteManager $routeManager * @return void */ public function createRouter(RouteManager $routeManager) { $routeManager->addStyle('name'); $routeManager->setStyleProperty('name', Route::FILTER_OUT, function ($url) { return Strings::webalize($url); }); $routeManager->setStyleProperty('name', Route::FILTER_IN, function ($url) { return Strings::webalize($url); }); // Front $front = $routeManager->getModule('Front'); $front[] = new Route('<presenter>[/<action>][/<id [0-9]+>[-<name [0-9a-zA-Z\\-]+>]]', ['presenter' => 'Homepage', 'action' => 'default']); }
protected function compile() { $contents = $this->content ?: $this->file->read(); $contents = str_replace(array_keys($this->phpTags), array_values($this->phpTags), $contents); // Escape php tags $contents = '<?php set_error_handler($_errorHandler);unset($_errorHandler); ?>' . $contents . '<?php restore_error_handler(); ?>'; $replace = []; preg_match_all('#\\{(!?\\$[\\w]+)\\}#', $contents, $matches); // {[!]$var} foreach ($matches[1] as $match) { $full = '{' . $match . '}'; $var = str_replace(['!'], '', $match); if (!in_array($var, $this->forbidden)) { $replace[$full] = $this->echoVar($var, !$this->autoEscape ? FALSE : !Strings::startsWith($match, '!')); } } $contents = str_replace(array_keys($replace), array_values($replace), $contents); $this->createCache($contents); }