/**
  * @param string              $calledMethod
  * @param ConnectionInterface $conn
  * @param Topic               $topic
  * @param null                $payload
  * @param null                $exclude
  * @param null                $eligible
  *
  * @return bool
  */
 public function dispatch($calledMethod, ConnectionInterface $conn, Topic $topic, WampRequest $request, $payload = null, $exclude = null, $eligible = null)
 {
     $dispatched = false;
     foreach ((array) $request->getRoute()->getCallback() as $callback) {
         $appTopic = $this->topicRegistry->getTopic($callback);
         if ($topic) {
             if ($appTopic instanceof TopicPeriodicTimerInterface) {
                 $appTopic->setPeriodicTimer($this->topicPeriodicTimer);
                 if (false === $this->topicPeriodicTimer->isRegistered($appTopic) && 0 !== count($topic)) {
                     $appTopic->registerPeriodicTimer($topic);
                 }
             }
             if ($calledMethod === static::UNSUBSCRIPTION && 0 === count($topic)) {
                 $this->topicPeriodicTimer->clearPeriodicTimer($appTopic);
             }
             try {
                 if ($payload) {
                     //its a publish call.
                     $appTopic->{$calledMethod}($conn, $topic, $request, $payload, $exclude, $eligible);
                 } else {
                     $appTopic->{$calledMethod}($conn, $topic, $request);
                 }
             } catch (\Exception $e) {
                 $this->logger->error($e->getMessage(), ['code' => $e->getCode(), 'file' => $e->getFile(), 'trace' => $e->getTraceAsString()]);
                 $conn->callError($topic->getId(), $topic, $e->getMessage(), ['topic' => $topic, 'request' => $request, 'event' => $calledMethod]);
                 return;
             }
             $dispatched = true;
         }
     }
     return $dispatched;
 }
 /**
  * @param bool                      $isFolder       = true
  * @param GoogleDriveListParameters $optParams
  * @param string                    $parentFolderId
  * @param string                    $filter
  *
  * @link https://developers.google.com/drive/web/search-parameters
  *
  * @throws HttpException
  *
  * @return \Google_Service_Drive_FileList
  */
 public function getFiles($isFolder = true, GoogleDriveListParameters $optParams = null, $parentFolderId = "", $filter = null)
 {
     $result = array();
     $optParams = empty($optParams) ? new GoogleDriveListParameters() : $optParams;
     if (0 < strlen($optParams->getQuery())) {
         $optParams->setQuery(sprintf("%s and (%s)", GoogleDriveListParameters::NO_TRASH, $optParams->getQuery()));
     } else {
         $optParams->setQuery(GoogleDriveListParameters::NO_TRASH, $optParams->getQuery());
     }
     // Filters
     $filters = array();
     $filters['type'] = !is_null($filter) ? $this->buildTypeFilter($filter) : null;
     if (empty($filters['type'])) {
         $filters['type'] = $isFolder ? GoogleDriveListParameters::FOLDERS : GoogleDriveListParameters::NO_FOLDERS;
     }
     if (!empty($parentFolderId)) {
         $filters['parentFolder'] = sprintf('"%s" in parents', $parentFolderId);
     }
     foreach ($filters as $filter) {
         $optParams->setQuery(sprintf("%s and (%s)", $optParams->getQuery(), $filter));
     }
     $this->container->get('monolog.logger.queries')->info($optParams->getJson());
     try {
         $files = $this->service->files->listFiles($optParams->getArray());
         $result['query'] = $optParams->getQuery();
         $result['nextPageToken'] = $files->getNextPageToken();
         $result['result'] = $files;
     } catch (\Exception $ge) {
         $errorMessage = sprintf("%s.\n%s.", $this->translator->trans('Google Drive cannot authenticate our [email / .p12 key file]'), $this->translator->trans('Please check the parameters.yml file'));
         $this->logger->error($errorMessage);
         throw new HttpException(500, $errorMessage, $ge);
     }
     return $result;
 }
 /**
  * Extract messages to MessageCatalogue.
  *
  * @return MessageCatalogue
  *
  * @throws \Exception|\RuntimeException
  */
 public function extract()
 {
     if ($this->catalogue) {
         throw new \RuntimeException('Invalid state');
     }
     $this->catalogue = new MessageCatalogue();
     foreach ($this->adminPool->getAdminServiceIds() as $id) {
         $admin = $this->getAdmin($id);
         $this->translator = $admin->getTranslator();
         $this->labelStrategy = $admin->getLabelTranslatorStrategy();
         $this->domain = $admin->getTranslationDomain();
         $admin->setTranslator($this);
         $admin->setSecurityHandler($this);
         $admin->setLabelTranslatorStrategy($this);
         //            foreach ($admin->getChildren() as $child) {
         //                $child->setTranslator($this);
         //            }
         // call the different public method
         $methods = array('getShow' => array(array()), 'getDatagrid' => array(array()), 'getList' => array(array()), 'getForm' => array(array()), 'getBreadcrumbs' => array(array('list'), array('edit'), array('create'), array('update'), array('batch'), array('delete')));
         if ($this->logger) {
             $this->logger->info(sprintf('Retrieving message from admin:%s - class: %s', $admin->getCode(), get_class($admin)));
         }
         foreach ($methods as $method => $calls) {
             foreach ($calls as $args) {
                 try {
                     call_user_func_array(array($admin, $method), $args);
                 } catch (\Exception $e) {
                     if ($this->logger) {
                         $this->logger->error(sprintf('ERROR : admin:%s - Raise an exception : %s', $admin->getCode(), $e->getMessage()));
                     }
                     throw $e;
                 }
             }
         }
     }
     $catalogue = $this->catalogue;
     $this->catalogue = false;
     return $catalogue;
 }
 /**
  * @param string              $calledMethod
  * @param ConnectionInterface $conn
  * @param Topic               $topic
  * @param null                $payload
  * @param null                $exclude
  * @param null                $eligible
  *
  * @return bool
  */
 public function dispatch($calledMethod, ConnectionInterface $conn, Topic $topic, WampRequest $request, $payload = null, $exclude = null, $eligible = null)
 {
     $dispatched = false;
     foreach ((array) $request->getRoute()->getCallback() as $callback) {
         $appTopic = $this->topicRegistry->getTopic($callback);
         if ($topic) {
             try {
                 if ($payload) {
                     //its a publish call.
                     $appTopic->{$calledMethod}($conn, $topic, $request, $payload, $exclude, $eligible);
                 } else {
                     $appTopic->{$calledMethod}($conn, $topic, $request);
                 }
             } catch (\Exception $e) {
                 $this->logger->error($e->getMessage(), ['code' => $e->getCode(), 'file' => $e->getFile(), 'trace' => $e->getTraceAsString()]);
                 $conn->callError($topic->getId(), $topic, $e->getMessage(), ['topic' => $topic, 'request' => $request, 'event' => $calledMethod]);
                 return;
             }
             $dispatched = true;
         }
     }
     return $dispatched;
 }