本文整理汇总了PHP中Symfony\Component\Routing\Route::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::getOptions方法的具体用法?PHP Route::getOptions怎么用?PHP Route::getOptions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\Route
的用法示例。
在下文中一共展示了Route::getOptions方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOptions
public function testOptions()
{
$route = new Route('/{foo}');
$route->setOptions(array('foo' => 'bar'));
$this->assertEquals(array_merge(array('segment_separators' => array('/', '.'), 'text_regex' => '.+?', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), array('foo' => 'bar')), $route->getOptions(), '->setOptions() sets the options');
$this->assertEquals($route, $route->setOptions(array()), '->setOptions() implements a fluent interface');
}
示例2: testOptions
public function testOptions()
{
$route = new Route('/{foo}');
$route->setOptions(array('foo' => 'bar'));
$this->assertEquals(array_merge(array('compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), array('foo' => 'bar')), $route->getOptions(), '->setOptions() sets the options');
$this->assertEquals($route, $route->setOptions(array()), '->setOptions() implements a fluent interface');
$route->setOptions(array('foo' => 'foo'));
$route->addOptions(array('bar' => 'bar'));
$this->assertEquals($route, $route->addOptions(array()), '->addOptions() implements a fluent interface');
$this->assertEquals(array('foo' => 'foo', 'bar' => 'bar', 'compiler_class' => 'Symfony\\Component\\Routing\\RouteCompiler'), $route->getOptions(), '->addDefaults() keep previous defaults');
}
示例3: getOptions
/**
* {@inheritDoc}
*
* Handling the missing default 'compiler_class'
* @see setOptions
*/
public function getOptions()
{
$options = parent::getOptions();
if (!array_key_exists('compiler_class', $options)) {
$options['compiler_class'] = 'Symfony\\Component\\Routing\\RouteCompiler';
}
foreach ($options as $key => $value) {
if ($this->isBooleanOption($key)) {
$options[$key] = (bool) $value;
}
}
return $options;
}
示例4: getOptions
/**
* {@inheritDoc}
*
* Handling the missing default 'compiler_class'
* @see setOptions
*/
public function getOptions()
{
$options = parent::getOptions();
if (!array_key_exists('compiler_class', $options)) {
$options['compiler_class'] = 'Symfony\\Component\\Routing\\RouteCompiler';
}
return $options;
}
示例5: setOptions
/**
* Set the options
*
* @param array $options
* @return Route
*/
public function setOptions(array $options)
{
parent::setOptions($options);
$this->options = parent::getOptions();
return $this;
}
示例6: assertMatchingRoute
/**
* Asserts that a route object has the expected properties.
*
* @param \Symfony\Component\Routing\Route $route
* The route to test.
* @param string $expected_path
* The expected path for the route.
* @param array $expected_defaults
* The expected defaults for the route.
* @param array $expected_requirements
* The expected requirements for the route.
* @param array $expected_options
* The expected options for the route.
*/
protected function assertMatchingRoute(Route $route, $expected_path, $expected_defaults, $expected_requirements, $expected_options)
{
$this->assertSame($expected_path, $route->getPath());
$this->assertSame($expected_defaults, $route->getDefaults());
$this->assertSame($expected_requirements, $route->getRequirements());
$this->assertSame($expected_options, $route->getOptions());
}
示例7: getOptions
/**
* Returns the options.
*
* @return array
* The options.
*/
public function getOptions()
{
return $this->route->getOptions();
}
示例8: prependBundlePrefix
/**
* Prepends the bundle prefix to the route.
*
* @param Route $route
* @param AbstractBundle $bundle
*
* We have to prepend the bundle prefix if
* - routes are _not_ currently extracted via the command line and
* - the route has i18n set to false.
* This is because when extracting the routes, a bundle author only wants to translate the bare route
* patterns, without a redundant and potentially customized bundle prefix in front of them.
* If i18n is set to true, Zikula's customized pattern generation strategy will take care of it.
* See Zikula\RoutesModule\Translation\ZikulaPatternGenerationStrategy
*/
private function prependBundlePrefix(Route $route, AbstractBundle $bundle)
{
$prefix = '';
$options = $route->getOptions();
$prependBundle = !isset($GLOBALS['translation_extract_routes']) && isset($options['i18n']) && !$options['i18n'];
if ($prependBundle && (!isset($options['zkNoBundlePrefix']) || !$options['zkNoBundlePrefix'])) {
// get url from MetaData first. May be empty.
$untranslatedPrefix = $bundle->getMetaData()->getUrl(false);
if (empty($untranslatedPrefix)) {
try {
// MetaData will be empty for extensions not Spec-2.0. Try to get from modinfo.
// this calls the DB which is not available during install.
$modinfo = \ModUtil::getInfoFromName($bundle->getName());
$prefix = $modinfo['url'];
} catch (\Exception $e) {
}
} else {
$locale = $this->container->getParameter('locale');
if ($this->translator->getCatalogue($locale)->has($untranslatedPrefix, strtolower($bundle->getName()))) {
$prefix = $this->translator->trans($untranslatedPrefix, [], strtolower($bundle->getName()), $locale);
} else {
$prefix = $untranslatedPrefix;
}
}
$path = "/" . $prefix . $route->getPath();
$route->setPath($path);
}
}
示例9: cloneRoute
/**
* Makes a clone of the given Route object.
*
* @param Route $route
*
* @return Route
*/
public function cloneRoute(Route $route)
{
return new Route($route->getPath(), $route->getDefaults(), $route->getRequirements(), $route->getOptions(), $route->getHost(), $route->getSchemes(), $route->getMethods());
}