public function bootstrap($app) { if (is_string($this->include)) { $this->include = explode(',', $this->include); } $app->on(Application::EVENT_BEFORE_REQUEST, function () use($app) { $app->getView()->on(View::EVENT_END_BODY, [Counter::className(), 'renderCounters'], $this->include); }); $app->on(Application::EVENT_BEFORE_ACTION, function () use($app) { if ('cart' === $app->requestedAction->controller->id && 'payment-success' === $app->requestedAction->id) { $app->getView()->on(View::EVENT_END_BODY, [ManageController::className(), 'renderEcommerceCounters'], ['orderId' => intval(Yii::$app->request->get('id'))]); } }); }
/** * @param ActionEvent $event */ public static function handleBeforeAction(ActionEvent $event) { /** @var SeoModule $seoModule */ $seoModule = \Yii::$app->getModule('seo'); /** @TODO remove */ if ('payment' === $event->action->controller->id && 'success' === $event->action->id) { \Yii::$app->getView()->on(View::EVENT_END_BODY, [Counter::className(), 'renderCounters'], [$event->action->controller->module->id . '/' . $event->action->controller->id]); \Yii::$app->getView()->on(View::EVENT_END_BODY, [ManageController::className(), 'renderEcommerceCounters'], ['transactionId' => intval(\Yii::$app->request->get('id'))]); } /** Only frontend */ if (true === $seoModule->isFrontend(\Yii::$app)) { if (1 === intval($seoModule->analytics['ecGoogle']['active'])) { GoogleEcommerceHandler::installHandlers($event); } if (1 === intval($seoModule->analytics['ecYandex']['active'])) { YandexEcommerceHandler::installHandlers($event); } } }
public function bootstrap($app) { if (is_string($this->include)) { $this->include = explode(',', $this->include); } $app->on(Application::EVENT_BEFORE_REQUEST, function () use($app) { if ($app->getModule('seo')->redirectWWW != self::NO_REDIRECT) { self::redirectWWW(); } if ($app->getModule('seo')->redirectTrailingSlash == 1) { self::redirectSlash(); } $app->getView()->on(View::EVENT_END_BODY, [Counter::className(), 'renderCounters'], $this->include); }); $app->on(Application::EVENT_BEFORE_ACTION, function () use($app) { if ('payment' === $app->requestedAction->controller->id && 'success' === $app->requestedAction->id) { $app->getView()->on(View::EVENT_END_BODY, [Counter::className(), 'renderCounters'], [$app->requestedAction->controller->module->id . '/' . $app->requestedAction->controller->id]); $app->getView()->on(View::EVENT_END_BODY, [ManageController::className(), 'renderEcommerceCounters'], ['transactionId' => intval(Yii::$app->request->get('id'))]); } }); }