コード例 #1
0
 function u(RequestContext $context)
 {
     $username = $context->takeNextPathComponent();
     $uriID = $context->takeNextPathComponentOrNull();
     try {
         if (empty($uriID)) {
             $user = User::loadFromUsername($username);
             return $this->render('widgets-for-user.diet-php', array('user' => $user, 'widgets' => Widget::getManyByOwner($user)));
         } else {
             $widget = Widget::getByURI(User::loadFromUsername($username), $uriID);
             return $this->renderWidgetObj($widget);
         }
     } catch (\Chipin\NoSuchUser $_) {
         return $this->pageNotFound("No such user");
     } catch (\Chipin\Widgets\NoSuchWidget $_) {
         return $this->pageNotFound("No such widget");
     }
 }