예제 #1
0
 /** @return Nette\Application\Routers\RouteList */
 public function create()
 {
     $ls = '[<locale=' . $this->defaultLocale . ' ' . implode('|', $this->availableLocales) . '>/]';
     $r = new RouteList();
     $r[] = new Route($ls . 'page/<page>', ['module' => 'Front', 'presenter' => 'Page', 'action' => 'default']);
     $r[] = new Route($ls . 'articles[/page-<p>]', Route::meta('Front:Articles', 'default', ['p' => 'articles-paginator-page']));
     $r[] = new Route($ls . 'user[/<action>]', Route::meta('Front:User', 'default'));
     $r[] = new Route($ls . '[<module=Front>[/p-<presenter>[/a-<action>]]]', ['presenter' => 'Default', 'action' => 'default']);
     return $r;
 }
예제 #2
0
 public static function createMetadata($presenter, $action = NULL, $aliases = array(), $persistentBoolParams = array())
 {
     if (is_array($presenter)) {
         $metadata = $presenter;
         list(, $aliases, $persistentBoolParams) = func_get_args();
     } else {
         $metadata = ['presenter' => $presenter];
         if (strlen($action) > 0) {
             $metadata['action'] = $action;
         }
     }
     if (count($aliases) > 0) {
         $metadata[NULL] = Route::createAliases($aliases);
     }
     if (count($persistentBoolParams) > 0) {
         foreach ($persistentBoolParams as $param) {
             $metadata[$param] = [Route::FILTER_IN => function () {
                 return TRUE;
             }, Route::FILTER_OUT => function () use($param) {
                 return $param;
             }];
         }
     }
     return $metadata;
 }