當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Event::hasHandlers方法代碼示例

本文整理匯總了PHP中yii\base\Event::hasHandlers方法的典型用法代碼示例。如果您正苦於以下問題:PHP Event::hasHandlers方法的具體用法?PHP Event::hasHandlers怎麽用?PHP Event::hasHandlers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在yii\base\Event的用法示例。


在下文中一共展示了Event::hasHandlers方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_MigrationEvent

 public function test_MigrationEvent()
 {
     try {
         $this->cleanDb();
         $this->mockYiiApplication();
         \Yii::$app->mycfg->system->version = null;
         // to trigger migration event
         $bootstrap = new MyLibraryBootstrap();
         $bootstrap->bootstrap(\Yii::$app);
         $this->assertTrue(\yii\base\Event::hasHandlers(\app\components\Controller::class, \app\components\Controller::EVENT_BEFORE_ACTION), 'migration event for controller was not added');
     } finally {
         $this->resetConnection();
     }
 }
開發者ID:yurii-github,項目名稱:yii2-mylib,代碼行數:14,代碼來源:MyLibraryBootstrapTest.php

示例2: testHasHandlers

 public function testHasHandlers()
 {
     $this->assertFalse(Event::hasHandlers(Post::className(), 'save'));
     $this->assertFalse(Event::hasHandlers(ActiveRecord::className(), 'save'));
     Event::on(Post::className(), 'save', function ($event) {
         $this->counter += 1;
     });
     $this->assertTrue(Event::hasHandlers(Post::className(), 'save'));
     $this->assertFalse(Event::hasHandlers(ActiveRecord::className(), 'save'));
     $this->assertFalse(Event::hasHandlers(User::className(), 'save'));
     Event::on(ActiveRecord::className(), 'save', function ($event) {
         $this->counter += 1;
     });
     $this->assertTrue(Event::hasHandlers(User::className(), 'save'));
     $this->assertTrue(Event::hasHandlers(ActiveRecord::className(), 'save'));
 }
開發者ID:howq,項目名稱:yii2,代碼行數:16,代碼來源:EventTest.php

示例3: hasEventHandlers

 /**
  * Returns a value indicating whether there is any handler attached to the named event.
  * @param string $name the event name
  * @return boolean whether there is any handler attached to the event.
  */
 public function hasEventHandlers($name)
 {
     $this->ensureBehaviors();
     return !empty($this->_events[$name]) || Event::hasHandlers($this, $name);
 }
開發者ID:hakudjin,項目名稱:yii2,代碼行數:10,代碼來源:Component.php

示例4: hasEventHandlers

 /**
  * Returns a value indicating whether there is any handler attached to the named event.
  *
  * 判斷 _events 中的一個 event 是否具有 handler
  * @param string $name the event name
  * @return boolean whether there is any handler attached to the event.
  */
 public function hasEventHandlers($name)
 {
     $this->ensureBehaviors();
     // _events 中存在 $name 的 event 或者 $name 的 event 是否含有該對象所在的類的 handler
     return !empty($this->_events[$name]) || Event::hasHandlers($this, $name);
 }
開發者ID:glcode,項目名稱:yii2-2.0.3-annotated,代碼行數:13,代碼來源:Component.php

示例5: hasEventHandlers

 /**
  * Returns a value indicating whether there is any handler attached to the named event.
  * @param string $name the event name
  * @return boolean whether there is any handler attached to the event.
  */
 public function hasEventHandlers($name)
 {
     $this->ensureBehaviors();
     if (!empty($this->_events[$name])) {
         return true;
     } else {
         return Event::hasHandlers($this, $name);
     }
 }
開發者ID:syca0516,項目名稱:yii2,代碼行數:14,代碼來源:Component.php


注:本文中的yii\base\Event::hasHandlers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。