• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Event\Event类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: beforeDispatch

 public function beforeDispatch(Event $event)
 {
     $event->stopPropagation();
     $response = new Response(['body' => $this->config('message')]);
     $response->httpCodes([429 => 'Too Many Requests']);
     $response->statusCode(429);
     return $response;
 }
开发者ID:Adnan0703,项目名称:Throttle,代码行数:8,代码来源:ThrottleFilter.php


示例2: 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


示例3: onSuccessRegister

 /**
  * Send an activation link on success registered user
  * @param Event $event
  */
 public function onSuccessRegister(Event $event)
 {
     $controller = $event->subject();
     $user = $event->data['user'];
     $controller->_sendActivationEmail($user)->template('Bazibartar.register')->subject('فعال سازی حساب کاربری')->send();
     $controller->Flash->success(__d('users', 'you are success register, and an activation email has been send, check your email'));
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:11,代码来源:UsersEventHandler.php


示例4: beforeDispatch

 /**
  * Checks whether the response was cached and set the body accordingly.
  *
  * @param \Cake\Event\Event $event containing the request and response object
  * @return \Cake\Network\Response with cached content if found, null otherwise
  */
 public function beforeDispatch(Event $event)
 {
     if (Configure::read('Cache.check') !== true) {
         return;
     }
     $path = $event->data['request']->here();
     if ($path === '/') {
         $path = 'home';
     }
     $prefix = Configure::read('Cache.viewPrefix');
     if ($prefix) {
         $path = $prefix . '_' . $path;
     }
     $path = strtolower(Inflector::slug($path));
     $filename = CACHE . 'views/' . $path . '.php';
     if (!file_exists($filename)) {
         $filename = CACHE . 'views/' . $path . '_index.php';
     }
     if (file_exists($filename)) {
         $controller = null;
         $view = new View($controller);
         $view->response = $event->data['response'];
         $result = $view->renderCache($filename, microtime(true));
         if ($result !== false) {
             $event->stopPropagation();
             $event->data['response']->body($result);
             return $event->data['response'];
         }
     }
 }
开发者ID:ripzappa0924,项目名称:carte0.0.1,代码行数:36,代码来源:CacheDispatcher.php


示例5: beforeDispatch

 /**
  * Checks if a requested cache file exists and sends it to the browser
  *
  * @param \Cake\Event\Event $event containing the request and response object
  *
  * @return \Cake\Network\Response|null Response if the client is requesting a recognized cache file, null otherwise
  */
 public function beforeDispatch(Event $event)
 {
     if (Configure::read('Cache.check') === false) {
         return null;
     }
     /* @var \Cake\Network\Request $request */
     $request = $event->data['request'];
     $url = $request->here();
     $url = str_replace($request->base, '', $url);
     $file = $this->getFile($url);
     if ($file === null) {
         return null;
     }
     $cacheContent = $this->extractCacheContent($file);
     $cacheInfo = $this->extractCacheInfo($cacheContent);
     $cacheTime = $cacheInfo['time'];
     if ($cacheTime < time() && $cacheTime != 0) {
         unlink($file);
         return null;
     }
     /* @var \Cake\Network\Response $response */
     $response = $event->data['response'];
     $event->stopPropagation();
     $response->modified(filemtime($file));
     if ($response->checkNotModified($request)) {
         return $response;
     }
     $pathSegments = explode('.', $file);
     $ext = array_pop($pathSegments);
     $this->_deliverCacheFile($request, $response, $file, $ext);
     return $response;
 }
开发者ID:dereuromark,项目名称:cakephp-cache,代码行数:39,代码来源:CacheFilter.php


示例6: startup

 /**
  * Startup callback.
  *
  * @param Event $event
  */
 public function startup(Event $event)
 {
     if (!$event->subject()->isAdmin()) {
         $this->__setForLayout();
         $this->__createModules();
     }
 }
开发者ID:Cheren,项目名称:union,代码行数:12,代码来源:ModuleComponent.php


示例7: beforeSave

 public function beforeSave(Event $event, Officer $officer, \ArrayObject $options)
 {
     if ($officer->isNew()) {
         return true;
     }
     if (!$officer->dirty('member_id')) {
         return true;
     }
     //Ensure no UI screwup tried to move "officer" record to different club
     $originalMemberId = $officer->getOriginal('member_id');
     $memberId = $officer->get('member_id');
     try {
         $originalMember = $this->Members->get($originalMemberId);
         $member = $this->Members->get($memberId);
     } catch (RecordNotFoundException $e) {
         $event->stopPropagation();
         return false;
     }
     if ($originalMember->club_id != $member->club_id) {
         //Somehow messed up and attempting to switch Officer record to different club
         $event->stopPropagation();
         return false;
     }
     return true;
 }
开发者ID:byu-oit-appdev,项目名称:byusa-clubs,代码行数:25,代码来源:OfficersTable.php


示例8: shutdown

 /**
  * Data collection callback.
  *
  * @param \Cake\Event\Event $event The shutdown event.
  * @return void
  */
 public function shutdown(Event $event)
 {
     /* @var Controller $controller */
     $controller = $event->subject();
     $request = $controller->request;
     $this->_data = ['params' => $request->params, 'query' => $request->query, 'data' => $request->data, 'cookie' => $request->cookies, 'get' => $_GET, 'matchedRoute' => $request->param('_matchedRoute'), 'headers' => ['response' => headers_sent($file, $line), 'file' => $file, 'line' => $line]];
 }
开发者ID:cakephp,项目名称:debug_kit,代码行数:13,代码来源:RequestPanel.php


示例9: beforeFiler

 /**
  * beforeFilter initTabsItems
  *
  * @param Cake/Event/Event $event Event
  * @return void
  */
 public function beforeFiler(Event $event)
 {
     $this->setController($event->subject());
     if (method_exists($this->Controller, 'initTabsItems')) {
         $this->Controller->initTabsItems($event);
     }
 }
开发者ID:crabstudio,项目名称:app,代码行数:13,代码来源:TabsComponent.php


示例10: getFooter

 /**
  * Method that adds footer element to the Layout.
  *
  * @param  Cake\Event\Event $event Event object
  * @return void
  */
 public function getFooter(Event $event)
 {
     if (!$event->subject()->elementExists(static::ELEMENT_FOOTER)) {
         return;
     }
     $event->result = $event->subject()->element(static::ELEMENT_FOOTER);
 }
开发者ID:QoboLtd,项目名称:cakephp-qobo-admin-panel,代码行数:13,代码来源:LayoutListener.php


示例11: beforeFilter

 /**
  * Callback
  *
  * @param \Cake\Event\Event $event
  * @return \Cake\Network\Response|array|null
  */
 public function beforeFilter(Event $event)
 {
     $this->Controller = $event->subject();
     if (!$this->config('enabled')) {
         return null;
     }
     if ($actions = $this->config('actions')) {
         $action = !empty($this->Controller->request->params['action']) ? $this->Controller->request->params['action'] : '';
         if (!in_array($action, $actions)) {
             return null;
         }
     }
     $this->Controller->request->params['isJson'] = isset($this->Controller->request->params['url']['_ext']) && $this->Controller->request->params['url']['_ext'] === 'json';
     $modelName = $this->config('modelName');
     if (empty($modelName)) {
         $modelName = $this->Controller->modelClass;
     }
     list(, $modelName) = pluginSplit($modelName);
     $this->config('modelName', $modelName);
     if (!$this->Controller->{$modelName}->behaviors()->has('Ratable')) {
         $this->Controller->{$modelName}->behaviors()->load('Ratings.Ratable', $this->_config);
     }
     $this->Controller->helpers[] = 'Ratings.Rating';
     $params = $this->request->data + $this->request->query + $this->_config['params'];
     if (!method_exists($this->Controller, 'rate')) {
         if (isset($params['rate']) && isset($params['rating'])) {
             $userId = $this->config('userId') ?: $this->Controller->Auth->user($this->config('userIdField'));
             return $this->rate($params['rate'], $params['rating'], $userId, $params['redirect']);
         }
     }
 }
开发者ID:dereuromark,项目名称:cakephp-ratings,代码行数:37,代码来源:RatingsComponent.php


示例12: testPropagation

 /**
  * Tests the event propagation stopping property
  *
  * @return void
  * @triggers fake.event
  */
 public function testPropagation()
 {
     $event = new Event('fake.event');
     $this->assertFalse($event->isStopped());
     $event->stopPropagation();
     $this->assertTrue($event->isStopped());
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:13,代码来源:EventTest.php


示例13: shutdown

 /**
  * Shutdown event
  *
  * @param \Cake\Event\Event $event The event
  * @return void
  */
 public function shutdown(Event $event)
 {
     $controller = $event->subject();
     $errors = [];
     array_walk_recursive($controller->viewVars, function (&$item) {
         // Execute queries so we can show the results in the toolbar.
         if ($item instanceof Query) {
             $item = $item->all();
         }
         if ($item instanceof Closure || $item instanceof PDO || $item instanceof SimpleXmlElement) {
             $item = 'Unserializable object - ' . get_class($item);
         }
         if ($item instanceof Exception) {
             $item = sprintf('Unserializable object - %s. Error: %s in %s, line %s', get_class($item), $item->getMessage(), $item->getFile(), $item->getLine());
         }
         return $item;
     });
     foreach ($controller->viewVars as $k => $v) {
         // Get the validation errors for Entity
         if ($v instanceof EntityInterface) {
             $errors[$k] = $this->_getErrors($v);
         } elseif ($v instanceof Form) {
             $formError = $v->errors();
             if (!empty($formError)) {
                 $errors[$k] = $formError;
             }
         }
     }
     $this->_data = ['content' => $controller->viewVars, 'errors' => $errors];
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:36,代码来源:VariablesPanel.php


示例14: injectEditor

 public function injectEditor(Event $event, $layoutFile)
 {
     $_view = $event->subject();
     $content = $_view->fetch('content');
     if (Configure::read('Editorial.autoload')) {
         $searchClass = Configure::read('Editorial.autoload');
         if (empty($searchClass)) {
             $searchClass = 'editor';
         }
         $plugin = Configure::read('Editorial.editor');
         list($vendor, $class) = $this->vendorSplit($plugin);
         $searchRegex = '/(<textarea.*class\\=\\".*' . Configure::read('Editorial.class') . '.*\\"[^>]*>.*<\\/textarea>)/isU';
         //preg_match_all($searchRegex, $content, $matches);
         //debug($matches);
         if (Plugin::loaded($plugin) !== false && preg_match_all($searchRegex, $content, $matches)) {
             if (!$_view->helpers()->has('Editor')) {
                 $options['className'] = $class . '.' . $class;
                 if ($vendor) {
                     $options['className'] = $vendor . '/' . $options['className'];
                 }
                 $options['options'] = $plugin . '.defaults';
                 if ($editorDefaults = Configure::read('Editorial.' . $class . '.defaults')) {
                     $options['options'] = $editorDefaults;
                 }
                 $_view->loadHelper('Editor', $options);
                 $_view->Editor->initialize();
             }
             $_view->Editor->connect($content);
         }
     }
 }
开发者ID:mindforce,项目名称:cakephp-editorial,代码行数:31,代码来源:EditorialEvent.php


示例15: onBeforeAdminTemplateStructure

 /**
  * Hook admin actions
  * @param Event $event
  */
 public function onBeforeAdminTemplateStructure(Event $event)
 {
     $this->_View = $view = $event->subject();
     $this->__hookAdminActions();
     $this->__hookAdminBoxes();
     $this->__hookAdminForms();
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:11,代码来源:PluginManagerEventHandler.php


示例16: shutdown

 /**
  * Data collection callback.
  *
  * @param \Cake\Event\Event $event The shutdown event.
  * @return void
  */
 public function shutdown(Event $event)
 {
     $controller = $event->subject();
     /* @var \Cake\Network\Request $request */
     $request = $controller ? $controller->request : null;
     $this->_data = ['matchedRoute' => $request ? $request->param('_matchedRoute') : null];
 }
开发者ID:cakephp,项目名称:debug_kit,代码行数:13,代码来源:RoutesPanel.php


示例17: beforeDispatch

 /**
  * Checks if request is for a compiled asset, otherwise skip any operation
  *
  * @param Event $event containing the request and response object
  * @throws \Cake\Network\Exception\NotFoundException
  * @return \Cake\Network\Response|null Response if the client is requesting a recognized asset, null otherwise
  */
 public function beforeDispatch(Event $event)
 {
     $request = $event->data['request'];
     $response = $event->data['response'];
     $config = $this->_getConfig();
     $production = !Configure::read('debug');
     if ($production && !$config->general('alwaysEnableController')) {
         return null;
     }
     // Make sure the request looks like an asset.
     $targetName = $this->getName($config, $request->url);
     if (!$targetName) {
         return null;
     }
     if (isset($request->query['theme'])) {
         $config->theme($request->query['theme']);
     }
     $factory = new Factory($config);
     $assets = $factory->assetCollection();
     if (!$assets->contains($targetName)) {
         return null;
     }
     $build = $assets->get($targetName);
     try {
         $compiler = $factory->cachedCompiler();
         $contents = $compiler->generate($build);
     } catch (Exception $e) {
         throw new NotFoundException($e->getMessage());
     }
     $response->type($build->ext());
     $response->body($contents);
     $event->stopPropagation();
     return $response;
 }
开发者ID:markstory,项目名称:asset_compress,代码行数:41,代码来源:AssetCompressorFilter.php


示例18: shutdown

 /**
  * shutdown callback
  *
  * @param \Cake\Event\Event $event The event
  * @return array
  */
 public function shutdown(Event $event)
 {
     $request = $event->subject()->request;
     if ($request) {
         $this->_data = ['content' => $request->session()->read()];
     }
 }
开发者ID:fabioalvaro,项目名称:cakexuxu,代码行数:13,代码来源:SessionPanel.php


示例19: checkRecordAccess

 /**
  * Check
  *
  * @param \Cake\Event\Event $event The beforeFind event that was fired.
  * @param \Cake\ORM\Query $query Query
  * @param \ArrayObject $options The options for the query
  * @return void
  */
 public function checkRecordAccess(Event $event, Query $query, ArrayObject $options)
 {
     $table = TableRegistry::get('RolesCapabilities.Capabilities');
     // current request parameters
     $request = $table->getCurrentRequest();
     // skip if current model does not match request's model
     if (array_diff(pluginSplit($event->subject()->registryAlias()), [$request['plugin'], $request['controller']])) {
         return;
     }
     // get capability owner type identifier
     $type = $table->getTypeOwner();
     // get user's action capabilities
     $userActionCapabilities = $table->getUserActionCapabilities();
     // skip if no user's action capabilities found or no user's action
     // owner specific capabilities found for current request's action
     if (empty($userActionCapabilities)) {
         return;
     }
     if (!isset($userActionCapabilities[$request['plugin']][$request['controller']][$request['action']][$type])) {
         return;
     }
     // set query where clause based on user's owner capabilities assignment fields
     foreach ($userActionCapabilities[$request['plugin']][$request['controller']][$request['action']][$type] as $userActionCapability) {
         $query->where([$userActionCapability->getField() => $table->getCurrentUser('id')]);
     }
 }
开发者ID:QoboLtd,项目名称:cakephp-roles-capabilities,代码行数:34,代码来源:ModelBeforeFindEventsListener.php


示例20: _prettifyEntity

 /**
  * Method that prepares entity to run through pretiffy logic.
  *
  * @param  \Cake\ORM\Entity  $entity Entity
  * @param  \Cake\Event\Event $event  Event instance
  * @return void
  */
 protected function _prettifyEntity(Entity $entity, Event $event)
 {
     if (!in_array($event->subject()->request->query('format'), [static::FORMAT_PRETTY])) {
         return;
     }
     $this->_prettify($entity, $event->subject()->{$event->subject()->name}, []);
 }
开发者ID:QoboLtd,项目名称:cakephp-csv-migrations,代码行数:14,代码来源:ViewViewListener.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Event\EventManager类代码示例发布时间:2022-05-23
下一篇:
PHP Error\Debugger类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap