Esempio n. 1
0
 /**
  * Detaches the behavior object from the component.
  * The default implementation will unset the {@link owner} property
  * and detach event handlers declared in {@link events}.
  * Make sure you call the parent implementation if you override this method.
  * @param CComponent $owner the component that this behavior is to be detached from.
  */
 public function detach($owner)
 {
     foreach ($this->events() as $event => $handler) {
         $owner->detachEventHandler($event, array($this, $handler));
     }
     $this->_owner = null;
 }
Esempio n. 2
0
 /**
  * Detaches the behavior object from the component.
  * The default implementation will unset the {@link owner} property
  * and detach event handlers declared in {@link events}.
  * This method will also set {@link enabled} to false.
  * Make sure you call the parent implementation if you override this method.
  * @param CComponent $owner the component that this behavior is to be detached from.
  */
 public function detach($owner)
 {
     foreach ($this->events() as $event => $handler) {
         $owner->detachEventHandler($event, [$this, $handler]);
     }
     $this->_owner = null;
     $this->_enabled = false;
 }
 protected function attachApiRequestBehaviors(CComponent $owner)
 {
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleSentryLogs'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleApplicationCache'));
     $owner->detachEventHandler('onBeginRequest', array(Yii::app()->request, 'validateCsrfToken'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleImports'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleSetupDatabaseConnection'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleDisableGamification'));
     $this->resolveBeginApiRequest($owner);
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleLibraryCompatibilityCheck'));
     $owner->attachEventHandler('onBeginRequest', array($this, 'handleStartPerformanceClock'));
 }
 /**
  * Dettach event hander
  *
  * @param string $name Event name
  * @param mixed $handler Event handler
  * @return bool
  */
 public function detachEventHandler($name, $handler)
 {
     foreach (self::$_events as $index => $event) {
         // when comparing 2 objects use === instead of ==
         // why? http://www.richardlord.net/blog/php-nesting-level-too-deep-recursive-dependency
         if ($event['name'] == $name && $event['handler'] === $handler) {
             unset(self::$_events[$index]);
         }
     }
     return parent::detachEventHandler($name, $handler);
 }
Esempio n. 5
0
 /**
  * Dettach event hander
  *
  * @param string $name Event name
  * @param mixed $handler Event handler
  * @return bool
  */
 public function detachEventHandler($name, $handler)
 {
     foreach (self::$_events as $index => $event) {
         if ($event['name'] == $name && $event['handler'] == $handler) {
             unset(self::$_events[$index]);
         }
     }
     return parent::detachEventHandler($name, $handler);
 }