Subscriber example

return $result;
    }

    /** * Writes all registered plugins into the storage. * The subscriber and the registered plugins are converted to an array. * * @return Enlight_Plugin_Namespace_Config */
    public function write()
    {
        $subscribes = $this->Subscriber()->toArray();

        foreach ($subscribes as $subscribe) {
            $subscribe['pluginID'] = $this->getInfo($subscribe['plugin'], 'id');
            if (!isset($subscribe['pluginID'])) {
                continue;
            }
            $subscribe['listener'] = $this->getInfo($subscribe['plugin'], 'class')
                . '::' . $subscribe['listener'];

            $sql = ' INSERT INTO `s_core_subscribes` ( `subscribe`, `type`, `listener`, `position`, `pluginID` ) VALUES ( ?, ?, ?, ?, ? ) ON DUPLICATE KEY UPDATE `position` = VALUES(`position`), `pluginID` = VALUES(`pluginID`) ';

    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 */
    public function install()
    {
    }
$widget->setPlugin($this->Plugin());

        $this->Plugin()->getWidgets()->add($widget);
    }

    /** * {@inheritdoc} */
    public function subscribeEvent($event$listener = null, $position = null)
    {
        if ($listener === null && $event instanceof Enlight_Event_Handler) {
            $this->Collection()->Subscriber()->registerListener($event);
        } else {
            parent::subscribeEvent($event$listener$position);
        }

        return $this;
    }

    /** * Helper function to register a plugin controller. * * If the default event listener is used for the registration of a plugin controller, the following requirements must be fulfilled: * 1. The plugin directory must contain a 'Controllers' subdirectory. * 2. The 'Controllers' directory must contain a subdirectory which corresponds to the module (Frontend, Backend, Widgets or API) * 3. The controller must be filed in this module directory. * 4. The controller file must have the same name as the controller class. * * If all the requirements are fulfilled, the controller is registered automatically. * Additionally, the following plugin namespaces/directories are registered, if available: * 1. The 'Views' plugin directory is added as a template directory. * 2. The 'Snippets' plugin directory is added as a config directory. * 3. The 'Components' plugin directory is added as a component namespace. * * @example * <code> * public function install() { * $this->registerController('Frontend', 'Example1'); * return true; * } * </code> * * @param string $module - Possible values: Frontend, Backend, Widgets, Api * @param string $name - The name of the controller * @param string $listener - Name of the event listener function which will be called * * @throws RuntimeException * * @return $this */

    public function write()
    {
        if (!$this->storage instanceof Enlight_Config) {
            throw new RuntimeException('Store is not set');
        }

        $this->storage->plugins = $this->toArray();
        $this->storage->listeners = $this->Subscriber()->toArray();
        $this->storage->write();

        return $this;
    }

    /** * Loads all plugins in the plugin namespace over the storage. * * @return Enlight_Plugin_Namespace_Config */
    public function read()
    {
$pluginManager = new Enlight_Plugin_PluginManager($application);

        foreach (['Core', 'Frontend', 'Backend'] as $namespace) {
            $namespace = new Shopware_Components_Plugin_Namespace(
                $namespace,
                null,
                $pluginDirectories,
                $configReader
            );

            $pluginManager->registerNamespace($namespace);
            $eventManager->registerSubscriber($namespace->Subscriber());
        }

        foreach ($pluginDirectories as $source => $path) {
            $loader->registerNamespace(
                'Shopware_Plugins',
                $path
            );
        }

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