Ejemplo n.º 1
0
 /**
  * Check if an event dispatcher has a subscriber
  *
  * @param HasDispatcherInterface $dispatcher
  * @param EventSubscriberInterface $subscriber
  *
  * @return bool
  */
 protected function hasSubscriber(HasDispatcherInterface $dispatcher, EventSubscriberInterface $subscriber)
 {
     $class = get_class($subscriber);
     $all = array_keys(call_user_func(array($class, 'getSubscribedEvents')));
     foreach ($all as $i => $event) {
         foreach ($dispatcher->getEventDispatcher()->getListeners($event) as $e) {
             if ($e[0] === $subscriber) {
                 unset($all[$i]);
                 break;
             }
         }
     }
     return count($all) == 0;
 }
Ejemplo n.º 2
0
 /**
  * Add the custom param listener to a transfer object
  *
  * @param HasDispatcherInterface $sync
  */
 protected function addCustomParamListener(HasDispatcherInterface $sync)
 {
     $params = $this->params;
     $sync->getEventDispatcher()->addListener(UploadSync::BEFORE_TRANSFER, function (Event $e) use($params) {
         if ($e['command'] instanceof CommandInterface) {
             $e['command']->overwriteWith($params);
         }
     });
 }
Ejemplo n.º 3
0
 /**
  * Add the custom param listener to a transfer object
  *
  * @param HasDispatcherInterface $sync
  */
 protected function addCustomParamListener(HasDispatcherInterface $sync)
 {
     $params = $this->params;
     $sync->getEventDispatcher()->addListener(UploadSync::BEFORE_TRANSFER, function (Event $e) use($params) {
         if ($e['command'] instanceof CommandInterface) {
             $e['command']->overwriteWith($params);
         } elseif ($e['command'] instanceof TransferInterface) {
             // Multipart upload transfer object
             foreach ($params as $k => $v) {
                 $e['command']->setOption($k, $v);
             }
         }
     });
 }