当前位置: 首页>>代码示例>>PHP>>正文


PHP Routes::getControllerRelativeUrl方法代码示例

本文整理汇总了PHP中Routes::getControllerRelativeUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::getControllerRelativeUrl方法的具体用法?PHP Routes::getControllerRelativeUrl怎么用?PHP Routes::getControllerRelativeUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Routes的用法示例。


在下文中一共展示了Routes::getControllerRelativeUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendVerificationEmail

 /**
  * Sends the verification email to this user if their email addresss
  * has not already been verified.
  * @return boolean
  */
 public function sendVerificationEmail()
 {
     // Force the user to get a new verification code
     $newCode = $this->getNewEmailVerificationCode();
     // Now send it to them
     $url = APP_ABSOLUTE_URL . Routes::getControllerRelativeUrl('user#verify', array('userid' => $this->getUserId(), 'code' => $newCode));
     return $this->sendEmail('Please verify your email address', 'You can verify your email address by clicking <a href="' . $url . '">here</a>');
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:13,代码来源:user.php

示例2: create

 /**
  * Creates a new notification for a user.
  * @param User $user The user to notify.
  * @param type $message The message to deliver.
  * @return Notificaton
  * @throws Exception
  */
 public static function create(User $user, $message, $controller = '', $replacements = array(), $imageurl = '')
 {
     // Make sure the user is not a guest
     if ($user->isGuest()) {
         throw new Exception('Notifications cannot be created for guests.');
     }
     $link = '';
     if (!empty($controller)) {
         $link = Routes::getControllerRelativeUrl($controller, $replacements);
     }
     // Add the notification to the database
     $query = Database::connection()->prepare('INSERT INTO user_notification (userid, created_at, message, link, image_url) VALUES (?, ?, ?, ?, ?)');
     $query->bindValue(1, $user->getUserId(), PDO::PARAM_INT);
     $query->bindValue(2, time(), PDO::PARAM_INT);
     $query->bindValue(3, $message, PDO::PARAM_STR);
     $query->bindValue(4, $link, PDO::PARAM_STR);
     $query->bindValue(5, $imageurl, PDO::PARAM_STR);
     if (!$query->execute()) {
         throw new Exception('Notification could not be created.');
     }
     // Let's send an email right away
     return Notification::fromId(Database::connection()->lastInsertId());
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:30,代码来源:notification.php

示例3: initialize

 /**
  * Initializes the templating system.
  */
 private static function initialize()
 {
     // Make sure it's not already initialized
     if (self::$initialized) {
         return;
     }
     // Load up and register Twig
     require_once APP_VENDOR_PATH . '/Twig/Autoloader.php';
     Twig_Autoloader::register();
     // Greate the environment
     $loader = new Twig_Loader_Filesystem(APP_VIEWS_PATH);
     $loader->addPath(APP_VIEWS_PATH . '/shared');
     $loader->addPath(APP_VIEWS_PATH_CORE);
     $loader->addPath(APP_VIEWS_PATH_CORE . '/shared');
     $twig = new Twig_Environment($loader, array('auto_reload' => true));
     // Add in the custom twig functions
     // The getPath function turns controller endpoints into relative
     // urls that can be used in the interface.
     $getPathFunction = new Twig_SimpleFunction("get_path", function () {
         $args = func_get_args();
         if (count($args) == 0) {
             return;
         }
         $controller = $args[0];
         array_shift($args);
         return Routes::getControllerRelativeUrl($controller, $args);
     });
     $twig->addFunction($getPathFunction);
     // Used to make images square with no distortion
     $avatarFunction = new Twig_SimpleFunction("avatar", function () {
         $args = func_get_args();
         $addon = '';
         if (count($args) == 2 && $args[1] == true) {
             $addon = '-small';
         } else {
             if (count($args) > 1) {
                 return;
             }
         }
         if (empty($args[0])) {
             $url = Routes::getControllerRelativeUrl('image#noavatar');
         } else {
             $url = Routes::getControllerRelativeUrl('image#viewthumb', array($args[0]));
         }
         echo '<div class="avatar-wrapper"><div class="avatar' . $addon . '" style="background-image: url(\'' . $url . '\');"></div></div>';
     });
     $twig->addFunction($avatarFunction);
     // Used to make images square with no distortion
     $friendlyUrlFunction = new Twig_SimpleFunction("seo_friendly", function () {
         $args = func_get_args();
         if (count($args) != 1) {
             return;
         }
         return Utils::makeSeoFriendly($args[0]);
     });
     $twig->addFunction($friendlyUrlFunction);
     // The public function allows the interface to get public resources
     $publicResourceFunction = new Twig_SimpleFunction("public_path", function ($path) {
         echo APP_RELATIVE_URL . '/public/' . Routes::fixPath($path);
     });
     $twig->addFunction($publicResourceFunction);
     // Set the reference
     self::$twig = $twig;
     self::$initialized = true;
 }
开发者ID:brandonfrancis,项目名称:scsapi,代码行数:68,代码来源:view.php


注:本文中的Routes::getControllerRelativeUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。