当前位置: 首页>>代码示例>>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;未经允许,请勿转载。