Generate Address for Google API request
@param DealerEvent $event
@return string
356482
protected function generateAddress(DealerEvent $event)
    {
        $dealer = $event->getDealer();
        $address = $dealer->getAddress1();
        if ($dealer->getAddress2()) {
            $address .= " " . $dealer->getAddress2();
        }
        $address .= " " . $dealer->getZipcode() . " " . $dealer->getCity();
        $address = str_replace(" ", "+", $address);
        return $address;
    }
259026
protected function getPayloadFromEvent($event)
    {
        if (method_exists($event, 'broadcastWith')) {
            return array_merge(
                $event->broadcastWith(), ['socket' => data_get($event, 'socket')]
            );
        }

        $payload = [];

        foreach ((new ReflectionClass($event))->getProperties(ReflectionProperty::IS_PUBLIC) as $property) {
            $payload[$property->getName()] = $this->formatProperty($property->getValue($event));
        }

        unset($payload['broadcastQueue']);

        return $payload;
    }
199392
private static function getApplication(Event $event)
    {
        if (null === self::$_application) {
            if (null !== $event->getDispatcher()) {
                self::$_application = $event->getDispatcher()->getApplication();
            }
        }

        return self::$_application;
    }
808277
public static function getCoordinates($address)
    {
        $config = Kwf_Registry::get('config');
        $q = $address;
        $q = str_replace(array('ä','ö','ü','Ä','Ö','Ü','ß'), array('ae','oe','ue','Ae','Oe','Ue','ss'), $q);
        $getParams = array(
            'address' => $q,
            'sensor' => 'false',
            'key' => $config->googleServerToServerApiKey
        );

        $httpClientConfig = array(
            'timeout' => 20,
            'persistent' => false
        );

        if ($config->http && $config->http->proxy && $config->http->proxy->host && $config->http->proxy->port) {
            $httpClientConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy';
            $httpClientConfig['proxy_host'] = $config->http->proxy->host;
            $httpClientConfig['proxy_port'] = $config->http->proxy->port;
        }

        $client = new Zend_Http_Client("https://maps.googleapis.com/maps/api/geocode/json", $httpClientConfig);
        $client->setMethod(Zend_Http_Client::GET);
        $client->setParameterGet($getParams);
        $body = utf8_encode($client->request()->getBody());

        try {
            $result = Zend_Json::decode($body);
        } catch (Zend_Json_Exception $e) {
            $e = new Kwf_Exception_Other($e);
            $e->logOrThrow();
        }

        if (isset($result['results'][0]['geometry']['location']['lat'])
            && isset($result['results'][0]['geometry']['location']['lng'])
        ) {
            return array(
                'lat' => $result['results'][0]['geometry']['location']['lat'],
                'lng' => $result['results'][0]['geometry']['location']['lng']
            );
        }
        return null;
    }
934686
public function getApiRequestUrl(Event $event)
    {
        $params = $event->getCustomParams();

        // Final parameter should be the country
        $country = $params[count($params) - 1];
        // Remove the final paramater
        unset($params[count($params) - 1]);
        // Merge the remainder of the supplied params and remove disallowed punctuation
        $place = trim(implode("_", preg_replace('/[^\da-z\ ]/i', '', $params)));
        return sprintf("%s/%s/conditions/q/%s/%s.json", $this->apiUrl, $this->appId, $country, $place);
    }
895864
protected function getContext(Event $event)
    {
        $context = [
            'event_name' => $event->getEventName(),
            'event_details' => $event->getEventDetails(),
        ];

        if ($event instanceof ExternalSystemHTTPEvent) {
            $context['http_uri'] = $event->getHttpURI();
            $context['request_body'] = $event->getRequestHttpBody();
            $context['request_headers'] = $event->getRequestHttpHeaders();
            $context['response_body'] = $event->getResponseHttpBody();
            $context['response_headers'] = $event->getResponseHttpHeaders();
            $context['status'] = $event->getStatus();
            $context['exchange'] = [
                'id' => $event->getExchangeId(),
            ];
            $context['transaction'] = [
                'id' => $event->getTransactionId(),
                'uri' => $event->getFromUri(),
            ];
        } elseif (
            $event instanceof HandlerEvent ||
            $event instanceof ProcessEvent
        ) {
            $contextExchangeDetails = $event->getExchange();
            $context['exchange'] = [
                'id' => $contextExchangeDetails->getId(),
                'uri' => $contextExchangeDetails->getHeader('from'),
                'type' => (true === $contextExchangeDetails->getHeader('async')) ? 'async' : 'sync',
            ];
        }

        if ($event instanceof ProcessEvent) {
            $endpointUri = $event->getProcessingContext()->get('resolved_uri');
            if ($endpointUri) {
                $context['endpoint_uri'] = $endpointUri;
            }

            $processor = $event->getProcessor();
            $context['processor'] = $this->getProcessorInfo($processor);

            if ($processor instanceof LogsExchangeDetails) {
                $context['exchange']['detail'] = $event->getExchange();
            }
        }

        if ($event instanceof HandlerEvent) {
            $context['exchange']['detail'] = $event->getExchange();
        }

        if ($event instanceof ProcessingErrorEvent || $event instanceof HandlerErrorEvent || $event instanceof MalformedInputEvent) {
            $context['exception'] = $event->getException();
        }

        return $context;
    }
1283230
public function getConfiguration(DriverConfigurationEvent $event)
    {
        $collection = $event->getArgumentCollection();

        $collection
            ->addArgument(new StringArgument("hostname"))
            ->addArgument(new StringArgument("login"))
            ->addArgument(new StringArgument("api-key"))
        ;

        $collection->setDefaults([
            "hostname" => OpenSearchServerDriver::DEFAULT_HOST,
        ]);
    }
913931
public function urlSecret(Event $event)
    {
        $query = $event['request']->getQuery();

        $query->set('client_id', $this->auth['client_id']);
        $query->set('client_secret', $this->auth['client_secret']);
    }
1057087
public function getAddress($index)
    {
        if (!isset($this->addresses[$index])) {
            return null;
        }
        return $this->addresses[$index];
    }
4996
public function getOptions(GetOptionsEvent $event)
    {
        // Check the context.
        $allowedProperties = array('lookupservice', 'second_attr_id', 'single_attr_id');
        if (!$this->isAllowedProperty($event, 'tl_metamodel_filtersetting', $allowedProperties)
            || 'lookupservice' !== $event->getSubPropertyName()
        ) {
            return;
        }

        $resolveClass = (array) $GLOBALS['METAMODELS']['filters']['perimetersearch']['resolve_class'];

        $domain  = 'tl_metamodel_filtersetting';
        $options = [];
        foreach (\array_keys($resolveClass) as $name) {
            $options[$name] = $this->translator->trans($domain . '.perimetersearch.' . $name, [], 'contao_' . $domain);
        }

        $event->setOptions($options);
    }
860674
public function getAddressRaw($address, \DateTime $from = null)
    {
        $result = false;

        $response = $this->request(sprintf('/api/address/%s/raw', $address));

        if ($response !== false && is_array($response)) {
            $result = [];
            foreach ($response as $data) {
                $transaction = new Transaction($data);

                if ($transaction->getOutAmount($address) !== false) {
                    if ($from === null || $transaction->getTime() > $from) {
                        $result[] = $transaction;
                    }
                }
            }
        }

        return $result;
    }
265446
public function onKernelRequest(Event\GetResponseEvent $event)
    {
        if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
            $request = $event->getRequest();
            $publicUrl = rawurldecode($request->getRequestUri());

            if ($this->isExcluded($publicUrl)) {
                // don't process urls which are marked as excluded.
                return;
            }

            if ($this->isParamsEnabled) {
                if (false !== ($queryMark = strpos($publicUrl, '?'))) {
                    $originalUrl = $publicUrl;
                    $publicUrl = substr($originalUrl, 0, $queryMark);
                    $queryString = substr($originalUrl, $queryMark);
                } else {
                    $queryString = null;
                }

                $parts = explode('/', $publicUrl);
                $params = [];
                while (false !== strpos(end($parts), '=')) {
                    array_push($params, array_pop($parts));
                }
                if ($params) {
                    $publicUrl = join('/', $parts);

                    $parser = new UriParser();
                    $request->query->add($parser->parseUri(join('/', array_reverse($params))));

                    if (!$this->aliasing->hasInternalAlias($publicUrl, false)) {
                        $this->rewriteRequest($event, $publicUrl . $queryString);

                        return;
                    }
                }
            }

            /** @var UrlAlias $url */
            if ($url = $this->aliasing->hasInternalAlias($publicUrl, true)) {
                switch ($url->getMode()) {
                    case UrlAlias::REWRITE:
                        $this->rewriteRequest($event, $url->getInternalUrl());
                        break;
                    case UrlAlias::MOVE:
                    case UrlAlias::ALIAS:
                        $event->setResponse(new RedirectResponse($url->getInternalUrl(), $url->getMode()));
                        break;
                    default:
                        throw new \UnexpectedValueException(
                            sprintf(
                                'Invalid mode %s for UrlAlias %s.',
                                $url->getMode(),
                                json_encode($url)
                            )
                        );
                }
            } elseif (strpos($publicUrl, '?') !== false) {
                // allow aliases to receive the query string.

                $publicUrl = substr($publicUrl, 0, strpos($publicUrl, '?'));
                if ($url = $this->aliasing->hasInternalAlias($publicUrl, true, UrlAlias::REWRITE)) {
                    $this->rewriteRequest($event, $url->getInternalUrl());

                    return;
                }
            }
        }
    }
984643
private function formatEventMessage(Event $event)
    {
        $message = null;
        $entityName = null;
        
        if ($event instanceof OrmEventInterface) {
            switch (true) {
                case ($event instanceof EntityLifecycleEvent):
                    $entityName = $event->getRepository()->getEntityName();
                    $message = $this->entityToString($event->getEntity());
                    break;
                case ($event instanceof MetadataLoadEvent):
                    $message = $this->metadataToString($event->getMetadata());
                    $entityName = $event->getMetadata()->getEntityClass();
                    break;
                case ($event instanceof FinderExecutionEvent):
                    $entityName = $event->getRepository()->getEntityName();
                    $query = $event->getSelectQuery();
                    $message = sprintf("SQL: (%s)", str_replace("\n", "\x20", $query->toSQL()));
                    break;
            }
        }
        
        $eventName = sprintf('%s::%s', (new \ReflectionObject($event))->getShortName(), $event->getName());
        $separator = str_repeat('-', 32);
        
        return sprintf("%s\n[%s]\nEntityClassName: %s\n%s", $separator, $eventName, $entityName, $message);
    }
468944
public function fetch(FilterRequestEvent $event)
    {
        if ($this->cache === null) {
            return null;
        }
        $request = $event->getRequest();
        if (!$this->cache->has($request->getUrl())) {
            return null;
        }
        /** @var $response CachedResponse */
        $response = $this->cache->get($request->getUrl());
        if (empty($response)) {
            return null;
        }
        $this->log->write(Log::INFO, 'HTTPCache', 'Cache hit for path: %s', $request->getUrl());
        $this->from_cache = true;

        $main = $this->container->get('Miny\\HTTP\\Response');
        foreach ($response->getParts() as $part) {
            if ($part instanceof CachedResponse) {
                $main->addResponse(
                    $this->container->get('Miny\\Application\\Dispatcher')->dispatch(
                        $part->getRequest()
                    )
                );
            } else {
                $main->addContent($part);
            }
        }

        return $response;
    }
414614
private function _addressDigestPart(KlarnaAddr $address = null)
    {
        if ($address === null) {
            return array();
        }

        $keyOrder = array(
            'careof', 'street', 'zip', 'city', 'country', 'fname', 'lname'
        );

        $holder = $address->toArray();
        $digest = array();

        foreach ($keyOrder as $key) {
            if ($holder[$key] != "") {
                $digest[] = $holder[$key];
            }
        }

        return $digest;
    }
809999
public function onPreCreate(OrderEvent $event)
    {
        if ($this->isOrderLocked($event)) {
            return;
        }

        $order = $event->getOrder();

        // Only for orders and quotes
        if (!in_array($order->getType(), [OrderTypes::TYPE_ORDER, OrderTypes::TYPE_QUOTE])) {
            return;
        }

        // Generate number and key
        $this->generateNumberAndKey($order);

        // Handle identity
        $this->handleIdentity($order);

        // Handle addresses
        $this->handleAddresses($order);
    }
182878
protected function getValue($event)
    {
        if (!empty($this->owner->{$this->attribute})) {
            return $this->owner->{$this->attribute};
        }
        if ($this->value === null) {
            $uuid = $this->generateUUID();
        } else {
            $uuid = parent::getValue($event);
        }
        return $this->ensureUnique ? $this->makeUnique($uuid) : $uuid;
    }