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


PHP Event::data方法代码示例

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


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

示例1: afterCasAuthenticate

 public function afterCasAuthenticate(Event $event)
 {
     $user = $event->data();
     if (empty($user['username'])) {
         return null;
     }
     if (!array_key_exists('id', $user)) {
         $user['id'] = $user['username'];
     }
     $localUser = TableRegistry::get('Users')->findOrCreateByNetid($user['username'], true);
     //force PersonSummary update check
     if (empty($localUser)) {
         return null;
     }
     $user['id'] = $localUser->id;
     if (empty($user['name']) && !empty($localUser->name)) {
         $user['name'] = $localUser->name;
     }
     if (empty($user['byuId']) && !empty($localUser->byu_id)) {
         $user['byuId'] = $localUser->byu_id;
     }
     $user['officers'] = TableRegistry::get('Officers')->listUserActive($localUser->id);
     $user['advisors'] = TableRegistry::get('Advisors')->listUserApproved($localUser->id);
     $user['members'] = TableRegistry::get('Members')->listActiveClubs($localUser->id);
     $user['roles'] = TableRegistry::get('Roles')->listByUser($localUser->id);
     $user['roles']['dean'] = TableRegistry::get('Departments')->listByDean($user['username']);
     $homePrefixes = ['admin', 'dean', 'risk', 'review'];
     //roles that have a default home, in descending preference order
     foreach ($homePrefixes as $prefix) {
         if (!empty($user['roles'][$prefix])) {
             $user['default_home'] = ['prefix' => $prefix, 'controller' => 'clubs', 'action' => 'index'];
         }
     }
     return $user;
 }
开发者ID:byu-oit-appdev,项目名称:byusa-clubs,代码行数:35,代码来源:AppController.php

示例2: _callListener

 /**
  * Calls a listener.
  *
  * Direct callback invocation is up to 30% faster than using call_user_func_array.
  * Optimize the common cases to provide improved performance.
  *
  * @param callable $listener The listener to trigger.
  * @param \Cake\Event\Event $event Event instance.
  * @return mixed The result of the $listener function.
  */
 protected function _callListener(callable $listener, Event $event)
 {
     $data = $event->data();
     $length = count($data);
     if ($length) {
         $data = array_values($data);
     }
     switch ($length) {
         case 0:
             return $listener($event);
         case 1:
             return $listener($event, $data[0]);
         case 2:
             return $listener($event, $data[0], $data[1]);
         case 3:
             return $listener($event, $data[0], $data[1], $data[2]);
         default:
             array_unshift($data, $event);
             return call_user_func_array($listener, $data);
     }
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:31,代码来源:EventManager.php


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