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


PHP event::invoke方法代码示例

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


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

示例1: route

 /**
  * @brief Main router entry point
  *
  * Override this in your router to get full control over the way the
  * request is being fed to the router class.
  *
  * @return Mixed The result from the routerequest call
  */
 public function route()
 {
     Console::debugEx(LOG_VERBOSE, __CLASS__, 'Looking for event handlers before routing');
     // Invoke events first to see if anything is registered
     if (event::invoke(MvcEvent::EVENT_BEFORE_ROUTING, array('uri' => $this->_uri, 'segments' => $this->_urisegments, 'domain' => $this->_domain, 'secure' => $this->_secure)) == true) {
         return 0;
     }
     Console::debugEx(LOG_VERBOSE, __CLASS__, 'Examining static routes');
     // Determine if this is a hooked uri
     foreach (Router::$_staticroutes as $sr) {
         if (@preg_match('/' . $sr['match'] . '/', $this->_uri, $ret)) {
             call_user_func_array($sr['hook'], array_slice($ret, 1));
             return 0;
         }
     }
     Console::debugEx(LOG_VERBOSE, __CLASS__, 'Invoking the router');
     // Invoke the router
     return $this->routeRequest($this->_uri);
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:27,代码来源:router.php

示例2: setUser

 /**
  * @brief Assign a user to the current session.
  *
  * @param $id The user id to assign
  */
 protected function setUser($id)
 {
     // Check if the user is active
     $u = user::getUser($id);
     if ($u == null) {
         throw new UserException("Unassociated user id / Integrity failure", UserException::ERR_USER_UNASSOCIATED);
     }
     if (!$u->active) {
         throw new UserException("User is not active, check audit log", UserException::ERR_USER_INACTIVE);
     }
     // TODO: Assign to session
     if (ModuleManager::has('lepton.mvc.session')) {
         session::set(User::KEY_USER_AUTH, $id);
     }
     if (class_exists('request')) {
         $db = new DatabaseConnection();
         $db->updateRow("UPDATE users SET lastlogin=NOW(), lastip=%s WHERE id=%d", request::getRemoteIp(), $id);
     }
     if (class_exists('UserEvents')) {
         event::invoke(UserEvents::EVENT_USER_LOGIN, array('id' => $id));
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:27,代码来源:authentication.php

示例3: __logMessage

 function __logMessage($prio, $msg)
 {
     event::invoke(debug::EVT_DEBUG, array($prio, $msg));
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:4,代码来源:logging.php

示例4: __construct

 /**
  * @brief Constructor for Password Authentication
  *
  * @param string $username The username for which to validate the token
  * @param string $password The user's password.
  */
 public function __construct()
 {
     $token = request::get('token')->toString();
     $apikey = config::get('lepton.user.engage.apikey');
     $ret = new HttpRequest('https://rpxnow.com/api/v2/auth_info', array('method' => 'post', 'parameters' => array('apiKey' => $apikey, 'token' => $token, 'format' => 'xml')));
     $dom = DOMDocument::loadXml($ret->responseText());
     $domx = new DOMXPath($dom);
     // Get the status
     $status = $domx->query('/rsp')->item(0)->getAttribute('stat');
     if ($status == 'ok') {
         // Call on the successful callback method
         event::invoke(EngageEvents::EVENT_SUCCESSFUL_CALLBACK, array('profile' => $dom, 'profiletext' => $ret->responseText()));
         // Extract the values
         $identifier = $domx->query('/rsp/profile/identifier')->item(0)->nodeValue;
         $displayname = $domx->query('/rsp/profile/displayName')->item(0)->nodeValue;
         $provider = $domx->query('/rsp/profile/providerName')->item(0)->nodeValue;
         $firstname = $domx->query('/rsp/profile/name/givenName')->item(0)->nodeValue;
         $lastname = $domx->query('/rsp/profile/name/familyName')->item(0)->nodeValue;
         $preferredusername = $domx->query('/rsp/profile/preferredUsername')->item(0)->nodeValue;
         $email = $domx->query('/rsp/profile/email')->item(0)->nodeValue;
         // Sign in
         $db = new DatabaseConnection();
         $idrs = $db->getSingleRow("SELECT * FROM userengage WHERE identifier=%s", $identifier);
         if ($idrs) {
             $cu = $idrs['userid'];
             $db->updateRow("UPDATE userengage SET lastseen=NOW(), lastip=%s WHERE id=%d", request::getRemoteIp(), $idrs['id']);
         } else {
             if (!user::isAuthenticated()) {
                 if (!config::get(EngageAuthentication::KEY_ALLOW_CREATION, false)) {
                     throw new SecurityException("User creation is disabled for EngageAuthentication");
                 }
                 // Check username, add random numbers if not available
                 $username = $preferredusername;
                 $retrycount = 0;
                 while (!user::checkUsername($username)) {
                     $username = substr($preferredusername, 0, 6) . rand(1000, 9999);
                     $retrycount = $retrycount + 1;
                     if ($retrycount > 10) {
                         throw new UserException("Bad username");
                     }
                 }
                 // Generate a new password
                 $password = substr(md5(uniqid()), 0, 6);
                 // And create the userrecord
                 $u = new UserRecord();
                 $u->username = $username;
                 $u->password = $password;
                 $u->flags = config::get(EngageAuthentication::KEY_DEFAULT_FLAGS, EngageAuthentication::DEFAULT_FLAGS);
                 $u->displayname = $displayname;
                 $u->firstname = $firstname;
                 $u->lastname = $lastname;
                 $u->email = $email;
                 $cu = user::create($u);
                 session::set(self::SESSIONKEY_USER_CREATED, true);
             } else {
                 $cu = user::getActiveUser();
             }
             // Add identifier to user
             $db->updateRow("INSERT INTO userengage (userid,identifier,provider,lastseen,lastip) VALUES (%d,%s,%s,NOW(),%s)", $cu, $identifier, $provider, request::getRemoteIp());
         }
         $this->userid = $cu;
     } else {
         $this->userid = null;
     }
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:71,代码来源:engage.php

示例5: addHeaders

 static function addHeaders()
 {
     event::invoke(document::EVENT_HEADER, array());
 }
开发者ID:noccy80,项目名称:lepton-ng,代码行数:4,代码来源:document.php


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