当前位置: 首页>>代码示例>>PHP>>正文


PHP Route::setOption方法代码示例

本文整理汇总了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);
 }
开发者ID:botalaszlo,项目名称:symfony-repositemap-bundle,代码行数:9,代码来源:SiteMapControllerServiceTest.php

示例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);
 }
开发者ID:botalaszlo,项目名称:symfony-repositemap-bundle,代码行数:9,代码来源:SiteMapOptionServiceTest.php

示例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']);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:14,代码来源:PageTest.php

示例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);
             }
         }
     }
 }
开发者ID:thinframe,项目名称:karma,代码行数:22,代码来源:RouteHandler.php

示例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);
 }
开发者ID:robertfoleyjr,项目名称:robertfoleyjr-d8,代码行数:10,代码来源:MenuLinkConfigMapper.php

示例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;
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:9,代码来源:RevisionHtmlRouteProvider.php

示例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.');
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:13,代码来源:RouteCompilerTest.php

示例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;
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:10,代码来源:CrudUiRouteProvider.php

示例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;
     }
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:20,代码来源:RevisionRouteProvider.php

示例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;
     }
 }
开发者ID:drupalbristol,项目名称:drupal-bristol-website,代码行数:23,代码来源:SponsorEntityHtmlRouteProvider.php

示例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));
 }
开发者ID:nstielau,项目名称:drops-8,代码行数:21,代码来源:AuthenticationManagerTest.php

示例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;
     }
 }
开发者ID:poetic,项目名称:clutch,代码行数:31,代码来源:CustomPageHtmlRouteProvider.php

示例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);
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:ConfigEntityMapper.php

示例14: getTestRoute

 protected function getTestRoute()
 {
     $route = new Route('/test/{test_revision}');
     $route->setOption('parameters', ['test_revision' => ['type' => 'entity_revision:test']]);
     return $route;
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:6,代码来源:EntityRevisionParamConverterTest.php

示例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.');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:22,代码来源:MatcherDumperTest.php


注:本文中的Symfony\Component\Routing\Route::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。