Pimcore\Controller\Plugin\QrCode::routeStartup PHP Method

routeStartup() public method

public routeStartup ( Zend_Controller_Request_Abstract $request )
$request Zend_Controller_Request_Abstract
    public function routeStartup(\Zend_Controller_Request_Abstract $request)
    {
        if (preg_match("@^/qr~-~code/([a-zA-Z0-9_\\-]+)@", $request->getPathInfo(), $matches)) {
            if (array_key_exists(1, $matches) && !empty($matches[1])) {
                $code = Tool\Qrcode\Config::getByName($matches[1]);
                if ($code) {
                    $url = $code->getUrl();
                    if ($code->getGoogleAnalytics()) {
                        $glue = "?";
                        if (strpos($url, "?")) {
                            $glue = "&";
                        }
                        $url .= $glue;
                        $url .= "utm_source=Mobile&utm_medium=QR-Code&utm_campaign=" . $code->getName();
                    }
                    header("Location: " . $url, true, 302);
                    exit;
                } else {
                    Logger::error("called an QR code but '" . $matches[1] . " is not a code in the system.");
                }
            }
        }
    }