Loader example



        // register plugin snippet directory         if (file_exists($this->Path() . 'Snippets')) {
            Shopware()->Snippets()->addConfigDir(
                $this->Path() . 'Snippets/'
            );
        }

        // register plugin component directory         if (file_exists($this->Path() . 'Components')) {
            Shopware()->Loader()->registerNamespace(
                'Shopware_Components',
                $this->Path() . 'Components/'
            );
        }

        return $path;
    }

    /** * Returns plugin capabilities * * @return array<string, bool> */
$class = $this->getControllerClass($request);
        $path = $this->getControllerPath($request);

        if (\is_object($path) || class_exists($path)) {
            $class = $path;
            $path = null;
        }

        if (!\is_object($class)) {
            try {
                Shopware()->Loader()->loadClass($class$path);
            } catch (Exception $e) {
                throw new Enlight_Exception(sprintf('Controller "%s" could not be loaded', $class));
            }

            $proxy = Shopware()->Hooks()->getProxy($class);

            /** @var Enlight_Controller_Action $controller */
            $controller = new $proxy();
        } else {
            /** @var Enlight_Controller_Action $controller */
            $controller = $class;
        }
/** * This method registers shopware's generic payment method handler * and the debit payment method handler * * @return array */
    public function addPaymentClass(Enlight_Event_EventArgs $args)
    {
        $dirs = $args->getReturn();

        $this->Application()->Loader()->registerNamespace('ShopwarePlugin\PaymentMethods\Components', __DIR__ . '/Components/');

        $dirs['debit'] = DebitPaymentMethod::class;
        $dirs['sepa'] = SepaPaymentMethod::class;
        $dirs['default'] = GenericPaymentMethod::class;

        return $dirs;
    }

    /** * Add View path to Smarty * * @return void */
return $this->Path() . 'Controllers/AlsoBought.php';
    }

    /** * Plugin event listener function which is fired * when the also bought resource has to be initialed. * * @return Shopware_Components_SeoIndex */
    public function initSeoIndexResource()
    {
        $this->Application()->Loader()->registerNamespace(
            'Shopware_Components',
            $this->Path() . 'Components/'
        );

        return Enlight_Class::Instance('Shopware_Components_SeoIndex');
    }

    /** * Registers all required events for the similar shown articles function. */
    protected function subscribeSearchIndexEvents()
    {
return $this->Path() . 'Controllers/SimilarShown.php';
    }

    /** * Plugin event listener function which is fired * when the similar shown resource has to be initialed. * * @return Shopware_Components_SimilarShown */
    public function initSimilarShownResource()
    {
        $this->Application()->Loader()->registerNamespace(
            'Shopware_Components',
            $this->Path() . 'Components/'
        );

        $similarShown = Enlight_Class::Instance('Shopware_Components_SimilarShown');
        Shopware()->Container()->set('similarshown', $similarShown);

        return $similarShown;
    }

    /** * Event listener function of the Shopware_Plugins_LastArticles_ResetLastArticles * event. This event is fired after the Shopware_Plugins_LastArticles plugin resets * the s_emarketing_lastarticles data for a validation time. * This listener is used to update the similar shown article data at the same time. */

    protected function initPlugin($name$prefix$file = null)
    {
        /** @var class-string<Enlight_Plugin_Bootstrap|Enlight_Plugin_Namespace> $class */
        $class = implode('_', [$prefix$name, 'Bootstrap']);
        if (!class_exists($class, false)) {
            Shopware()->Loader()->loadClass($class$file);
        }

        $plugin = new $class($name$this);
        $this->plugins[$name] = $plugin;

        return $this;
    }
}
Home | Imprint | This part of the site doesn't use cookies.