Beispiel #1
0
 /**
  * Filters and transforms the session options array
  * so it complies with the format expected by Enlight_Components_Session
  *
  * @param array $options
  * @return array
  */
 private function prepareSessionOptions($options)
 {
     if (!isset($options['cookie_path']) && $this->request !== null) {
         $options['cookie_path'] = rtrim($this->request->getBaseUrl(), '/') . '/backend/';
     }
     if (empty($options['gc_maxlifetime'])) {
         $backendTimeout = $this->Config()->get('backendTimeout', 60 * 90);
         $options['gc_maxlifetime'] = (int) $backendTimeout;
     }
     unset($options['referer_check']);
     unset($options['client_check']);
     return $options;
 }
Beispiel #2
0
 /**
  * Returns the configured proxy-url.
  *
  * Fallbacks to autodetection if proxy-url is not configured and $request is given.
  * Returns null if $request is not given or autodetection fails.
  *
  * @param Request $request
  * @return string|null
  */
 public function getProxyUrl(Request $request = null)
 {
     $proxyUrl = trim($this->Config()->get('proxy'));
     if (!empty($proxyUrl)) {
         return $proxyUrl;
     }
     // if proxy url is not set fall back to host detection
     if ($request !== null && $request->getHttpHost()) {
         return $request->getScheme() . '://' . $request->getHttpHost() . $request->getBaseUrl() . '/';
     }
     /** @var ModelManager $em */
     $em = $this->get('models');
     $repository = $em->getRepository('Shopware\\Models\\Shop\\Shop');
     /** @var Shopware\Models\Shop\Shop $shop */
     $shop = $repository->findOneBy(array('default' => true));
     if (!$shop->getHost()) {
         return null;
     }
     $url = sprintf('%s://%s%s/', 'http', $shop->getHost(), $shop->getBasePath());
     return $url;
 }