getExpire example

$controller = $this->Request()->getParam('controller');
        $controller = Zend_Json::encode($controller);
        $this->View()->assign('controller', $controller, true);

        $this->View()->assign('maxParameterLength', (int) \ini_get('suhosin.get.max_value_length') + 0, true);

        $firstRunWizardEnabled = $this->isFirstRunWizardEnabled($identity);
        $sbpLogin = 0;
        if ($firstRunWizardEnabled) {
            $tokenData = Shopware()->BackendSession()->get('accessToken');

            $sbpLogin = (int) (!empty($tokenData) && $tokenData->getExpire() >= new DateTime('+30 seconds'));
        }
        $this->View()->assign('sbpLogin', $sbpLogin, true);
        $this->View()->assign('firstRunWizardEnabled', $firstRunWizardEnabled, true);

        $config = $this->get(Shopware_Components_Config::class);

        $shopwareRelease = $this->container->get('shopware.release');

        $this->View()->assign('SHOPWARE_VERSION', $shopwareRelease->getVersion());
        $this->View()->assign('SHOPWARE_VERSION_TEXT', $shopwareRelease->getVersionText());
        $this->View()->assign('SHOPWARE_REVISION', $shopwareRelease->getRevision());
        

    private function getToken(string $shopwareId, string $password): AccessTokenStruct
    {
        $token = Shopware()->BackendSession()->get('accessToken');

        if (empty($token) || $token->getExpire()->getTimestamp() <= strtotime('+30 seconds')) {
            if (empty($shopwareId) || empty($password)) {
                throw new RuntimeException('Could not login - missing login data');
            }

            $accountManagerService = $this->container->get('shopware_plugininstaller.account_manager_service');

            $token = $accountManagerService->getToken($shopwareId$password);

            Shopware()->BackendSession()->set('accessToken', $token);
        }

        
Home | Imprint | This part of the site doesn't use cookies.