addNamePrefix example

if (null !== $condition) {
                $subCollection->setCondition($condition);
            }
            if (null !== $schemes) {
                $subCollection->setSchemes($schemes);
            }
            if (null !== $methods) {
                $subCollection->setMethods($methods);
            }
            if (null !== $namePrefix) {
                $subCollection->addNamePrefix($namePrefix);
            }
            $subCollection->addDefaults($defaults);
            $subCollection->addRequirements($requirements);
            $subCollection->addOptions($options);

            $collection->addCollection($subCollection);
        }
    }

    /** * @throws \InvalidArgumentException When loading of XML file fails because of syntax errors * or when the XML structure is not as expected by the scheme - * see validate() */
$this->assertSame('/fun', $compiledUrlGenerator->generate('fun.en'));
        $this->assertSame('/fun', $compiledUrlGenerator->generate('fun', ['_locale' => 'en']));
        $this->assertSame('/amusant', $compiledUrlGenerator->generate('fun.fr', ['_locale' => 'en']));
    }

    public function testAliases()
    {
        $subCollection = new RouteCollection();
        $subCollection->add('a', new Route('/sub'));
        $subCollection->addAlias('b', 'a');
        $subCollection->addAlias('c', 'b');
        $subCollection->addNamePrefix('sub_');

        $this->routeCollection->add('a', new Route('/foo'));
        $this->routeCollection->addAlias('b', 'a');
        $this->routeCollection->addAlias('c', 'b');
        $this->routeCollection->addCollection($subCollection);

        file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump());

        $compiledUrlGenerator = new CompiledUrlGenerator(require $this->testTmpFilepath, new RequestContext());

        $this->assertSame('/foo', $compiledUrlGenerator->generate('b'));
        
return $this;
    }

    /** * Sets the prefix to add to the name of all child routes. * * @return $this */
    final public function namePrefix(string $namePrefix)static
    {
        $this->route->addNamePrefix($namePrefix);

        return $this;
    }

    /** * Sets the host to use for all child routes. * * @param string|array $host the host, or the localized hosts * * @return $this */
    

            if (null !== $condition) {
                $subCollection->setCondition($condition);
            }
            if (null !== $schemes) {
                $subCollection->setSchemes($schemes);
            }
            if (null !== $methods) {
                $subCollection->setMethods($methods);
            }
            if (null !== $namePrefix) {
                $subCollection->addNamePrefix($namePrefix);
            }
            $subCollection->addDefaults($defaults);
            $subCollection->addRequirements($requirements);
            $subCollection->addOptions($options);

            $collection->addCollection($subCollection);
        }
    }

    /** * @return void * * @throws \InvalidArgumentException If one of the provided config keys is not supported, * something is missing or the combination is nonsense */

            if (null !== $condition) {
                $subCollection->setCondition($condition);
            }
            if (null !== $schemes) {
                $subCollection->setSchemes($schemes);
            }
            if (null !== $methods) {
                $subCollection->setMethods($methods);
            }
            if (null !== $namePrefix) {
                $subCollection->addNamePrefix($namePrefix);
            }
            $subCollection->addDefaults($defaults);
            $subCollection->addRequirements($requirements);
            $subCollection->addOptions($options);

            $collection->addCollection($subCollection);
        }
    }

    /** * @return void * * @throws \InvalidArgumentException If one of the provided config keys is not supported, * something is missing or the combination is nonsense */
return $this;
    }

    /** * Sets the prefix to add to the name of all child routes. * * @return $this */
    final public function namePrefix(string $namePrefix)static
    {
        $this->route->addNamePrefix($namePrefix);

        return $this;
    }

    /** * Sets the host to use for all child routes. * * @param string|array $host the host, or the localized hosts * * @return $this */
    
$this->assertEquals(['PUT']$routea->getMethods());
        $this->assertEquals(['PUT']$routeb->getMethods());
    }

    public function testAddNamePrefix()
    {
        $collection = new RouteCollection();
        $collection->add('foo', $foo = new Route('/foo'));
        $collection->add('bar', $bar = new Route('/bar'));
        $collection->add('api_foo', $apiFoo = new Route('/api/foo'));
        $collection->addNamePrefix('api_');

        $this->assertEquals($foo$collection->get('api_foo'));
        $this->assertEquals($bar$collection->get('api_bar'));
        $this->assertEquals($apiFoo$collection->get('api_api_foo'));
        $this->assertNull($collection->get('foo'));
        $this->assertNull($collection->get('bar'));
    }

    public function testAddNamePrefixCanonicalRouteName()
    {
        $collection = new RouteCollection();
        
if (null !== $condition) {
                $subCollection->setCondition($condition);
            }
            if (null !== $schemes) {
                $subCollection->setSchemes($schemes);
            }
            if (null !== $methods) {
                $subCollection->setMethods($methods);
            }
            if (null !== $namePrefix) {
                $subCollection->addNamePrefix($namePrefix);
            }
            $subCollection->addDefaults($defaults);
            $subCollection->addRequirements($requirements);
            $subCollection->addOptions($options);

            $collection->addCollection($subCollection);
        }
    }

    /** * @throws \InvalidArgumentException When loading of XML file fails because of syntax errors * or when the XML structure is not as expected by the scheme - * see validate() */
Home | Imprint | This part of the site doesn't use cookies.