本文整理汇总了PHP中Symfony\Component\Routing\Route::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::setOptions方法的具体用法?PHP Route::setOptions怎么用?PHP Route::setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\Route
的用法示例。
在下文中一共展示了Route::setOptions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processOutbound
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL)
{
if ($route_name === '<current>') {
if ($current_route = $this->routeMatch->getRouteObject()) {
$requirements = $current_route->getRequirements();
// Setting _method and _schema is deprecated since 2.7. Using
// setMethods() and setSchemes() are now the recommended ways.
unset($requirements['_method']);
unset($requirements['_schema']);
$route->setRequirements($requirements);
$route->setPath($current_route->getPath());
$route->setSchemes($current_route->getSchemes());
$route->setMethods($current_route->getMethods());
$route->setOptions($current_route->getOptions());
$route->setDefaults($current_route->getDefaults());
$parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
if ($bubbleable_metadata) {
$bubbleable_metadata->addCacheContexts(['route']);
}
} else {
// If we have no current route match available, point to the frontpage.
$route->setPath('/');
}
}
}
示例2: configureRoute
protected function configureRoute(\Symfony\Component\Routing\Route $route, \ReflectionClass $class, \ReflectionMethod $method, $annot)
{
// defines the controller
$route->setDefault('_controller', $class->getName() . '::' . $method->getName());
// verify the other callbacks
$options = $annot->getOptions();
foreach ($options as $prop => &$values) {
if (!in_array($prop, array('_after_middlewares', '_before_middlewares', '_converters'))) {
continue;
}
if (empty($values)) {
continue;
}
foreach ($values as &$value) {
if (is_string($value) && $class->hasMethod($value)) {
// call static method from class
$value = array($class->getName(), $value);
}
}
unset($value);
// clear reference
}
unset($values);
$route->setOptions($options);
}
示例3: 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');
}
示例4: processOutbound
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters)
{
if ($route_name === '<current>' && ($current_route = $this->routeMatch->getRouteObject())) {
$route->setPath($current_route->getPath());
$route->setRequirements($current_route->getRequirements());
$route->setOptions($current_route->getOptions());
$route->setDefaults($current_route->getDefaults());
$parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
}
}
示例5: 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');
}
示例6: processOutbound
/**
* {@inheritdoc}
*/
public function processOutbound($route_name, Route $route, array &$parameters)
{
if ($route_name === '<current>') {
if ($current_route = $this->routeMatch->getRouteObject()) {
$route->setPath($current_route->getPath());
$route->setRequirements($current_route->getRequirements());
$route->setOptions($current_route->getOptions());
$route->setDefaults($current_route->getDefaults());
$parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all());
} else {
// If we have no current route match available, point to the frontpage.
$route->setPath('/');
}
}
}
示例7: refreshEntity
/**
* Refresh the entity
*
* @ORM\PostLoad
*/
public function refreshEntity()
{
parent::setPath($this->path);
parent::setDefaults($this->defaults);
parent::setRequirements($this->requirements);
parent::setOptions($this->options);
parent::setHost($this->host);
parent::setMethods($this->methods);
parent::setSchemes($this->schemes);
}
示例8: __construct
public function __construct()
{
$this->request = Request::createFromGlobals();
$this->container = Container::getInstance();
/* Parse params file - Begin */
$params = $this->parseYamlFile(APP_DIR . DS . 'configs' . DS . 'params.yml');
$isDev = $params['environment'] === 'development';
if ($isDev) {
Debug::enable(E_STRICT);
}
date_default_timezone_set($params['timezone']);
/* Parse params file - End */
/* Parse routes file - Begin */
$routes = $this->parseYamlFile(APP_DIR . DS . 'configs' . DS . 'routes.yml');
$collection = new RouteCollection();
foreach ($routes as $name => $options) {
$parts = explode(':', $options['defaults']['_controller']);
$options['defaults'] = array('_controller' => "{$parts[0]}\\Controllers\\{$parts[1]}Controller::{$parts[2]}Action");
$route = new Route($options['path']);
$route->setDefaults($options['defaults']);
$route->setRequirements(isset($options['requirements']) ? $options['requirements'] : array());
$route->setOptions(isset($options['options']) ? $options['options'] : array());
$route->setHost(isset($options['host']) ? $options['host'] : '');
$route->setSchemes(isset($options['schemes']) ? $options['schemes'] : array());
$route->setMethods(isset($options['methods']) ? $options['methods'] : array());
$route->setCondition(isset($options['condition']) ? $options['condition'] : '');
$collection->add($name, $route);
}
$this->container->setParameter('routes', $collection);
/* Parse routes file - End */
/* Composer ClassLoader - Begin */
$composer_loader = new ClassLoader();
$composer_loader->addPsr4('Application\\Controllers\\', APP_DIR . DS . 'layers' . DS . 'controllers');
$composer_loader->addPsr4('Application\\Models\\', APP_DIR . DS . 'layers' . DS . 'models');
$composer_loader->register();
/* Composer ClassLoader - End */
/* Set error controller - Begin */
$namespace = $isDev ? 'Hideks\\Controller\\' : 'Application\\Controllers\\';
$this->container->setParameter('exception.controller', $namespace . 'ErrorController::exceptionAction');
/* Set error controller - End */
/* Assetic configuration setup - Begin */
$filter_manager = new FilterManager();
$filter_manager->set('css_min', new CssMinFilter());
$filter_manager->set('lessphp', new LessphpFilter());
$filter_manager->set('js_min', new JSMinFilter());
$asset_factory = new AssetFactory(APP_DIR . DS . 'assets' . DS);
$asset_factory->setDebug($isDev);
$asset_factory->setFilterManager($filter_manager);
$asset_factory->addWorker(new CacheBustingWorker());
$this->container->setParameter('assetic.factory', $asset_factory);
/* Assetic configuration setup - End */
/* Twig configuration setup - Begin */
$this->container->setParameter('twig.debug', $isDev);
$this->container->setParameter('twig.cache', $isDev ? false : APP_DIR . DS . 'cache' . DS . 'twig');
$twig_loader = $this->container->get('twig.loader');
$twig_loader->addPath(APP_DIR . DS . 'layers' . DS . 'views');
/* Twig configuration setup - End */
/* Active Record configuration setup - Begin */
$active_record = \ActiveRecord\Config::instance();
$active_record->set_model_directory(APP_DIR . DS . 'layers' . DS . 'models');
$active_record->set_connections($params['connections']);
$active_record->set_default_connection($params['environment']);
/* Active Record configuration setup - End */
}