registerNamespace example

public function testFilterXPathWithMultipleNamespaces()
    {
        $crawler = $this->createTestXmlCrawler()->filterXPath('//media:group/yt:aspectRatio');
        $this->assertCount(1, $crawler, '->filterXPath() automatically registers multiple namespaces');
        $this->assertSame('widescreen', $crawler->text());
    }

    public function testFilterXPathWithManuallyRegisteredNamespace()
    {
        $crawler = $this->createTestXmlCrawler();
        $crawler->registerNamespace('m', 'http://search.yahoo.com/mrss/');

        $crawler = $crawler->filterXPath('//m:group/yt:aspectRatio');
        $this->assertCount(1, $crawler, '->filterXPath() uses manually registered namespace');
        $this->assertSame('widescreen', $crawler->text());
    }

    public function testFilterXPathWithAnUrl()
    {
        $crawler = $this->createTestXmlCrawler();

        $crawler = $crawler->filterXPath('//media:category[@scheme="http://gdata.youtube.com/schemas/2007/categories.cat"]');
        
$front->setDispatcher($container->get('dispatcher'));

        $front->setRouter($container->get(RouterInterface::class));

        $front->setParams($options);

        $front->setRequestStack($requestStack);

        /** @var Enlight_Plugin_PluginManager $plugins */
        $plugins = $container->get('plugins');

        $plugins->registerNamespace($front->Plugins());

        if (!empty($options['throwExceptions'])) {
            $front->throwExceptions((bool) $options['throwExceptions']);
        }

        try {
            $container->load('cache');
            $container->load('db');
            $container->load('plugins');
        } catch (Exception $e) {
            if ($front->throwExceptions()) {
                
/** * @return CacheIdCollector */
    public function initCacheIdCollector()
    {
        return new CacheIdCollector();
    }

    public function afterInit()
    {
        $this->get(Enlight_Loader::class)->registerNamespace('ShopwarePlugins\\HttpCache', __DIR__);
        parent::afterInit();
    }

    public function getCapabilities()
    {
        return [
            'install' => false,
            'enable' => false,
            'update' => true,
        ];
    }

    

        $path = $this->locator->locate($resource);

        $xml = $this->parseFileToDOM($path);

        $this->container->fileExists($path);

        $this->loadXml($xml$path);

        if ($this->env) {
            $xpath = new \DOMXPath($xml);
            $xpath->registerNamespace('container', self::NS);
            foreach ($xpath->query(sprintf('//container:when[@env="%s"]', $this->env)) ?: [] as $root) {
                $env = $this->env;
                $this->env = null;
                try {
                    $this->loadXml($xml$path$root);
                } finally {
                    $this->env = $env;
                }
            }
        }

        
if (!isset($options['proxyDir'])) {
            throw new \Exception('proxyDir has to be set.');
        }

        $this->proxyFactory = new Enlight_Hook_ProxyFactory(
            $this,
            $options['proxyNamespace'],
            $options['proxyDir']
        );

        $loader->registerNamespace(
            $options['proxyNamespace'],
            $this->proxyFactory->getProxyDir()
        );
    }

    /** * @return Enlight_Hook_ProxyFactory */
    public function getProxyFactory()
    {
        return $this->proxyFactory;
    }
'install' => false,
            'enable' => false,
            'update' => true,
        ];
    }

    /** * Is executed after the collection has been added. */
    public function afterInit()
    {
        $this->get(Enlight_Loader::class)->registerNamespace(
            'ShopwarePlugins\\RestApi\\Components',
            __DIR__ . '/Components/'
        );
    }

    /** * Listener method for the Enlight_Controller_Front_DispatchLoopStartup event. * * @return void */
    public function onDispatchLoopStartup(Enlight_Controller_EventArgs $args)
    {
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()
    {
/** * 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 */

    public function factory(
        EventManager $eventManager,
        Configuration $config,
        Enlight_Loader $loader,
        Connection $connection,
        // Annotation driver is not really used here but has to be loaded first         AnnotationDriver $modelAnnotation,
        ?QueryOperatorValidator $operatorValidator = null
    ) {
        $loader->registerNamespace(
            'Shopware\Models\Attribute',
            $config->getAttributeDir()
        );

        $connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
        $connection->getDatabasePlatform()->registerDoctrineTypeMapping('bit', 'boolean');

        $entityManager = ModelManager::createInstance(
            $connection,
            $config,
            $eventManager,
            
// XML taken from https://www.iana.org/assignments/http-status-codes/http-status-codes.xml         // (might not be up-to-date for older Symfony versions)         $ianaHttpStatusCodes = new \DOMDocument();
        $ianaHttpStatusCodes->load(__DIR__.'/Fixtures/xml/http-status-codes.xml');
        if (!$ianaHttpStatusCodes->relaxNGValidate(__DIR__.'/schema/http-status-codes.rng')) {
            self::fail('Invalid IANA\'s HTTP status code list.');
        }

        $ianaCodesReasonPhrases = [];

        $xpath = new \DOMXPath($ianaHttpStatusCodes);
        $xpath->registerNamespace('ns', 'http://www.iana.org/assignments');

        $records = $xpath->query('//ns:record');
        foreach ($records as $record) {
            $value = $xpath->query('.//ns:value', $record)->item(0)->nodeValue;
            $description = $xpath->query('.//ns:description', $record)->item(0)->nodeValue;

            if (\in_array($description['Unassigned', '(Unused)'], true)) {
                continue;
            }

            if (preg_match('/^([0-9]+)\s*\-\s*([0-9]+)$/', $value$matches)) {
                
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. */
 {
        $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;
    }
return ['success' => true, 'invalidateCache' => ['backend']];
    }

    /** * Register Plugin namespace in autoloader */
    public function afterInit()
    {
        /** @var Enlight_Loader $loader */
        $loader = $this->get(Enlight_Loader::class);
        $loader->registerNamespace(
            'ShopwarePlugins\\SwagUpdate',
            __DIR__ . '/'
        );
    }

    /** * When index backend module was loaded, add our snippet- and template-directory * Also extend the template * * @return void */
    


        // 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> */

        $path = $this->locator->locate($resource);

        $xml = $this->parseFileToDOM($path);

        $this->container->fileExists($path);

        $this->loadXml($xml$path);

        if ($this->env) {
            $xpath = new \DOMXPath($xml);
            $xpath->registerNamespace('container', self::NS);
            foreach ($xpath->query(sprintf('//container:when[@env="%s"]', $this->env)) ?: [] as $root) {
                $env = $this->env;
                $this->env = null;
                try {
                    $this->loadXml($xml$path$root);
                } finally {
                    $this->env = $env;
                }
            }
        }

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