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


PHP CakeEvent::subject方法代码示例

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


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

示例1: onLogin

 /**
  * AuthController onLogin
  * @param CakeEvent $event
  */
 public function onLogin($event)
 {
     $this->log(__("User '%s' just logged in", $event->data['username']), 'auth');
     //Write LastLogin Date
     $event->subject()->BackendUser->id = $event->data['id'];
     $event->subject()->BackendUser->saveField('last_login', date("Y-m-d H:i:s"));
     //return $redirectUri;
 }
开发者ID:fm-labs,项目名称:cakephp-backend,代码行数:12,代码来源:BackendEventListener.php

示例2: onSubscribeNewTopic

 /**
  * Start the keep alive timer when the first client subscribes
  *
  * @param CakeEvent $event
  */
 public function onSubscribeNewTopic(CakeEvent $event)
 {
     if (Configure::read('Ratchet.Connection.keepaliveInterval') > 0) {
         $this->__timer = $this->__loop->addPeriodicTimer(Configure::read('Ratchet.Connection.keepaliveInterval'), function () use($event) {
             $event->subject()->broadcast('Rachet.connection.keepAlive', ['ping']);
         });
         $event->subject()->broadcast('Rachet.connection.keepAlive', ['ping']);
     }
 }
开发者ID:schnauss,项目名称:Ratchet,代码行数:14,代码来源:RatchetKeepAliveListener.php

示例3: formAfterInput

 /**
  * formAfterInput
  * 
  * @param CakeEvent $event
  * @return string
  */
 public function formAfterInput(CakeEvent $event)
 {
     if (!BcUtil::isAdminSystem()) {
         return $event->data['out'];
     }
     $View = $event->subject();
     if (!in_array($View->request->params['controller'], $this->targetController)) {
         return $event->data['out'];
     }
     if (!in_array($View->request->params['action'], $this->targetAction)) {
         return $event->data['out'];
     }
     if (!isset($View->request->data['KeywordConfig'])) {
         return $event->data['out'];
     }
     if (!$View->request->data['KeywordConfig']['status']) {
         return $event->data['out'];
     }
     // 固定ページ:入力欄の下にキーワード入力欄を表示する
     if ($event->data['fieldName'] == 'Page.description') {
         $event->data['out'] = $event->data['out'] . $View->element('Keyword.keyword_form');
     }
     // ブログ記事:記事タイトル入力欄の下にキーワード入力欄を表示する
     if ($event->data['fieldName'] == 'BlogPost.name') {
         $event->data['out'] = $event->data['out'] . $View->element('Keyword.keyword_form');
     }
     return $event->data['out'];
 }
开发者ID:ichi280,项目名称:keyword,代码行数:34,代码来源:KeywordHelperEventListener.php

示例4: modelConstruct

 public function modelConstruct(CakeEvent $Event)
 {
     $Model = $Event->subject();
     // Because, by default, the SQL is only logged and displayed if debug > 2; using the `DebugKit`
     // new 'autoRun' and/or 'forceEnable' still doesn't help in profiling SQL calls in production.
     // This will force the current model's datasource to log all SQL calls ONLY when in production
     // mode and DebugKit is used with either 'autoRun' or 'forceEnable'.
     if (Reveal::is('DebugKit.running') && !Reveal::is('Page.test')) {
         $Model->getDatasource()->fullDebug = true;
     }
     if (!isset($Model->belongsToForeignModels)) {
         return;
     }
     // Get all foreign models used if not defined by current model.
     if (empty($Model->belongsToForeignModels)) {
         $foreignModels = $Model->find('all', array('fields' => array('DISTINCT' => 'foreign_model'), 'recursive' => -1, 'callbacks' => false));
         foreach ($foreignModels as $foreignModel) {
             // Rarely, some tokens are not associated with any other model.
             if (empty($foreignModel[$Model->alias]['foreign_model'])) {
                 continue;
             }
             list($plugin, $name) = pluginSplit($foreignModel[$Model->alias]['foreign_model']);
             $Model->belongsToForeignModels[$name] = array('className' => $foreignModel[$Model->alias]['foreign_model'], 'foreignKey' => 'foreign_key', 'conditions' => null, 'fields' => null, 'order' => null, 'counterCache' => false);
         }
     }
     // Associate foreign `belongsTo` models.
     $Event->result = Hash::merge((array) $Event->result, array('belongsTo' => array_merge($Model->belongsTo, $Model->belongsToForeignModels)));
 }
开发者ID:gourmet,项目名称:common,代码行数:28,代码来源:CommonEventListener.php

示例5: formAfterEnd

 /**
  * formAfterCreate
  * 
  * @param CakeEvent $event
  * @return array
  */
 public function formAfterEnd(CakeEvent $event)
 {
     $Form = $event->subject();
     if ($Form->request->params['controller'] == 'blog_posts') {
         if (!empty($Form->request->data['PetitBlogCustomFieldConfig']['status'])) {
             // ブログ記事追加画面にプチ・カスタムフィールド編集欄を追加する
             if ($Form->request->action == 'admin_add') {
                 if ($event->data['id'] == 'BlogPostForm') {
                     $event->data['out'] = $event->data['out'] . $Form->element('PetitBlogCustomField.petit_blog_custom_field_form');
                 }
             }
             // ブログ記事編集画面にプチ・カスタムフィールド編集欄を追加する
             if ($Form->request->action == 'admin_edit') {
                 if ($event->data['id'] == 'BlogPostForm') {
                     $event->data['out'] = $event->data['out'] . $Form->element('PetitBlogCustomField.petit_blog_custom_field_form');
                 }
             }
         }
     }
     if ($Form->request->params['controller'] == 'blog_contents') {
         // ブログ設定編集画面にプチ・カスタムフィールド設定欄を表示する
         if ($Form->request->action == 'admin_edit') {
             if ($event->data['id'] == 'BlogContentAdminEditForm') {
                 $event->data['out'] = $event->data['out'] . $Form->element('PetitBlogCustomField.petit_blog_custom_field_config_form');
             }
         }
         // ブログ追加画面にプチ・カスタムフィールド設定欄を表示する
         if ($Form->request->action == 'admin_add') {
             if ($event->data['id'] == 'BlogContentAdminAddForm') {
                 $event->data['out'] = $event->data['out'] . $Form->element('PetitBlogCustomField.petit_blog_custom_field_config_form');
             }
         }
     }
     return $event->data['out'];
 }
开发者ID:gondoh,项目名称:petit_blog_custom_field,代码行数:41,代码来源:PetitBlogCustomFieldHelperEventListener.php

示例6: testSubject

 /**
  * Tests the subject() method
  *
  * @return void
  * @triggers fake.event $this
  * @triggers fake.event
  */
 public function testSubject()
 {
     $event = new CakeEvent('fake.event', $this);
     $this->assertSame($this, $event->subject());
     $event = new CakeEvent('fake.event');
     $this->assertNull($event->subject());
 }
开发者ID:keetamhoang,项目名称:lotdephong,代码行数:14,代码来源:CakeEventTest.php

示例7: onAdminLoginSuccessful

 /**
  * onAdminLoginSuccessful
  *
  * @param CakeEvent $event
  * @return void
  */
 public function onAdminLoginSuccessful($event)
 {
     $Controller = $event->subject();
     $message = __('Welcome %s.  Have a nice day', $Controller->Auth->user('name'));
     $Controller->Session->setFlash($message);
     $Controller->redirect(array('admin' => true, 'plugin' => 'example', 'controller' => 'example', 'action' => 'index'));
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:13,代码来源:ExampleEventHandler.php

示例8: construct

 /**
  * References the ReactPHP eventloop for later use
  *
  * @param CakeEvent $event
  */
 public function construct(CakeEvent $event)
 {
     if (!function_exists('pcntl_signal')) {
         $event->subject()->getShell()->out('<warning>Your configuration doesn\'t seem to support \'ext-pcntl\'. It is highly recomended that you install and configure it as it provides OS signaling support!</warning>');
     } elseif (!class_exists('MKraemer\\ReactPCNTL\\PCNTL')) {
         $event->subject()->getShell()->out('<warning>PCNTL support found but you didn\'t install mkraemer/react-pcntl!</warning>');
     } else {
         $pcntl = new MKraemer\ReactPCNTL\PCNTL($event->data['loop']);
         $pcntl->on(SIGTERM, function () use($event) {
             $event->data['loop']->stop();
         });
         $pcntl->on(SIGINT, function () use($event) {
             $event->data['loop']->stop();
         });
     }
 }
开发者ID:schnauss,项目名称:Ratchet,代码行数:21,代码来源:PcntlListener.php

示例9: formAfterSubmit

 /**
  * Form After Submit
  *
  * フォームの保存ボタンの前後に、一覧、プレビュー、削除ボタンを配置する
  * プレビューを配置する場合は、設定にて、preview を true にする
  *
  * @param CakeEvent $event
  * @return string
  */
 public function formAfterSubmit(CakeEvent $event)
 {
     if (!BcUtil::isAdminSystem()) {
         return;
     }
     $View = $event->subject();
     $data = $View->request->data;
     if (!preg_match('/(AdminEditForm|AdminEditAliasForm)$/', $event->data['id'])) {
         return;
     }
     $output = $View->BcHtml->link('一覧に戻る', array('plugin' => '', 'admin' => true, 'controller' => 'contents', 'action' => 'index'), array('class' => 'button'));
     $setting = Configure::read('BcContents.items.' . $data['Content']['plugin'] . '.' . $data['Content']['type']);
     if (!empty($setting['preview']) && $data['Content']['type'] != 'ContentFolder') {
         $output .= "\n" . $View->BcForm->button('プレビュー', array('class' => 'button', 'id' => 'BtnPreview'));
     }
     $output .= $event->data['out'];
     if (empty($data['Content']['site_root'])) {
         if ($data['Content']['alias_id']) {
             $deleteText = '削除';
         } else {
             $deleteText = 'ゴミ箱へ移動';
         }
         $output .= $View->BcForm->button($deleteText, array('class' => 'button', 'id' => 'BtnDelete'));
     }
     return $output;
 }
开发者ID:baserproject,项目名称:basercms,代码行数:35,代码来源:BcContentsEventListener.php

示例10: blogBlogBeforeRender

 /**
  * 拡張BlogHelperを呼び出しに追加
  *
  */
 public function blogBlogBeforeRender(CakeEvent $event)
 {
     $path = App::pluginPath('ExHelper');
     // ヘルパーのパスを追加
     App::build(array('View/Helper' => array($path . 'View' . DS . 'Helper' . DS)), APP::APPEND);
     $Controller = $event->subject();
     $Controller->helpers[] = 'ExBlog';
 }
开发者ID:n1215,项目名称:ExHelper,代码行数:12,代码来源:ExHelperControllerEventListener.php

示例11: afterRender

 /**
  * After Render
  * 
  * @param CakeEvent $event
  */
 public function afterRender(CakeEvent $event)
 {
     if (BcUtil::isAdminSystem()) {
         return;
     }
     $View = $event->subject();
     $this->_execShortCode($View);
 }
开发者ID:baserproject,项目名称:basercms,代码行数:13,代码来源:BcShortCodeEventListener.php

示例12: handleAfterCreateComment

 /**
  * Test event listener for before create comment
  *
  * @param CakeEvent $event
  * @return mixed
  */
 public function handleAfterCreateComment(CakeEvent $event)
 {
     $data = $event->data;
     $model = $event->subject();
     $comment = $model->Comment->read(null, $data['Comment']['id']);
     $comment['Comment']['body'] = 'Changed in afterComment!';
     $model->Comment->save($comment);
     return $data;
 }
开发者ID:jxav,项目名称:comments,代码行数:15,代码来源:CommentEventListener.php

示例13: blogBlogStartup

 function blogBlogStartup(CakeEvent $event)
 {
     $Controller = $event->subject();
     if (!isset($Controller->contentId) || $Controller->contentId != Configure::read('BlogShare.contentId')) {
         return;
     }
     $dbConfigName = Configure::read('BlogShare.dbConfigName');
     $Controller->BlogPost->setDataSource($dbConfigName);
     $Controller->BlogPost->BlogCategory->setDataSource($dbConfigName);
     $Controller->BlogPost->BlogTag->setDataSource($dbConfigName);
 }
开发者ID:ryuring,项目名称:basercms-blog_share,代码行数:11,代码来源:BlogShareControllerEventListener.php

示例14: pageBeforeSave

 public function pageBeforeSave(CakeEvent $event)
 {
     $Page = $event->subject();
     $tmhkConverter = new TmhkConverter();
     $targetColums = array('title', 'contents', 'draft');
     foreach ($Page->data['Page'] as $k => $v) {
         if (in_array($k, $targetColums) && is_string($v)) {
             $Page->data['Page'][$k] = $tmhkConverter->convert($v);
         }
     }
     return true;
 }
开发者ID:kaburk,项目名称:TokushuMojiHenkanKun,代码行数:12,代码来源:TokushuMojiHenkanKunModelEventListener.php

示例15: calculateTotals

 public function calculateTotals(CakeEvent $Event)
 {
     $Model = $Event->subject();
     $cartData = $Event->data['cartData'];
     $cartData[$Model->alias]['total'] = 0.0;
     if (!empty($cartData['CartsItem'])) {
         foreach ($cartData['CartsItem'] as $key => $item) {
             $cartData['CartsItem'][$key]['total'] = (double) $item['quantity'] * (double) $item['price'];
             $cartData[$Model->alias]['total'] += (double) $cartData['CartsItem'][$key]['total'];
         }
     }
     return $cartData;
 }
开发者ID:mikebirch,项目名称:cakephp-cart-plugin,代码行数:13,代码来源:DefaultCartEventListener.php


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