registerResources example


    private $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;
    }

    public function registerShop(Shop $shop): void
    {
        $this->registerResources($shop);
        $this->resetTemplate($shop);
    }

    public function registerResources(Shop $shop): void
    {
        $this->container->set('shop', $shop);

        $locale = $this->container->get(Zend_Locale::class);
        $locale->setLocale($shop->getLocale()->toString());

        $currency = $this->container->get(Zend_Currency::class);
        
$this->View()->assign(['success' => true, 'data' => $nodes]);
    }

    public function getMailVariablesAction()
    {
        $prefix = ltrim($this->Request()->getParam('prefix'), '$');

        /** @var Mail $mail */
        $mail = $this->getRepository()->find((int) $this->Request()->getParam('mailId'));
        $shop = $this->get(ModelManager::class)->getRepository(Shop::class)->getActiveDefault();
        $shop->registerResources();

        $context = array_merge($this->getDefaultMailContext($shop)$mail->getContext());

        $completer = $this->container->get(AutoCompleteResolver::class);

        $context = $completer->completer($context$this->Request()->getParam('smartyCode'));
        $context = $mail->arrayGetPath($context);

        $result = [];

        foreach ($context as $key => $value) {
            
/** * @return list<array{name: string, url: string}> */
    private function getUrls(Type $type): array
    {
        $shops = $this->getModelManager()->getRepository(Shop::class)->getActiveShopsFixed();

        $urls = [];

        foreach ($shops as $shop) {
            $shop->registerResources();

            $urls[] = [
                'name' => $shop->getName(),
                'url' => $this->Front()->ensureRouter()->assemble([
                    'controller' => $type->getControllerName(),
                    'module' => 'frontend',
                    'action' => 'index',
                    'fullPath' => true,
                ]),
            ];
        }

        


        if (!empty($this->_order->order->currencyID)) {
            $repository = Shopware()->Models()->getRepository(Currency::class);
            $currency = $repository->find($this->_order->order->currencyID);
            if ($currency === null) {
                throw new ModelNotFoundException(Currency::class$this->_order->order->currencyID);
            }
            $shop->setCurrency($currency);
        }

        Shopware()->Container()->get(ShopRegistrationServiceInterface::class)->registerResources($shop);
    }

    /** * Set object configuration from array */
    protected function setConfig(array $config)
    {
        $this->_config = $config;
        foreach ($config as $key => $v) {
            if (property_exists($this$key)) {
                $this->$key = $v;
            }
Home | Imprint | This part of the site doesn't use cookies.