コード例 #1
0
 public function collect(\Enlight_Controller_Action $controller)
 {
     $error = $controller->Request()->getParam('error_handler');
     if ($error && isset($error->exception)) {
         return ['exception' => $error->exception];
     }
     return [];
 }
コード例 #2
0
 public function collect(\Enlight_Controller_Action $controller)
 {
     $smarty = $controller->View()->Engine();
     $assigns = $controller->View()->getAssign();
     /**
      * Clear Assigns, to fix cannot serialize pdo instances errors
      */
     unset($assigns['Shopware']);
     unset($assigns['Controller']);
     unset($assigns['Shop']);
     unset($assigns['Locale']);
     unset($assigns['sProfiler']);
     unset($assigns['sProfilerCollectors']);
     unset($assigns['sProfilerID']);
     $result = ['template' => ['cache_dir' => $smarty->getCacheDir(), 'compile_dir' => $smarty->getCompileDir(), 'template_dir' => $smarty->getTemplateDir(), 'plugin_dir' => $smarty->getPluginsDir(), 'template' => explode('|', $controller->View()->Template()->template_resource), 'vars' => $assigns, 'start_time' => $smarty->start_time]];
     return $result;
 }
コード例 #3
0
 /**
  * This function will be called before the widget is being finalized
  */
 public function preDispatch()
 {
     $this->pluginBootstrap = $this->get('plugins')->Frontend()->SwagBrowserLanguage();
     $this->shopFinder = new ShopFinder($this->pluginBootstrap, $this->getModelManager());
     $this->translator = new Translator($this->pluginBootstrap, $this->getModelManager(), $this->get("snippets"), $this->get("db"));
     $this->session = $this->get("session");
     $this->shop = $this->get("shop");
     parent::preDispatch();
 }
コード例 #4
0
ファイル: Bootstrap.php プロジェクト: GerDner/luck-docker
 /**
  * Init backend locales
  */
 protected function initLocale()
 {
     $bootstrap = $this->Application()->Bootstrap();
     $locale = $this->getCurrentLocale();
     $bootstrap->getResource('Locale')->setLocale($locale->toString());
     $bootstrap->getResource('Snippets')->setLocale($locale);
     $template = $bootstrap->getResource('Template');
     $baseHash = $this->request->getScheme() . '://' . $this->request->getHttpHost() . $this->request->getBaseUrl() . '?' . Shopware::REVISION;
     $baseHash = substr(sha1($baseHash), 0, 5);
     $template->setCompileId('backend_' . $locale->toString() . '_' . $baseHash);
     if ($this->action !== null && $this->action->View()->hasTemplate()) {
         $this->action->View()->Template()->setCompileId($template->getCompileId());
     }
 }
コード例 #5
0
ファイル: Bootstrap.php プロジェクト: nhp/shopware-4
    /**
     * Init backend locales
     *
     * @param Zend_Auth $auth
     */
    protected function initLocale($auth = null)
    {
        $bootstrap = $this->Application()->Bootstrap();
        if($auth !== null) {
            $user = $auth->getIdentity();
            /** @var $locale \Shopware\Models\Shop\Locale */
        }

        $locale = null;
        if (isset($user->locale)) {
            $locale = $user->locale;
        } else {
            $default = $this->getDefaultLocale();
            $locale = Shopware()->Models()->getRepository(
                'Shopware\Models\Shop\Locale'
            )->find($default);
        }

        $bootstrap->getResource('Locale')->setLocale($locale->toString());
        $bootstrap->getResource('Snippets')->setLocale($locale);
        $template = $bootstrap->getResource('Template');
        $baseHash = $this->request->getScheme() . '://'
                  . $this->request->getHttpHost()
                  . $this->request->getBaseUrl() . '?'
                  . Shopware::REVISION;
        $baseHash = substr(sha1($baseHash), 0 , 5);
        $template->setCompileId('backend_' . $locale->toString() . '_' . $baseHash);
        if (isset($user->role)) {
            $template->setCacheId($user->role->getName());
        }

        if($this->action !== null && $this->action->View()->hasTemplate()) {
            $this->action->View()->Template()->setCompileId($template->getCompileId());
            $this->action->View()->Template()->setCacheId($template->getCacheId());
        }
    }
コード例 #6
0
 public function collect(\Enlight_Controller_Action $controller)
 {
     return ['response' => ['httpResponse' => $controller->Response()->getHttpResponseCode(), 'headers' => $controller->Response()->getHeaders()], 'request' => ['moduleName' => $controller->Request()->getModuleName(), 'controllerName' => $controller->Request()->getControllerName(), 'actionName' => $controller->Request()->getActionName(), 'httpMethod' => $controller->Request()->getMethod(), 'params' => $controller->Request()->getParams(), 'get' => $controller->Request()->getQuery(), 'post' => $controller->Request()->getPost(), 'cookies' => $controller->Request()->getCookie(), 'uri' => $controller->Request()->getRequestUri(), 'url' => ($controller->Request()->isSecure() ? 'https' : 'http') . '://' . Shopware()->Shop()->getHost() . Shopware()->Shop()->getBaseUrl() . $controller->Request()->getRequestUri(), 'ip' => $controller->Request()->getClientIp(), 'time' => time()], 'session' => ['meta' => Shopware()->Db()->fetchRow('SELECT expiry,modified FROM s_core_sessions WHERE id = ?', [Shopware()->Session()->get('sessionId')]), 'data' => $_SESSION['Shopware']], 'logs' => $this->getLogs(), 'server' => $_SERVER, 'startTime' => STARTTIME, 'bundles' => $this->getBundles()];
 }
コード例 #7
0
 /**
  * @param ControllerAction $action
  */
 public function onPaypalPlus(ControllerAction $action)
 {
     $config = $this->config;
     $router = $action->Front()->Router();
     $view = $action->View();
     $user = $view->getAssign('sUserData');
     $basket = $view->getAssign('sBasket');
     $cancelUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'cancel', 'forceSecure' => true));
     $returnUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'return', 'forceSecure' => true));
     $profile = $this->getProfile();
     $this->restClient->setAuthToken();
     $uri = 'payments/payment';
     $params = array('intent' => 'sale', 'experience_profile_id' => $profile['id'], 'payer' => array('payment_method' => 'paypal'), 'transactions' => $this->getTransactionData($basket, $user), 'redirect_urls' => array('return_url' => $returnUrl, 'cancel_url' => $cancelUrl));
     $payment = $this->restClient->create($uri, $params);
     if (!empty($payment['links'][1]['href'])) {
         $view->assign('PaypalPlusApprovalUrl', $payment['links'][1]['href']);
         $view->assign('PaypalPlusModeSandbox', $config->get('paypalSandbox'));
         $view->assign('PaypalLocale', $this->paypalBootstrap->getLocaleCode());
         $db = $this->bootstrap->get('db');
         $sql = 'SELECT paymentmeanID AS id, paypal_plus_media AS media
                 FROM s_core_paymentmeans_attributes WHERE paypal_plus_active = 1';
         $paymentMethods = $db->fetchAssoc($sql);
         $view->assign('PaypalPlusThirdPartyPaymentMethods', $paymentMethods);
         $this->session->PaypalPlusPayment = $payment['id'];
     }
 }
コード例 #8
0
ファイル: Bootstrap.php プロジェクト: GerDner/luck-docker
 /**
  * Returns an array of affected cacheids for this $controller
  *
  * @param \Enlight_Controller_Action $controller
  * @return array
  */
 protected function getCacheIdsFromController(\Enlight_Controller_Action $controller)
 {
     $request = $controller->Request();
     $view = $controller->View();
     $controllerName = $this->buildControllerName($request);
     $cacheIds = array();
     $articleIds = array();
     switch ($controllerName) {
         case 'frontend/blog':
             $categoryId = (int) $request->getParam('sCategory');
             $cacheIds[] = 'c' . $categoryId;
             $blogPost = $view->getAssign('sArticle');
             foreach ($blogPost['assignedArticles'] as $article) {
                 $articleIds[] = $article['id'];
             }
             break;
         case 'widgets/listing':
             $categoryId = (int) $request->getParam('sCategory');
             if (empty($categoryId)) {
                 $categoryId = (int) Shopware()->Shop()->get('parentID');
             }
             $cacheIds[] = 'c' . $categoryId;
             foreach ($view->getAssign('sArticles') as $article) {
                 $articleIds[] = $article['articleID'];
             }
             foreach ($view->getAssign('sCharts') as $article) {
                 $articleIds[] = $article['articleID'];
             }
             break;
         case 'frontend/index':
             $categoryId = (int) Shopware()->Shop()->get('parentID');
             $cacheIds[] = 'c' . $categoryId;
             break;
         case 'widgets/recommendation':
             $article = $view->getAssign('sArticle');
             foreach ($article['sRelatedArticles'] as $article) {
                 $articleIds[] = $article['articleID'];
             }
             foreach ($article['sSimilarArticles'] as $article) {
                 $articleIds[] = $article['articleID'];
             }
             break;
         case 'frontend/detail':
             $articleId = $request->getParam('sArticle', 0);
             $articleIds[] = $articleId;
             break;
         case 'widgets/emotion':
             foreach ($view->getAssign('sEmotions') as $emotion) {
                 $cacheIds[] = 'e' . $emotion['id'];
                 foreach ($emotion['elements'] as $element) {
                     if ($element['component']['name'] == 'Artikel') {
                         $articleIds[] = $element['data']['articleID'];
                         $articleIds[] = $element['data']['articleDetailsID'];
                     } elseif ($element['component']['name'] == 'Artikel-Slider') {
                         foreach ($element['data']['values'] as $value) {
                             $articleIds[] = $value['articleID'];
                             $articleIds[] = $value['articleDetailsID'];
                         }
                     } elseif ($element['component']['name'] == 'Sideview-Element') {
                         foreach ($element['data']['product_data'] as $value) {
                             $articleIds[] = $value['articleID'];
                         }
                     }
                 }
             }
             break;
         case 'frontend/listing':
             foreach ($view->getAssign('sArticles') as $article) {
                 $articleIds[] = $article['articleID'];
             }
             break;
     }
     array_walk($articleIds, function (&$value) {
         $value = 'a' . $value;
     });
     $cacheIds = array_merge($cacheIds, $articleIds);
     return $cacheIds;
 }
コード例 #9
0
ファイル: Frontend.php プロジェクト: Goucher/shopware
 /**
  * This function controls the buyer protection item in the basket.
  *
  * @param \Enlight_Controller_Action $controller
  * @param \Enlight_Controller_Request_RequestHttp $request
  * @param $basketAmount
  * @return void
  */
 private function controlBasketTsArticle($controller, $request, $basketAmount)
 {
     //get total basket amount
     $amount = $this->getAmount($controller->getShippingCosts(), $basketAmount);
     $basketArticle = $this->isTsArticleInBasket();
     //Always use the brutto-value
     if ($controller->View()->sAmountWithTax) {
         $amount = $controller->View()->sAmountWithTax;
     }
     if (empty($basketArticle)) {
         return;
     }
     $sql = "SELECT COUNT(id)\n\t\t\t\tFROM s_order_basket\n\t\t\t\tWHERE sessionID = ?\n\t\t\t\t\tAND modus = 0";
     $articleAmount = $this->db->fetchOne($sql, array($this->sessionId));
     if ($articleAmount > 1) {
         if ($amount > 0) {
             //get trusted shop article data
             $toAddArticle = $this->getTsArticleByAmount($amount);
             if ($toAddArticle['tsProductID'] == $basketArticle['ordernumber']) {
                 return;
             }
         }
     }
     $sql = "DELETE FROM s_order_basket\n\t\t\t\tWHERE id = ?\n\t\t\t\t\tAND sessionID = ?";
     $this->db->query($sql, array($basketArticle['id'], $this->sessionId));
     $controller->View()->sTsArticleRemoved = true;
     $controller->forward($request->getActionName());
 }
コード例 #10
0
ファイル: Bootstrap.php プロジェクト: nhp/shopware-4
    /**
     * @param   array $params
     * @return  string
     */
    public function renderEsiTag($params)
    {
        $request = $this->action->Request();

        if (isset($params['params'])) {
            $params = array_merge((array)$params['params'], $params);
            unset($params['params']);
        }

        if (!isset($params['module'])) {
            $params['module'] = $request->getModuleName();
            if (!isset($params['controller'])) {
                $params['controller'] = $request->getControllerName();
            }
        }

        $targetName = $params['module'] . '/' . $params['controller'];
        $controllerName = $request->getModuleName() . '/' . $request->getControllerName();

        if (isset($this->autoNoCacheControllers[$controllerName])
            && isset($this->allowNoCacheControllers[$targetName])
            && $this->autoNoCacheControllers[$controllerName]
                == $this->allowNoCacheControllers[$targetName]
        ) {
            $params['nocache'] = 1;
        }

        $url = sprintf('%s://%s%s/?%s',
            $request->getScheme(),
            $request->getHttpHost(),
            $request->getBaseUrl(),
            http_build_query($params, null, '&')
        );

        return '<esi:include src="' . $url . '" />';
    }
コード例 #11
0
 /**
  * @param Controller $controller
  */
 private function onPaypalPlus(Controller $controller)
 {
     $router = $controller->Front()->Router();
     $view = $controller->View();
     $cancelUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'cancel', 'forceSecure' => true));
     $returnUrl = $router->assemble(array('controller' => 'payment_paypal', 'action' => 'return', 'forceSecure' => true));
     $profile = $this->getProfile();
     $uri = 'payments/payment';
     $params = array('intent' => 'sale', 'experience_profile_id' => $profile['id'], 'payer' => array('payment_method' => 'paypal'), 'transactions' => $this->getTransactionData($view->getAssign('sBasket'), $view->getAssign('sUserData')), 'redirect_urls' => array('return_url' => $returnUrl, 'cancel_url' => $cancelUrl));
     $payment = array();
     try {
         $payment = $this->restClient->create($uri, $params);
     } catch (Exception $e) {
         $this->logException('An error occurred on creating a payment', $e);
     }
     if (!empty($payment['links'][1]['href'])) {
         $view->assign('PaypalPlusApprovalUrl', $payment['links'][1]['href']);
         $view->assign('PaypalPlusModeSandbox', $this->config->get('paypalSandbox'));
         $view->assign('PaypalLocale', $this->paypalBootstrap->getLocaleCode());
         $this->session->PaypalPlusPayment = $payment['id'];
     }
 }