本文整理汇总了PHP中Symfony\Component\Routing\Route::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Route::setOption方法的具体用法?PHP Route::setOption怎么用?PHP Route::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Routing\Route
的用法示例。
在下文中一共展示了Route::setOption方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->mockedRoute = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock();
$this->mockedSiteMapControllerService = $this->getMockBuilder('RepoSitemapBundle\\Services\\SiteMapControllerService')->disableOriginalConstructor()->getMock();
$this->sitemapInfo = array('type' => SiteMapOptionService::TYPE_DYNAMIC, 'repository' => 'AppBundle:Test', 'lastmod' => '2000-01-01', 'changefreq' => 'daily', 'priority' => 0.67);
$this->route = new Route('tests');
$this->route->setOption('sitemap', $this->sitemapInfo);
}
示例2: setUp
public function setUp()
{
parent::setUp();
$this->mockedSiteMapOptionService = $this->getMockBuilder('RepoSitemapBundle\\Services\\SiteMapOptionService')->disableOriginalConstructor()->setMethods(array('getOptionValues', 'setOtherOptions'))->getMock();
$this->mockedRoute = $this->getMockBuilder('Symfony\\Component\\Routing\\Route')->disableOriginalConstructor()->getMock();
$this->sitemapOption = array('repository' => 'AppBundle:Test', 'lastmod' => '2000-01-01', 'changefreq' => 'daily', 'priority' => 0.67);
$this->route = new Route('tests');
$this->route->setOption('sitemap', $this->sitemapOption);
}
示例3: testBuildBasicRenderable
/**
* @covers ::buildBasicRenderable
*/
public function testBuildBasicRenderable()
{
$route = new Route('/test-view');
$route->setDefault('view_id', 'test_view');
$route->setOption('_view_display_plugin_id', 'page');
$route->setOption('_view_display_show_admin_links', TRUE);
$result = Page::buildBasicRenderable('test_view', 'page_1', [], $route);
$this->assertEquals('test_view', $result['#view_id']);
$this->assertEquals('page', $result['#view_display_plugin_id']);
$this->assertEquals(TRUE, $result['#view_display_show_admin_links']);
}
示例4: handleMethodAnnotations
/**
* Handle method annotations
*
* @param mixed $targetObj
* @param \ReflectionMethod $reflection
* @param array $annotations
*
* @return mixed
*/
public function handleMethodAnnotations(\ReflectionMethod $reflection, array $annotations, $targetObj = null)
{
if (isset($annotations['Route'])) {
foreach ($annotations['Route'] as $route) {
if ($route instanceof \stdClass && isset($route->path)) {
$symfonyRoute = new Route($route->path, isset($route->defaults) ? $route->defaults : [], isset($route->requirements) ? $route->requirements : [], isset($route->options) ? $route->options : [], isset($route->host) ? $route->host : '', isset($route->schemes) ? $route->schemes : [], isset($route->methods) ? $route->methods : []);
$symfonyRoute->setOption('karmaController', $reflection->getDeclaringClass()->getName());
$symfonyRoute->setOption('karmaAction', $reflection->getName());
$this->routeCollection->add(isset($route->name) ? $route->name : $reflection->getDeclaringClass()->getName() . ':' . $reflection->getName(), $symfonyRoute);
}
}
}
}
示例5: processRoute
/**
* {@inheritdoc}
*/
protected function processRoute(Route $route)
{
// Add entity upcasting information.
$parameters = $route->getOption('parameters') ?: array();
$parameters += array('menu_link_plugin' => array('type' => 'menu_link_plugin'));
$route->setOption('parameters', $parameters);
}
示例6: revisionDeleteRoute
protected function revisionDeleteRoute(EntityTypeInterface $entity_type)
{
$route = new Route($entity_type->getLinkTemplate('revision-delete'));
$route->setDefault('_form', 'Drupal\\content_entity_base\\Entity\\Form\\EntityRevisionDeleteForm');
$route->setDefault('_title', 'Delete earlier revision');
$route->setRequirement('_entity_access_revision', $entity_type->id() . '.delete');
$route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()], $entity_type->id() . '_revision' => ['type' => 'entity_revision:' . $entity_type->id()]]);
return $route;
}
示例7: testCompilationDefaultValue
/**
* Confirms that a compiled route with default values has the correct outline.
*/
public function testCompilationDefaultValue()
{
// Because "here" has a default value, it should not factor into the outline
// or the fitness.
$route = new Route('/test/{something}/more/{here}', array('here' => 'there'));
$route->setOption('compiler_class', 'Drupal\\Core\\Routing\\RouteCompiler');
$compiled = $route->compile();
$this->assertEquals($compiled->getFit(), 5, 'The fit was not correct.');
$this->assertEquals($compiled->getPatternOutline(), '/test/%/more', 'The pattern outline was not correct.');
}
示例8: addPageRoute
protected function addPageRoute(EntityTypeInterface $entity_type)
{
$route = new Route($entity_type->getLinkTemplate('add-page'));
$route->setDefault('_controller', '\\Drupal\\content_entity_base\\Entity\\Controller\\EntityBaseController::addPage');
$route->setDefault('_title_callback', '\\Drupal\\content_entity_base\\Entity\\Controller\\EntityBaseController::getAddPageTitle');
$route->setDefault('entity_definition', $entity_type->id());
$route->setOption('parameters', ['entity_definition' => ['type' => 'entity_definition']]);
$route->setRequirement('_entity_create_access', $entity_type->id());
return $route;
}
示例9: getRevisionViewRoute
/**
* Gets the entity revision view route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRevisionViewRoute(EntityTypeInterface $entity_type)
{
if ($entity_type->hasLinkTemplate('revision')) {
$entity_type_id = $entity_type->id();
$route = new Route($entity_type->getLinkTemplate('revision'));
$route->addDefaults(['_controller' => '\\Drupal\\entity\\Controller\\RevisionController::view', '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title']);
$route->addRequirements(['_entity_access_revision' => "{$entity_type_id}.view"]);
$route->setOption('parameters', [$entity_type->id() => ['type' => 'entity:' . $entity_type->id()], $entity_type->id() . '_revision' => ['type' => 'entity_revision:' . $entity_type->id()]]);
return $route;
}
}
示例10: getAddFormRoute
/**
* Gets the add-form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getAddFormRoute(EntityTypeInterface $entity_type)
{
if ($entity_type->hasLinkTemplate('add-form')) {
$entity_type_id = $entity_type->id();
$parameters = [$entity_type_id => ['type' => 'entity:' . $entity_type_id]];
$route = new Route($entity_type->getLinkTemplate('add-form'));
$bundle_entity_type_id = $entity_type->getBundleEntityType();
// Content entities with bundles are added via a dedicated controller.
$route->setDefaults(['_controller' => 'Drupal\\drupalbristol_sponsors\\Controller\\SponsorEntityAddController::addForm', '_title_callback' => 'Drupal\\drupalbristol_sponsors\\Controller\\SponsorEntityAddController::getAddFormTitle'])->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}');
$parameters[$bundle_entity_type_id] = ['type' => 'entity:' . $bundle_entity_type_id];
$route->setOption('parameters', $parameters)->setOption('_admin_route', TRUE);
return $route;
}
}
示例11: testDefaultFilter
/**
* @covers ::defaultFilter
* @covers ::applyFilter
*
* @dataProvider providerTestDefaultFilter
*/
public function testDefaultFilter($applies, $has_route, $auth_option, $provider_id, $global)
{
$authentication_manager = new AuthenticationManager();
$auth_provider = $this->getMock('Drupal\\Core\\Authentication\\AuthenticationProviderInterface');
$authentication_manager->addProvider($auth_provider, $provider_id, 0, $global);
$request = new Request();
if ($has_route) {
$route = new Route('/example');
if ($auth_option) {
$route->setOption('_auth', $auth_option);
}
$request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, $route);
}
$this->assertSame($applies, $authentication_manager->appliesToRoutedRequest($request, FALSE));
}
示例12: getAddFormRoute
/**
* Gets the add-form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getAddFormRoute(EntityTypeInterface $entity_type)
{
if ($entity_type->hasLinkTemplate('add-form')) {
$entity_type_id = $entity_type->id();
$parameters = [$entity_type_id => ['type' => 'entity:' . $entity_type_id]];
$route = new Route($entity_type->getLinkTemplate('add-form'));
// Content entities with bundles are added via a dedicated controller.
if ($bundle_entity_type_id = $entity_type->getBundleEntityType()) {
$route->setDefaults(['_controller' => 'Drupal\\custom_page\\Controller\\CustomPageAddController::addForm', '_title_callback' => 'Drupal\\custom_page\\Controller\\CustomPageAddController::getAddFormTitle'])->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}');
$parameters[$bundle_entity_type_id] = ['type' => 'entity:' . $bundle_entity_type_id];
} else {
// Use the add form handler, if available, otherwise default.
$operation = 'default';
if ($entity_type->getFormClass('add')) {
$operation = 'add';
}
$route->setDefaults(['_entity_form' => "{$entity_type_id}.{$operation}", '_title' => "Add {$entity_type->getLabel()}"])->setRequirement('_entity_create_access', $entity_type_id);
}
$route->setOption('parameters', $parameters)->setOption('_admin_route', TRUE);
return $route;
}
}
示例13: processRoute
/**
* {@inheritdoc}
*/
protected function processRoute(Route $route)
{
// Add entity upcasting information.
$parameters = $route->getOption('parameters') ?: array();
$parameters += array($this->entityType => array('type' => 'entity:' . $this->entityType));
$route->setOption('parameters', $parameters);
}
示例14: getTestRoute
protected function getTestRoute()
{
$route = new Route('/test/{test_revision}');
$route->setOption('parameters', ['test_revision' => ['type' => 'entity_revision:test']]);
return $route;
}
示例15: testDump
/**
* Confirm that we can dump a route collection to the database.
*/
public function testDump()
{
$connection = Database::getConnection();
$dumper = new MatcherDumper($connection, $this->state, 'test_routes');
$route = new Route('/test/{my}/path');
$route->setOption('compiler_class', 'Drupal\\Core\\Routing\\RouteCompiler');
$collection = new RouteCollection();
$collection->add('test_route', $route);
$dumper->addRoutes($collection);
$this->fixtures->createTables($connection);
$dumper->dump(array('provider' => 'test'));
$record = $connection->query("SELECT * FROM {test_routes} WHERE name= :name", array(':name' => 'test_route'))->fetchObject();
$loaded_route = unserialize($record->route);
$this->assertEqual($record->name, 'test_route', 'Dumped route has correct name.');
$this->assertEqual($record->path, '/test/{my}/path', 'Dumped route has correct pattern.');
$this->assertEqual($record->pattern_outline, '/test/%/path', 'Dumped route has correct pattern outline.');
$this->assertEqual($record->fit, 5, 'Dumped route has correct fit.');
$this->assertTrue($loaded_route instanceof Route, 'Route object retrieved successfully.');
}