示例#1
0
 /**
  * Reset ignore_user_abort if it's activated and if it's the same target
  * who activated it.
  *
  * If exit_on_abort is enabled and the connection has been aborted
  * exit the script.
  *
  * @param  Event $event
  * @return void
  */
 public function onAfter(Event $event)
 {
     if ($this->activatedTarget === $event->getTarget()) {
         // exit if connection aborted
         if ($this->getOptions()->getExitOnAbort() && connection_aborted()) {
             exit;
         }
         // reset ignore_user_abort
         ignore_user_abort(false);
         // remove activated target
         $this->activatedTarget = null;
     }
 }
示例#2
0
 /**
  * Constructor
  *
  * Accept a target and its parameters.
  *
  * @param  string $name Event name
  * @param  Adapter $storage
  * @param  ArrayObject $params
  * @param  mixed $result
  * @return void
  */
 public function __construct($name, Adapter $storage, ArrayObject $params, &$result)
 {
     parent::__construct($name, $storage, $params);
     $this->setResult($result);
 }
示例#3
0
 /**
  * On decrement items pre
  *
  * @param  Event $event
  * @return mixed
  */
 public function onDecrementItemsPre(Event $event)
 {
     $event->stopPropagation(true);
     $cache = $event->getTarget();
     $params = $event->getParams();
     $keyValuePairs = $cache->getItems(array_keys($params['keyValuePairs']), $params['options']);
     foreach ($params['keyValuePairs'] as $key => &$value) {
         if (isset($keyValuePairs[$key])) {
             $keyValuePairs[$key] -= $value;
         } else {
             $keyValuePairs[$key] = -$value;
         }
     }
     return $cache->setItems($keyValuePairs, $params['options']);
 }
示例#4
0
 /**
  * On decrement items pre
  *
  * @param  Event $event
  * @return mixed
  */
 public function onDecrementItemsPre(Event $event)
 {
     $storage = $event->getTarget();
     $params = $event->getParams();
     $keyValuePairs = $storage->getItems(array_keys($params['keyValuePairs']));
     foreach ($params['keyValuePairs'] as $key => &$value) {
         if (isset($keyValuePairs[$key])) {
             $keyValuePairs[$key] -= $value;
         } else {
             $keyValuePairs[$key] = -$value;
         }
     }
     $failedKeys = $storage->setItems($keyValuePairs);
     foreach ($failedKeys as $failedKey) {
         unset($keyValuePairs[$failedKey]);
     }
     $event->stopPropagation(true);
     return $keyValuePairs;
 }
 /**
  * @param Event $e
  */
 public function hashKey(Event $e)
 {
     $e->setParam('key', md5($e->getParam('key')));
 }
示例#6
0
 /**
  * Constructor
  *
  * Accept a target and its parameters.
  *
  * @param  string $name Event name
  * @param  Adapter $storage
  * @param  ArrayObject $params
  * @param  Exception $exception
  * @return void
  */
 public function __construct($name, Adapter\AdapterInterface $storage, ArrayObject $params, Exception $exception)
 {
     parent::__construct($name, $storage, $params);
     $this->setException($exception);
 }