Collection example

/** * @throws Exception * * @return array */
    public function installPlugin(Plugin $plugin)
    {
        $bootstrap = $this->getPluginBootstrap($plugin);

        /** @var Shopware_Components_Plugin_Namespace $namespace */
        $namespace = $bootstrap->Collection();

        try {
            $result = $namespace->installPlugin($bootstrap);
        } catch (Exception $e) {
            throw new Exception(sprintf("Unable to install '%s', got exception:\n%s\n", $plugin->getName()$e->getMessage()), 0, $e);
        }

        $result = \is_bool($result) ? ['success' => $result] : $result;

        if (!$result['success']) {
            if (isset($result['message'])) {
                

    public function init()
    {
        if (!$this->Collection()) {
            return;
        }
        $event = new Enlight_Event_Handler_Default(
            'Enlight_Controller_Front_DispatchLoopStartup',
            [$this, 'onDispatchLoopStartup'],
            400
        );
        $this->Application()->Events()->registerListener($event);
        $event = new Enlight_Event_Handler_Default(
            'Enlight_Controller_Action_PostDispatch',
            [$this, 'onPostDispatch'],
            

    public function subscribeEvent($event$listener$position = null)
    {
        $namespace = $this->Collection();
        $handler = new Enlight_Event_Handler_Plugin(
            $event$namespace$this$listener$position
        );
        $namespace->Subscriber()->registerListener($handler);

        return $this;
    }

    /** * This function installs the plugin. * * @return bool */
return 'snippet:string:{include file="' . implode("\"}\n{include file=\"", $templateNames) . '"}';
    }

    /** * Sets the view renderer instance * * @return Enlight_Controller_Plugins_ScriptRenderer_Bootstrap */
    public function setViewRenderer(?Enlight_Controller_Plugins_ViewRenderer_Bootstrap $viewRenderer = null)
    {
        if ($viewRenderer === null) {
            $collection = $this->Collection();
            if ($collection !== null) {
                $viewRenderer = $collection->get('ViewRenderer');
            }
        }

        $this->viewRenderer = $viewRenderer;

        return $this;
    }

    /** * @param string $module * @param string $controller * @param string $file * * @return string */

    protected $formatDateTime = true;

    /** * Initializes this plugin. This Plugin should run after the ViewRenderer Plugin * * @return void */
    public function init()
    {
        if ($this->Collection() === null) {
            return;
        }
        $event = new Enlight_Event_Handler_Default(
            'Enlight_Controller_Action_PostDispatch',
            [$this, 'onPostDispatch'],
            500
        );
        $this->Application()->Events()->registerListener($event);
    }

    /** * Called from the Event Manager after the dispatch process * * @return void */
/** * Returns plugin config * * @return Enlight_Config */
    public function Config()
    {
        if (!\is_string($this->name)) {
            throw new RuntimeException('Plugin name not initialized correctly');
        }

        return $this->Collection()->getConfig($this->name);
    }

    final public function Plugin(): Plugin
    {
        if ($this->plugin === null) {
            $plugin = Shopware()->Models()->getRepository(Plugin::class)->findOneBy(['id' => $this->getId()]);
            if (!$plugin instanceof Plugin) {
                throw new ModelNotFoundException(Plugin::class$this->getId());
            }
            $this->plugin = $plugin;
        }

        

    protected $parseParams = [];

    /** * Init this plugin. This Plugin should run before the dispatching process. * * @return void */
    public function init()
    {
        if ($this->Collection() === null) {
            return;
        }
        $event = new Enlight_Event_Handler_Default('Enlight_Controller_Action_PreDispatch', [
            $this, 'onPreDispatch',
        ]);
        $this->Application()->Events()->registerListener($event);
    }

    /** * Called from the event manager before the dispatch process. * Parse the json input data, when it was activated. * * @return void */
Home | Imprint | This part of the site doesn't use cookies.