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


PHP RouteCollection::add方法代码示例

本文整理汇总了PHP中Symfony\Component\Routing\RouteCollection::add方法的典型用法代码示例。如果您正苦于以下问题:PHP RouteCollection::add方法的具体用法?PHP RouteCollection::add怎么用?PHP RouteCollection::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Routing\RouteCollection的用法示例。


在下文中一共展示了RouteCollection::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createRoutes

 private function createRoutes($entity)
 {
     $prefix = self::DEFAULT_PREFIX;
     $parts = explode('\\', $entity);
     $bundle = str_replace('bundle', '', strtolower($parts[1]));
     $routeKey = strtolower($parts[3]);
     $controller = strtolower($parts[3]);
     // pheetup.controller.bundle.controller
     $controller_service = 'pheetup.controller.' . $bundle . '.' . $controller;
     //create
     $createPattern = $prefix . '/' . $routeKey . '/create/{id}';
     $createDefaults = ['_controller' => $controller_service . ':createAction', 'id' => 0];
     $createRoute = new Route($createPattern, $createDefaults);
     $this->routes->add('pheetup_' . $routeKey . '_create', $createRoute);
     //list
     $listPattern = $prefix . '/' . $routeKey;
     $listDefaults = ['_controller' => $controller_service . ':listAction'];
     $listRoute = new Route($listPattern, $listDefaults);
     $this->routes->add('pheetup_' . $routeKey, $listRoute);
     //delete
     $deletePattern = $prefix . '/' . $routeKey . '/delete/{id}';
     $deleteDefaults = ['_controller' => $controller_service . ':deleteAction'];
     $deleteRoute = new Route($deletePattern, $deleteDefaults, ['id' => '\\d+']);
     $this->routes->add('pheetup_' . $routeKey . '_delete', $deleteRoute);
     //view
     $viewPattern = $prefix . '/' . $routeKey . '/explore/{id}';
     $viewDefaults = ['_controller' => $controller_service . ':viewAction'];
     $viewRoute = new Route($viewPattern, $viewDefaults, ['id' => '\\d+']);
     $this->routes->add('pheetup_' . $routeKey . '_view', $viewRoute);
 }
开发者ID:AnkaraPHP,项目名称:pheetup,代码行数:30,代码来源:RouteLoader.php

示例2: load

 public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add the "dynamic" loader twice');
     }
     $defaultSite = $this->sm()->getDefaultSite();
     $routes = new RouteCollection();
     $homeRedirectRoute = new Route('/', array('_controller' => 'FrameworkBundle:Redirect:urlRedirect', 'path' => '/' . $defaultSite->getSlug() . '/index.php', 'permanent' => true));
     $routes->add('homeRedirect', $homeRedirectRoute);
     $homeRedirectRoute = new Route('/{siteSlug}/index.php', array('_controller' => 'BWCMSBundle:FrontEnd:home'), array('siteSlug' => '[a-zA-Z0-9-]+'));
     $routes->add('home_page', $homeRedirectRoute);
     //make sure all content types are initialized.
     $this->cm()->init();
     $registerContentTypes = $this->cm()->getAllContentTypes();
     foreach ($registerContentTypes as $contentType) {
         $routeCollection = $contentType->getRouteCollection();
         if (!is_null($routeCollection)) {
             foreach ($routeCollection as $routeName => $routeInfo) {
                 $routes->add($routeName, $routeInfo);
             }
         }
     }
     $routeLoaderEvent = new RouteLoaderEvent();
     $routeLoaderEvent->setRoutes($routes);
     $this->getEventDispatcher()->dispatch('BWCMS.Route.Loader', $routeLoaderEvent);
     $this->loaded = true;
     return $routeLoaderEvent->getRoutes();
 }
开发者ID:anoopogt,项目名称:BWCMS,代码行数:28,代码来源:RoutingService.php

示例3: testLoad

 public function testLoad()
 {
     $importedRouteCollection = new RouteCollection();
     $importedRouteCollection->add('route1', new Route('/example/route1'));
     $importedRouteCollection->add('route2', new Route('/route2'));
     $portal1 = new Portal();
     $portal1->setKey('sulu_lo');
     $portal2 = new Portal();
     $portal2->setKey('sulu_com');
     $portalInformations = [new PortalInformation(null, null, $portal1, null, 'sulu.io/de'), new PortalInformation(null, null, $portal2, null, 'sulu.com')];
     $this->loaderResolver->resolve(Argument::any(), Argument::any())->willReturn($this->loader->reveal());
     $this->loader->load(Argument::any(), Argument::any())->willReturn($importedRouteCollection);
     $this->webspaceManager->getPortalInformations(Argument::any())->willReturn($portalInformations);
     $routeCollection = $this->portalLoader->load('', 'portal');
     $this->assertCount(4, $routeCollection);
     $routes = $routeCollection->getIterator();
     $this->assertArrayHasKey('sulu.io/de.route1', $routes);
     $this->assertArrayHasKey('sulu.io/de.route2', $routes);
     $this->assertArrayHasKey('sulu.com.route1', $routes);
     $this->assertArrayHasKey('sulu.com.route2', $routes);
     $this->assertEquals('/de/example/route1', $routeCollection->get('sulu.io/de.route1')->getPath());
     $this->assertEquals('/de/route2', $routeCollection->get('sulu.io/de.route2')->getPath());
     $this->assertEquals('/example/route1', $routeCollection->get('sulu.com.route1')->getPath());
     $this->assertEquals('/route2', $routeCollection->get('sulu.com.route2')->getPath());
 }
开发者ID:Silwereth,项目名称:sulu,代码行数:25,代码来源:PortalLoaderTest.php

示例4: test

 public function test()
 {
     $coll = new RouteCollection();
     $coll->add('foo', new Route('/foo', array(), array('_method' => 'POST')));
     $coll->add('bar', new Route('/bar/{id}', array(), array('id' => '\\d+')));
     $coll->add('bar1', new Route('/bar/{name}', array(), array('id' => '\\w+', '_method' => 'POST')));
     $coll->add('bar2', new Route('/foo', array(), array(), array(), 'baz'));
     $coll->add('bar3', new Route('/foo1', array(), array(), array(), 'baz'));
     $context = new RequestContext();
     $context->setHost('baz');
     $matcher = new TraceableUrlMatcher($coll, $context);
     $traces = $matcher->getTraces('/babar');
     $this->assertEquals(array(0, 0, 0, 0, 0), $this->getLevels($traces));
     $traces = $matcher->getTraces('/foo');
     $this->assertEquals(array(1, 0, 0, 2), $this->getLevels($traces));
     $traces = $matcher->getTraces('/bar/12');
     $this->assertEquals(array(0, 2), $this->getLevels($traces));
     $traces = $matcher->getTraces('/bar/dd');
     $this->assertEquals(array(0, 1, 1, 0, 0), $this->getLevels($traces));
     $traces = $matcher->getTraces('/foo1');
     $this->assertEquals(array(0, 0, 0, 0, 2), $this->getLevels($traces));
     $context->setMethod('POST');
     $traces = $matcher->getTraces('/foo');
     $this->assertEquals(array(2), $this->getLevels($traces));
     $traces = $matcher->getTraces('/bar/dd');
     $this->assertEquals(array(0, 1, 2), $this->getLevels($traces));
 }
开发者ID:marchyoung,项目名称:FrameworkBenchmarks,代码行数:27,代码来源:TraceableUrlMatcherTest.php

示例5: testAbsoluteSecureUrlWithNonStandardPort

 public function testAbsoluteSecureUrlWithNonStandardPort()
 {
     $this->routeCollection->add('test', new Route('/testing'));
     $this->generator->setContext(array('base_url' => '/app.php', 'method' => 'GET', 'host' => 'localhost', 'port' => 8080, 'is_secure' => true));
     $url = $this->generator->generate('test', array(), true);
     $this->assertEquals('https://localhost:8080/app.php/testing', $url);
 }
开发者ID:rooster,项目名称:symfony,代码行数:7,代码来源:UrlGeneratorTest.php

示例6: filter

 /**
  * {@inheritdoc}
  */
 public function filter(RouteCollection $collection, Request $request)
 {
     // Generates a list of Symfony formats matching the acceptable MIME types.
     // @todo replace by proper content negotiation library.
     $acceptable_mime_types = $request->getAcceptableContentTypes();
     $acceptable_formats = array_filter(array_map(array($request, 'getFormat'), $acceptable_mime_types));
     $primary_format = $request->getRequestFormat();
     foreach ($collection as $name => $route) {
         // _format could be a |-delimited list of supported formats.
         $supported_formats = array_filter(explode('|', $route->getRequirement('_format')));
         if (empty($supported_formats)) {
             // No format restriction on the route, so it always matches. Move it to
             // the end of the collection by re-adding it.
             $collection->add($name, $route);
         } elseif (in_array($primary_format, $supported_formats)) {
             // Perfect match, which will get a higher priority by leaving the route
             // on top of the list.
         } elseif (in_array('*/*', $acceptable_mime_types) || array_intersect($acceptable_formats, $supported_formats)) {
             // Move it to the end of the list.
             $collection->add($name, $route);
         } else {
             // Remove the route if it does not match at all.
             $collection->remove($name);
         }
     }
     if (count($collection)) {
         return $collection;
     }
     // We do not throw a
     // \Symfony\Component\Routing\Exception\ResourceNotFoundException here
     // because we don't want to return a 404 status code, but rather a 406.
     throw new NotAcceptableHttpException(SafeMarkup::format('No route found for the specified formats @formats.', array('@formats' => implode(' ', $acceptable_mime_types))));
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:36,代码来源:AcceptHeaderMatcher.php

示例7: testOnAlterRoutes

 /**
  * Tests the onAlterRoutes method.
  *
  * @see \Drupal\views\EventSubscriber\RouteSubscriber::onAlterRoutes()
  */
 public function testOnAlterRoutes()
 {
     $collection = new RouteCollection();
     // The first route will be overridden later.
     $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\\Tests\\Core\\Controller\\TestController')));
     $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\\Tests\\Core\\Controller\\TestController'));
     $collection->add('test_route_2', $route_2);
     $route_event = new RouteBuildEvent($collection, 'views');
     list($view, $executable, $display_1, $display_2) = $this->setupMocks();
     // The page_1 display overrides an existing route, so the dynamicRoutes
     // should only call the second display.
     $display_1->expects($this->once())->method('collectRoutes')->willReturnCallback(function () use($collection) {
         $collection->add('views.test_id.page_1', new Route('test_route', ['_content' => 'Drupal\\views\\Routing\\ViewPageController']));
         return ['test_id.page_1' => 'views.test_id.page_1'];
     });
     $display_1->expects($this->once())->method('alterRoutes')->willReturn(['test_id.page_1' => 'test_route']);
     $display_2->expects($this->once())->method('collectRoutes')->willReturnCallback(function () use($collection) {
         $collection->add('views.test_id.page_2', new Route('test_route', ['_content' => 'Drupal\\views\\Routing\\ViewPageController']));
         return ['test_id.page_2' => 'views.test_id.page_2'];
     });
     $display_2->expects($this->once())->method('alterRoutes')->willReturn([]);
     // Ensure that even both the collectRoutes() and alterRoutes() methods
     // are called on the displays, we ensure that the route first defined by
     // views is dropped.
     $this->routeSubscriber->routes();
     $this->assertNull($this->routeSubscriber->onAlterRoutes($route_event));
     $this->state->expects($this->once())->method('set')->with('views.view_route_names', array('test_id.page_1' => 'test_route', 'test_id.page_2' => 'views.test_id.page_2'));
     $collection = $route_event->getRouteCollection();
     $this->assertEquals(['test_route', 'test_route_2', 'views.test_id.page_2'], array_keys($collection->all()));
     $this->routeSubscriber->routeRebuildFinished();
 }
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:36,代码来源:RouteSubscriberTest.php

示例8: load

 public function load($resource, $type = null)
 {
     $routes = new RouteCollection();
     list($prefix, $resource) = explode('.', $resource);
     $pluralResource = Inflector::pluralize($resource);
     $rootPath = '/' . $pluralResource . '/';
     $requirements = array();
     // GET collection request.
     $routeName = sprintf('%s_api_%s_index', $prefix, $resource);
     $defaults = array('_controller' => sprintf('%s.controller.%s:indexAction', $prefix, $resource));
     $route = new Route($rootPath, $defaults, $requirements, array(), '', array(), array('GET'));
     $routes->add($routeName, $route);
     // GET request.
     $routeName = sprintf('%s_api_%s_show', $prefix, $resource);
     $defaults = array('_controller' => sprintf('%s.controller.%s:showAction', $prefix, $resource));
     $route = new Route($rootPath . '{id}', $defaults, $requirements, array(), '', array(), array('GET'));
     $routes->add($routeName, $route);
     // POST request.
     $routeName = sprintf('%s_api_%s_create', $prefix, $resource);
     $defaults = array('_controller' => sprintf('%s.controller.%s:createAction', $prefix, $resource));
     $route = new Route($rootPath, $defaults, $requirements, array(), '', array(), array('POST'));
     $routes->add($routeName, $route);
     // PUT request.
     $routeName = sprintf('%s_api_%s_update', $prefix, $resource);
     $defaults = array('_controller' => sprintf('%s.controller.%s:updateAction', $prefix, $resource));
     $route = new Route($rootPath . '{id}', $defaults, $requirements, array(), '', array(), array('PUT', 'PATCH'));
     $routes->add($routeName, $route);
     // DELETE request.
     $routeName = sprintf('%s_api_%s_delete', $prefix, $resource);
     $defaults = array('_controller' => sprintf('%s.controller.%s:deleteAction', $prefix, $resource));
     $route = new Route($rootPath . '{id}', $defaults, $requirements, array(), '', array(), array('DELETE'));
     $routes->add($routeName, $route);
     return $routes;
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:34,代码来源:ApiLoader.php

示例9: format

 /**
  * Given an array of RAML\Resources, this function will add each Resource
  * into the Symfony Route Collection, and set the corresponding method.
  *
  * @param BasicRoute[Resource] $resources
  *  Associative array where the key is the method and full path, and the value contains
  *  the path, method type (GET/POST etc.) and then the Raml\Method object
  *
  * @return array
  */
 public function format(array $resources)
 {
     // Loop over the Resources
     foreach ($resources as $path => $resource) {
         // This is the path from the RAML, with or without a /.
         $path = $resource->getUri() . ($this->addTrailingSlash ? '/' : '');
         // This is the baseUri + path, the complete URL.
         $url = $resource->getBaseUrl() . $path;
         // Now remove the host away, so we have the FULL path to the resource.
         // baseUri may also contain path that has been omitted for brevity in the
         // RAML creation.
         $host = parse_url($url, PHP_URL_HOST);
         $fullPath = substr($url, strpos($url, $host) + strlen($host));
         // Now build our Route class.
         $route = new Route($fullPath);
         $route->setMethods($resource->getMethod()->getType());
         $route->setSchemes($resource->getProtocols());
         // Loop over each of the URI Parameters searching for validation patterns
         // or default values for parameters.
         foreach ($resource->getUriParameters() as $name => $param) {
             $route->setRequirement($name, $param->getValidationPattern());
             if ($default = $param->getDefault()) {
                 $route->setDefault($name, $default);
             }
         }
         $this->routes->add($resource->getType() . ' ' . $path, $route);
     }
     return $resources;
 }
开发者ID:TheKnarf,项目名称:php-raml-parser,代码行数:39,代码来源:SymfonyRouteFormatter.php

示例10: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection)
 {
     foreach ($this->contentTranslationManager->getSupportedEntityTypes() as $entity_type_id => $entity_type) {
         // Try to get the route from the current collection.
         $link_template = $entity_type->getLinkTemplate('canonical');
         if (strpos($link_template, '/') !== FALSE) {
             $base_path = '/' . $link_template;
         } else {
             if (!($entity_route = $collection->get("entity.{$entity_type_id}.canonical"))) {
                 continue;
             }
             $base_path = $entity_route->getPath();
         }
         // Inherit admin route status from edit route, if exists.
         $is_admin = FALSE;
         $route_name = "entity.{$entity_type_id}.edit_form";
         if ($edit_route = $collection->get($route_name)) {
             $is_admin = (bool) $edit_route->getOption('_admin_route');
         }
         $path = $base_path . '/translations';
         $route = new Route($path, array('_controller' => '\\Drupal\\content_translation\\Controller\\ContentTranslationController::overview', 'entity_type_id' => $entity_type_id), array('_entity_access' => $entity_type_id . '.view', '_access_content_translation_overview' => $entity_type_id), array('parameters' => array($entity_type_id => array('type' => 'entity:' . $entity_type_id)), '_admin_route' => $is_admin));
         $route_name = "entity.{$entity_type_id}.content_translation_overview";
         $collection->add($route_name, $route);
         $route = new Route($path . '/add/{source}/{target}', array('_controller' => '\\Drupal\\content_translation\\Controller\\ContentTranslationController::add', 'source' => NULL, 'target' => NULL, '_title' => 'Add', 'entity_type_id' => $entity_type_id), array('_entity_access' => $entity_type_id . '.view', '_access_content_translation_manage' => 'create'), array('parameters' => array('source' => array('type' => 'language'), 'target' => array('type' => 'language'), $entity_type_id => array('type' => 'entity:' . $entity_type_id)), '_admin_route' => $is_admin));
         $collection->add("entity.{$entity_type_id}.content_translation_add", $route);
         $route = new Route($path . '/edit/{language}', array('_controller' => '\\Drupal\\content_translation\\Controller\\ContentTranslationController::edit', 'language' => NULL, '_title' => 'Edit', 'entity_type_id' => $entity_type_id), array('_access_content_translation_manage' => 'update'), array('parameters' => array('language' => array('type' => 'language'), $entity_type_id => array('type' => 'entity:' . $entity_type_id)), '_admin_route' => $is_admin));
         $collection->add("entity.{$entity_type_id}.content_translation_edit", $route);
         $route = new Route($path . '/delete/{language}', array('_entity_form' => $entity_type_id . '.content_translation_deletion', 'language' => NULL, '_title' => 'Delete', 'entity_type_id' => $entity_type_id), array('_access_content_translation_manage' => 'delete'), array('parameters' => array('language' => array('type' => 'language'), $entity_type_id => array('type' => 'entity:' . $entity_type_id)), '_admin_route' => $is_admin));
         $collection->add("entity.{$entity_type_id}.content_translation_delete", $route);
     }
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:34,代码来源:ContentTranslationRouteSubscriber.php

示例11: testDumpWithSchemeRequirement

 public function testDumpWithSchemeRequirement()
 {
     $this->routeCollection->add('Test1', new Route('/testing', array(), array(), array(), '', array('ftp', 'https')));
     $this->routeCollection->add('Test2', new Route('/testing_bc', array(), array('_scheme' => 'https')));
     // BC
     file_put_contents($this->testTmpFilepath, $this->generatorDumper->dump(array('class' => 'SchemeUrlGenerator')));
     include $this->testTmpFilepath;
     $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php'));
     $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true);
     $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true);
     $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false);
     $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false);
     $this->assertEquals($absoluteUrl, 'ftp://localhost/app.php/testing');
     $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc');
     $this->assertEquals($relativeUrl, 'ftp://localhost/app.php/testing');
     $this->assertEquals($relativeUrlBC, 'https://localhost/app.php/testing_bc');
     $projectUrlGenerator = new \SchemeUrlGenerator(new RequestContext('/app.php', 'GET', 'localhost', 'https'));
     $absoluteUrl = $projectUrlGenerator->generate('Test1', array(), true);
     $absoluteUrlBC = $projectUrlGenerator->generate('Test2', array(), true);
     $relativeUrl = $projectUrlGenerator->generate('Test1', array(), false);
     $relativeUrlBC = $projectUrlGenerator->generate('Test2', array(), false);
     $this->assertEquals($absoluteUrl, 'https://localhost/app.php/testing');
     $this->assertEquals($absoluteUrlBC, 'https://localhost/app.php/testing_bc');
     $this->assertEquals($relativeUrl, '/app.php/testing');
     $this->assertEquals($relativeUrlBC, '/app.php/testing_bc');
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:26,代码来源:PhpGeneratorDumperTest.php

示例12: loadRoutes

 protected function loadRoutes()
 {
     $this->routes->add('dynamic_route_' . ($this->routes->count() + 1), new Route('pup/image/upload/service', $defaults = array('_controller' => 'pupBundle:Process:upload'), $requirements = array()));
     //add another
     //or execute a db query and add multiple routes
     //etc.
 }
开发者ID:ryzhkin,项目名称:pupBundle,代码行数:7,代码来源:DynamicRouterListener.php

示例13: load

 /**
  * @todo clean this
  */
 public function load($resource, $type = null)
 {
     if (true === $this->loaded) {
         throw new \RuntimeException('Do not add this loader twice');
     }
     $routes = new RouteCollection();
     $frontPageConfig = $this->container->get('system')->get('system.frontpage', 'blog');
     $frontPageProvider = $this->container->get('drafterbit_system.frontpage_provider');
     $reservedBaseUrl = [$this->container->getParameter('admin')];
     foreach ($frontPageProvider->all() as $prefix => $frontPage) {
         $frontRoutes = $frontPage->getRoutes();
         if ($prefix !== $frontPageConfig) {
             $frontRoutes->addPrefix($frontPage->getRoutePrefix());
             $reservedBaseUrl[] = $prefix;
         }
         $routes->addCollection($frontRoutes);
     }
     $defaults = array('_controller' => 'DrafterbitPageBundle:Frontend:view');
     // check if configured frontpage is not an app
     if (!array_key_exists($frontPageConfig, $frontPageProvider->all())) {
         // its page
         $defaults['slug'] = $frontPageConfig;
         $routes->add('_home', new Route('/', $defaults));
     }
     $reservedBaseUrl = implode('|', $reservedBaseUrl);
     // @link http://stackoverflow.com/questions/25496704/regex-match-slug-except-particular-start-words
     // @prototype  'slug' => "^(?!(?:backend|blog)(?:/|$)).*$"
     $requirements = array('slug' => "^(?!(?:%admin%|" . $reservedBaseUrl . "|)(?:/|\$)).*\$");
     $route2 = new Route('/{slug}', $defaults, $requirements);
     $routes->add('misc', $route2);
     return $routes;
 }
开发者ID:hikmahtiar6,项目名称:drafterbit,代码行数:35,代码来源:FrontendLoader.php

示例14: testDump

 public function testDump()
 {
     $collection = new RouteCollection();
     // defaults and requirements
     $collection->add('foo', new Route('/foo/{bar}', array('def' => 'test'), array('bar' => 'baz|symfony')));
     // method requirement
     $collection->add('bar', new Route('/bar/{foo}', array(), array('_method' => 'GET|head')));
     // method requirement (again)
     $collection->add('baragain', new Route('/baragain/{foo}', array(), array('_method' => 'get|post')));
     // simple
     $collection->add('baz', new Route('/test/baz'));
     // simple with extension
     $collection->add('baz2', new Route('/test/baz.html'));
     // trailing slash
     $collection->add('baz3', new Route('/test/baz3/'));
     // trailing slash with variable
     $collection->add('baz4', new Route('/test/{foo}/'));
     // trailing slash and safe method
     $collection->add('baz5', new Route('/test/{foo}/', array(), array('_method' => 'get')));
     // trailing slash and unsafe method
     $collection->add('baz5unsafe', new Route('/testunsafe/{foo}/', array(), array('_method' => 'post')));
     // complex
     $collection->add('baz6', new Route('/test/baz', array('foo' => 'bar baz')));
     $dumper = new ApacheMatcherDumper($collection);
     $this->assertStringEqualsFile(self::$fixturesPath . '/dumper/url_matcher1.apache', $dumper->dump(), '->dump() dumps basic routes to the correct apache format.');
 }
开发者ID:netconstructor,项目名称:symfony,代码行数:26,代码来源:ApacheMatcherDumperTest.php

示例15: route

 /**
  * Adds a Route to the Route Collection
  * @param type $name
  * @param type $path
  * @param array $controlerAction
  * @param array $defaults
  * @return \Blend\Component\Routing\Route
  */
 public function route($name, $path, array $controlerAction, array $defaults = [])
 {
     $params = array_merge($defaults, [RouteAttribute::CONTROLLER => $controlerAction]);
     $route = new Route($path, $params);
     $this->routes->add($name, $route);
     return $route;
 }
开发者ID:blendsdk,项目名称:blendengine,代码行数:15,代码来源:RouteBuilder.php


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