getArea example

public function refactor(Node $node): ?Node
    {
        if (!$node instanceof ClassLike) {
            return null;
        }

        if ($this->isTestClass($node)) {
            return null;
        }

        $area = $this->getArea($node);

        if ($area === null) {
            return null;
        }

        if ($this->hasPackageAnnotation($node)) {
            return null;
        }

        $node->attrGroups[] = $this->phpAttributeGroupFactory->createFromClassWithItems(Package::class[$area]);

        
$stateId = null;

        $currencyId = (int) $this->container->get(Connection::class)->fetchOne(
            'SELECT `id` FROM `s_core_currencies` WHERE `currency` = :currency',
            ['currency' => $order->getCurrency()]
        );

        $shippingAddress = $order->getShipping();
        if ($shippingAddress instanceof Shipping) {
            $countryId = $shippingAddress->getCountry()->getId();

            $area = $shippingAddress->getCountry()->getArea();
            if ($area instanceof Area) {
                $areaId = $area->getId();
            }

            $state = $shippingAddress->getState();
            if ($state instanceof State) {
                $stateId = $state->getId();
            }
        }

        $shop = $order->getShop();

        
if ($this->isValidShippingAddress($address)) {
                $this->addressService->setDefaultShippingAddress($address);
            }
        }
    }

    private function refreshSession(Address $address)
    {
        $countryId = $address->getCountry()->getId();
        $stateId = $address->getState() ? $address->getState()->getId() : null;
        $areaId = $address->getCountry()->getArea() ? $address->getCountry()->getArea()->getId() : null;

        $this->get('session')->offsetSet('sCountry', $countryId);
        $this->get('session')->offsetSet('sState', $stateId);
        $this->get('session')->offsetSet('sArea', $areaId);

        $this->get(ContextServiceInterface::class)->initializeShopContext();
    }

    /** * @return array */
    
$currency = array_shift($currency);
        }

        if (!$currency) {
            $currency = $shop->getCurrency();
        }

        $context = new ShopContext($baseUrl$shop$currency$currentCustomerGroup$fallbackCustomerGroup[][]);

        $area = null;
        if ($areaId !== null) {
            $area = $this->countryGateway->getArea($areaId$context);
        }

        $country = null;
        if ($countryId !== null) {
            $country = $this->countryGateway->getCountry($countryId$context);
        } else {
            if (method_exists($this->countryGateway, 'getFallbackCountry')) {
                $country = $this->countryGateway->getFallbackCountry($context);
            }
        }

        
if ($shippingCountry === null) {
            throw new RuntimeException('Invalid customer shipping address');
        }

        /** @var Enlight_Components_Session_Namespace $session */
        $session = $this->get('session');
        $session->offsetSet('sRegister', $data['register']);
        $session->offsetSet('sOneTimeAccount', false);
        $session->offsetSet('sRegisterFinished', true);
        $session->offsetSet('sCountry', $shippingCountry->getId());
        $session->offsetSet('sArea', $shippingCountry->getArea() !== null ? $shippingCountry->getArea()->getId() : 0);

        if ($customer->getAccountMode() === Customer::ACCOUNT_MODE_FAST_LOGIN) {
            $session->offsetSet('sOneTimeAccount', true);
        }
    }

    private function loginCustomer(Customer $customer): void
    {
        $this->front->Request()->setPost('email', $customer->getEmail());
        $this->front->Request()->setPost('passwordMD5', $customer->getPassword());
        Shopware()->Modules()->Admin()->sLogin(true);
    }
$shop = $order->getShop();
        if (!$shop instanceof Shop) {
            throw new ModelNotFoundException(Shop::class$orderId);
        }

        $customerGroup = $customer->getGroup() ?? $this->container->get(ModelManager::class)->getRepository(Group::class)->findOneBy(['key' => self::DEFAULT_CUSTOMER_GROUP]);
        if (!$customerGroup instanceof Group) {
            throw new ModelNotFoundException(Group::class$orderId);
        }
        $customerGroupKey = $customerGroup->getKey();

        $area = $orderShippingAddress->getCountry()->getArea();
        $state = $orderShippingAddress->getState();
        $shopContext = $this->container->get('shopware_storefront.shop_context_factory')->create(
            $shop->getBaseUrl() ?? '',
            $shop->getId(),
            null,
            $customerGroupKey,
            $area ? $area->getId() : null,
            $orderShippingAddress->getCountry()->getId(),
            $state ? $state->getId() : null
        );

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