/** * {@inheritdoc} */ protected function describeRoute(Route $route, array $options = array()) { $requirements = $route->getRequirements(); unset($requirements['_scheme'], $requirements['_method']); // fixme: values were originally written as raw $description = array( '<comment>Path</comment> '.$route->getPath(), '<comment>Host</comment> '.('' !== $route->getHost() ? $route->getHost() : 'ANY'), '<comment>Scheme</comment> '.($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'), '<comment>Method</comment> '.($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'), '<comment>Class</comment> '.get_class($route), '<comment>Defaults</comment> '.$this->formatRouterConfig($route->getDefaults()), '<comment>Requirements</comment> '.$this->formatRouterConfig($requirements) ?: 'NO CUSTOM', '<comment>Options</comment> '.$this->formatRouterConfig($route->getOptions()), '<comment>Path-Regex</comment> '.$route->compile()->getRegex(), ); if (isset($options['name'])) { array_unshift($description, '<comment>Name</comment> '.$options['name']); array_unshift($description, $this->formatSection('router', sprintf('Route "%s"', $options['name']))); } if (null !== $route->compile()->getHostRegex()) { $description[] = '<comment>Host-Regex</comment> '.$route->compile()->getHostRegex(); } $this->writeText(implode("\n", $description)."\n", $options); }
/** * {@inheritdoc} */ protected function describeRoute(Route $route, array $options = array()) { $requirements = $route->getRequirements(); unset($requirements['_scheme'], $requirements['_method']); $output = '- Path: ' . $route->getPath() . "\n" . '- Host: ' . ('' !== $route->getHost() ? $route->getHost() : 'ANY') . "\n" . '- Scheme: ' . ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY') . "\n" . '- Method: ' . ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY') . "\n" . '- Class: ' . get_class($route) . "\n" . '- Defaults: ' . $this->formatRouterConfig($route->getDefaults()) . "\n" . '- Requirements: ' . $this->formatRouterConfig($requirements) ?: 'NONE' . "\n" . '- Options: ' . $this->formatRouterConfig($route->getOptions()) . "\n" . '- Path-Regex: ' . $route->compile()->getRegex(); $this->write(isset($options['name']) ? $options['name'] . "\n" . str_repeat('-', strlen($options['name'])) . "\n\n" . $output : $output); $this->write("\n"); }
/** * {@inheritdoc} */ protected function describeRoute(Route $route, array $options = array()) { $tableHeaders = array('Property', 'Value'); $tableRows = array(array('Route Name', $options['name']), array('Path', $route->getPath()), array('Path Regex', $route->compile()->getRegex()), array('Host', '' !== $route->getHost() ? $route->getHost() : 'ANY'), array('Host Regex', '' !== $route->getHost() ? $route->compile()->getHostRegex() : ''), array('Scheme', $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'), array('Method', $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'), array('Requirements', $route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM'), array('Class', get_class($route)), array('Defaults', $this->formatRouterConfig($route->getDefaults())), array('Options', $this->formatRouterConfig($route->getOptions()))); $table = new Table($this->getOutput()); $table->setHeaders($tableHeaders)->setRows($tableRows); $table->render(); }
/** * {@inheritdoc} */ public function resolve(Route $route, RouteCollectionAccessor $routes) { if (!in_array('OPTIONS', $route->getMethods(), true)) { return; } $entryPath = $this->getEntryPath($route); if (!$entryPath) { return; } $nameFromController = $this->getNameFromController($route); if (!$nameFromController) { return; } $nameFromPath = str_replace('/', '', $entryPath); if ($nameFromPath === $nameFromController) { return; } if (false !== ($pos = strrpos($entryPath, '/'))) { $pluralName = substr($entryPath, $pos + 1); $singleName = substr($nameFromController, $pos - substr_count($entryPath, '/') + 1); } else { $pluralName = $entryPath; $singleName = $nameFromController; } if ($pluralName === $singleName || $pluralName !== Inflector::pluralize($singleName)) { return; } $singlePath = str_replace('/' . $pluralName, '/' . $singleName, $route->getPath()); $singleRoute = $routes->cloneRoute($route); $singleRoute->setPath($singlePath); $singleRoute->setOption('old_options', true); $pluralRouteName = $routes->getName($route); $routes->insert($routes->generateRouteName($pluralRouteName), $singleRoute, $pluralRouteName); }
/** * @param Route $route * @return Action */ public function getActionForRoute(Route $route) { foreach ($this->actions as $action) { // TODO this should be improved to be more precise (route prefix) $sameSchema = strpos($route->getPath(), $action->getUrlSchema()) >= 0; $sameMethods = $action->getMethods() == $route->getMethods(); if ($sameMethods && $sameSchema) { return $action; } } }
private function isAccessedAnonymously($routeName, Route $route) { if (!in_array('GET', $route->getMethods()) && $route->getMethods()) { return false; // GET method must be allowed } if (strpos($routeName, '_') === 0) { return false; // internal|private routes } $compiled = $route->compile(); $params = []; foreach ($compiled->getPathVariables() as $key) { $params[$key] = 'any'; // we do not care about it } foreach ($route->getRequirements() as $key => $regex) { $params[$key] = 'any'; // we do not care about it } foreach ($route->getDefaults() as $key => $default) { $params[$key] = $default; } if (!array_key_exists('_controller', $params)) { return false; // route is dynamic, should not be index by robots } $uri = $this->get('router')->generate($routeName, $params); // mock the request $request = Request::create('http://mock.com' . $uri); $request->setSession(new Session(new MockFileSessionStorage())); // run the request through security firewall $event = new GetResponseEvent($this->getApplication()->getKernel(), $request, HttpKernelInterface::MASTER_REQUEST); try { $this->get('security.firewall')->onKernelRequest($event); } catch (AccessDeniedException $e) { return false; // access is denied } return !$event->getResponse() instanceof RedirectResponse; }
/** * get collection and id from route * * @param Route $route route to look at * @param string $value value of reference as URI * * @return array */ private function getDataFromRoute(Route $route, $value) { if ($route->getRequirement('id') !== null && $route->getMethods() === ['GET'] && preg_match($route->compile()->getRegex(), $value, $matches)) { $id = $matches['id']; list($routeService) = explode(':', $route->getDefault('_controller')); list($core, $bundle, , $name) = explode('.', $routeService); $serviceName = implode('.', [$core, $bundle, 'rest', $name]); $collection = array_search($serviceName, $this->mapping); return [$collection, $id]; } return [null, null]; }
/** * @param Route $route the route we're tried to add * @param int $name the name given to the route we tried to add * @param Route $routeWithSameName the existing route with the same name */ public function __construct(Route $route, $name, Route $routeWithSameName) { // host to string if (!($host = $route->getHost())) { $host = 'any'; } if (!($hostRouteWithSameName = $routeWithSameName->getHost())) { $hostRouteWithSameName = 'any'; } // methods to string if ($methods = $route->getMethods()) { $methods = implode($methods, ', '); } else { $methods = 'any'; } if ($methodsRouteWithSameName = $routeWithSameName->getMethods()) { $methodsRouteWithSameName = implode($methodsRouteWithSameName, ', '); } else { $methodsRouteWithSameName = 'any'; } $message = sprintf("Cannot add the route [path: %s, host: %s, methods: %s] with the name '%s'\n as it is already used by the route [path: %s, host: %s, methods: %s].", $route->getPath(), $host, $methods, $name, $routeWithSameName->getPath(), $hostRouteWithSameName, $methodsRouteWithSameName); parent::__construct($message); }
/** * @param Route $route * * @return array */ protected function getRouteData(Route $route) { return array('path' => $route->getPath(), 'pathRegex' => $route->compile()->getRegex(), 'host' => '' !== $route->getHost() ? $route->getHost() : 'ANY', 'hostRegex' => '' !== $route->getHost() ? $route->compile()->getHostRegex() : '', 'scheme' => $route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY', 'method' => $route->getMethods() ? implode('|', $route->getMethods()) : 'ANY', 'class' => get_class($route), 'defaults' => $route->getDefaults(), 'requirements' => $route->getRequirements() ?: 'NO CUSTOM', 'options' => $route->getOptions()); }
/** * Returns methods allowed for a route. * * @param Route $route * The route * * @return array The methods */ private function getRouteMethods(Route $route) { $methods = $route->getMethods(); // GET and HEAD are equivalent if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { $methods[] = 'HEAD'; } return $methods; }
/** * Generates a route name based on details of this route. * * @return string */ private function generateRouteName(Route $route) { $methods = implode('_', $route->getMethods()) . '_'; $routeName = $methods . $route->getPath(); $routeName = str_replace(array('/', ':', '|', '-'), '_', $routeName); $routeName = preg_replace('/[^a-z0-9A-Z_.]+/', '', $routeName); // Collapse consecutive underscores down into a single underscore. $routeName = preg_replace('/_+/', '_', $routeName); return $routeName; }
public function addPageRoute($admin_name, $action_name, \Symfony\Component\Routing\Route $route, \ReflectionMethod $m, \Symforce\AdminBundle\Compiler\Annotation\Route $annot) { if (null === $this->route_page_collection) { throw new \Exception('should call getRouteCollection first'); } $_path = array('s' => $route->getSchemes(), 'h' => $route->getHost(), 'p' => $route->getPath(), 'm' => $route->getMethods()); $path = json_encode($_path); $admin_action = $admin_name . ':' . $action_name; if (isset($this->page_path_map[$path])) { $_admin_action = $this->page_path_map[$path]; throw new \Exception(sprintf("web page path:`%s` duplicate(%s,%s)", $route->getPath(), $this->page_actions_map[$admin_action], $this->page_actions_map[$_admin_action])); } $this->page_path_map[$path] = $admin_action; if (isset($this->page_route_map[$annot->name])) { $_admin_action = $this->page_route_map[$annot->name]; throw new \Exception(sprintf("web page route name:`%s` duplicate method(%s,%s), action(%s,%s)", $annot->name, $this->page_actions_map[$admin_action], $this->page_actions_map[$_admin_action], $admin_action, $_admin_action)); } $this->page_route_map[$annot->name] = $admin_action; $this->route_page_collection->add($annot->name, $route); $this->page_dispatch_map[$admin_action] = array('name' => $annot->name, 'path' => $route->getPath(), 'requirements' => $route->getRequirements(), 'entity' => $annot->entity, 'template' => $annot->template, 'generator' => null, 'dispatcher' => null); }
/** * @param Route $route * @return string */ protected function getRouteMethods(Route $route) : string { return strtolower(implode(',', $route->getMethods()) ?: 'get'); }
/** * Compiles a single Route to PHP code used to match it against the path info. * * @param Route $route A Route instance * @param string $name The name of the Route * @param bool $supportsRedirections Whether redirections are supported by the base class * @param string|null $parentPrefix The prefix of the parent collection used to optimize the code * * @return string PHP code * * @throws \LogicException */ private function compileRoute(Route $route, $name, $supportsRedirections, $parentPrefix = null) { $code = ''; $compiledRoute = $route->compile(); $conditions = array(); $hasTrailingSlash = false; $matches = false; $hostMatches = false; $methods = $route->getMethods(); // GET and HEAD are equivalent if (in_array('GET', $methods) && !in_array('HEAD', $methods)) { $methods[] = 'HEAD'; } $supportsTrailingSlash = $supportsRedirections && (!$methods || in_array('HEAD', $methods)); if (!count($compiledRoute->getPathVariables()) && false !== preg_match('#^(.)\\^(?P<url>.*?)\\$\\1#', $compiledRoute->getRegex(), $m)) { if ($supportsTrailingSlash && substr($m['url'], -1) === '/') { $conditions[] = sprintf("rtrim(\$pathinfo, '/') === %s", var_export(rtrim(str_replace('\\', '', $m['url']), '/'), true)); $hasTrailingSlash = true; } else { $conditions[] = sprintf("\$pathinfo === %s", var_export(str_replace('\\', '', $m['url']), true)); } } else { if ($compiledRoute->getStaticPrefix() && $compiledRoute->getStaticPrefix() !== $parentPrefix) { $conditions[] = sprintf("0 === strpos(\$pathinfo, %s)", var_export($compiledRoute->getStaticPrefix(), true)); } $regex = $compiledRoute->getRegex(); if ($supportsTrailingSlash && ($pos = strpos($regex, '/$'))) { $regex = substr($regex, 0, $pos) . '/?$' . substr($regex, $pos + 2); $hasTrailingSlash = true; } $conditions[] = sprintf("preg_match(%s, \$pathinfo, \$matches)", var_export($regex, true)); $matches = true; } if ($compiledRoute->getHostVariables()) { $hostMatches = true; } if ($route->getCondition()) { $conditions[] = $this->getExpressionLanguage()->compile($route->getCondition(), array('context', 'request')); } $conditions = implode(' && ', $conditions); $code .= <<<EOF // {$name} if ({$conditions}) { EOF; $gotoname = 'not_' . preg_replace('/[^A-Za-z0-9_]/', '', $name); if ($methods) { if (1 === count($methods)) { $code .= <<<EOF if (\$this->context->getMethod() != '{$methods['0']}') { \$allow[] = '{$methods['0']}'; goto {$gotoname}; } EOF; } else { $methods = implode("', '", $methods); $code .= <<<EOF if (!in_array(\$this->context->getMethod(), array('{$methods}'))) { \$allow = array_merge(\$allow, array('{$methods}')); goto {$gotoname}; } EOF; } } if ($hasTrailingSlash) { $code .= <<<EOF if (substr(\$pathinfo, -1) !== '/') { return \$this->redirect(\$pathinfo.'/', '{$name}'); } EOF; } if ($schemes = $route->getSchemes()) { if (!$supportsRedirections) { throw new \LogicException('The "schemes" requirement is only supported for URL matchers that implement RedirectableUrlMatcherInterface.'); } $schemes = str_replace("\n", '', var_export(array_flip($schemes), true)); $code .= <<<EOF \$requiredSchemes = {$schemes}; if (!isset(\$requiredSchemes[\$this->context->getScheme()])) { return \$this->redirect(\$pathinfo, '{$name}', key(\$requiredSchemes)); } EOF; } // optimize parameters array if ($matches || $hostMatches) { $vars = array(); if ($hostMatches) { $vars[] = '$hostMatches'; } if ($matches) { $vars[] = '$matches'; } $vars[] = "array('_route' => '{$name}')"; $code .= sprintf(" return \$this->mergeDefaults(array_replace(%s), %s);\n", implode(', ', $vars), str_replace("\n", '', var_export($route->getDefaults(), true))); } elseif ($route->getDefaults()) { $code .= sprintf(" return %s;\n", str_replace("\n", '', var_export(array_replace($route->getDefaults(), array('_route' => $name)), true))); } else { $code .= sprintf(" return array('_route' => '%s');\n", $name); } $code .= " }\n"; if ($methods) { $code .= " {$gotoname}:\n"; } return $code; }
/** * @group legacy */ public function testLegacyMethodRequirement() { $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); $route = new Route('/'); $route->setRequirement('_method', 'GET|POST'); $this->assertEquals('GET|POST', $route->getRequirement('_method')); $this->assertEquals(array('GET', 'POST'), $route->getMethods()); $route->setMethods(array('gEt')); $this->assertEquals('GET', $route->getRequirement('_method')); $route->setMethods(array()); $this->assertNull($route->getRequirement('_method')); }
/** * @param Route $route * @return bool */ private function expectsInput(Route $route) { $methods = $route->getMethods(); if (in_array('POST', $methods) || in_array('PUT', $methods) || in_array('PATCH', $methods)) { return true; } return false; }
/** * Returns a new ApiDoc instance with more data. * * @param ApiDoc $annotation * @param Route $route * @param \ReflectionMethod $method * @param DunglasResource $dunglasResource * @return ApiDoc */ protected function extractData(ApiDoc $annotation, Route $route, \ReflectionMethod $method, DunglasResource $dunglasResource = null) { //remove methode OPTIONS $methods = $route->getMethods(); $optionIndex = array_search('OPTIONS', $methods); if ($optionIndex !== false) { unset($methods[$optionIndex]); $route->setMethods($methods); } if (in_array(strtolower($this->versionApi), $this->nelmioDocStandardVersion)) { return parent::extractData($annotation, $route, $method); } // create a new annotation $annotation = clone $annotation; $annotation->addTag($this->versionApi, '#ff0000'); // doc $annotation->setDocumentation($this->commentExtractor->getDocCommentText($method)); // parse annotations $this->parseAnnotations($annotation, $route, $method); $resource = $route->getDefault('_resource'); // route $annotation->setRoute($route); $entityClassInput = $entityClassOutput = null; //section $annotation->setSection($resource); $annotation = $this->addFilters($resource, $annotation, $dunglasResource, $route); if (in_array($annotation->getMethod(), ['POST', 'PUT'])) { $formName = 'api_v2_' . strtolower($dunglasResource->getShortName()); if ($hasFormtype = $this->registry->hasType($formName)) { $type = $this->registry->getType($formName); if ($type instanceof ResolvedFormTypeInterface) { $entityClassInput = get_class($type->getInnerType()); $dunglasResource->initValidationGroups($type->getInnerType()->validationGrp); } } } if ('GET' === $annotation->getMethod()) { $entityClassInput = null; } if (is_null($annotation->getOutput()) || is_array($annotation->getOutput())) { $entityClassOutput = $this->transformerHelper->getEntityClass($resource); } else { $entityClassOutput = $annotation->getOutput(); } if ('DELETE' === $annotation->getMethod()) { $entityClassInput = $entityClassOutput = null; } // input (populates 'parameters' for the formatters) if (null !== ($input = $entityClassInput)) { $normalizedInput = $this->normalizeClassParameter($input, $dunglasResource); $parameters = $this->getParametersParser($normalizedInput, $resource, $dunglasResource, $annotation); if ($hasFormtype && in_array($annotation->getMethod(), ['POST', 'PUT'])) { $parameters = $this->processFormParams($formName, $parameters, $dunglasResource); } $parameters = $this->clearClasses($parameters); $parameters = $this->generateHumanReadableTypes($parameters); if ($annotation->getMethod() === 'POST') { if (isset($parameters['id'])) { unset($parameters['id']); } } if (in_array($annotation->getMethod(), ['PUT', 'PATCH'])) { // All parameters are optional with PUT (update) array_walk($parameters, function ($val, $key) use(&$parameters) { $parameters[$key]['required'] = false; }); } $annotation->setParameters($parameters); } // output (populates 'response' for the formatters) if (null !== ($output = $entityClassOutput)) { $normalizedOutput = $this->normalizeClassParameter($output, $dunglasResource); if (!is_array($annotation->getOutput())) { $response = $this->getParametersParser($normalizedOutput, $resource, $dunglasResource, $annotation, 'Output'); foreach ($response as $key => $params) { if (isset($response[$key]['children'])) { unset($response[$key]['children']); } if ($response[$key]['actualType'] === 'model') { $response[$key]['dataType'] = 'Integer | ' . $response[$key]['dataType']; } } $response = $this->clearClasses($response); $response = $this->generateHumanReadableTypes($response); } else { $response = $this->normalizeArrayParameter($annotation->getOutput()); } $annotation->setResponse($response); $annotation->setResponseForStatusCode($response, $normalizedOutput, 200); } if (count($annotation->getResponseMap()) > 0) { foreach ($annotation->getResponseMap() as $code => $modelName) { if (is_array($modelName)) { continue; } if ('200' === (string) $code && isset($modelName['type']) && isset($modelName['model'])) { /* * Model was already parsed as the default `output` for this ApiDoc. */ continue; } $normalizedModel = $this->normalizeClassParameter($modelName, $dunglasResource); $parameters = array(); $supportedParsers = array(); foreach ($this->getParsers($normalizedModel) as $parser) { if ($parser->supports($normalizedModel)) { $supportedParsers[] = $parser; $parameters = $this->mergeParameters($parameters, $parser->parse($normalizedModel)); } } foreach ($supportedParsers as $parser) { if ($parser instanceof PostParserInterface) { $mp = $parser->postParse($normalizedModel, $parameters); $parameters = $this->mergeParameters($parameters, $mp); } } $parameters = $this->clearClasses($parameters); $parameters = $this->generateHumanReadableTypes($parameters); $annotation->setResponseForStatusCode($parameters, $normalizedModel, $code); } } return $annotation; }
/** * getUniqueKeyForRoute * * @param Route $route * * @return string */ protected function getUniqueKeyForRoute(Route $route) { return sprintf('%s-%s', implode('', $route->getMethods()), $route->getPath()); }
/** * 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()); }
/** * Get the route information for a given route. * * @param string $name * @param \Symfony\Component\Routing\Route $route * @return array */ protected function getRouteInformation($name, Route $route) { $uri = head($route->getMethods()) . ' ' . $route->getPath(); $action = $route->getAction() ?: 'Closure'; return array('host' => $route->getHost(), 'uri' => $uri, 'name' => $this->getRouteName($name), 'action' => $action, 'before' => $this->getBeforeFilters($route), 'after' => $this->getAfterFilters($route)); }
public function testMethod() { $route = new Route('/'); $this->assertEquals(array(), $route->getMethods(), 'methods is initialized with array()'); $route->setMethods('gEt'); $this->assertEquals(array('GET'), $route->getMethods(), '->setMethods() accepts a single method string and uppercases it'); $route->setMethods(array('gEt', 'PosT')); $this->assertEquals(array('GET', 'POST'), $route->getMethods(), '->setMethods() accepts an array of methods and uppercases them'); }
/** * Returns a descriptive string for a Route. * * @param Route $route A BackBee Route instance * @param string $routeName The Route name (the associated index in a RouteCollection) * @param bool $showControllers If true, display the Controller information * * @return string The text description of a Route */ private function describeRoute(Route $route, $routeName, $showControllers) { $description = array('<comment>Name</comment> ' . $routeName, '<comment>Path</comment> ' . $route->getPath(), '<comment>Path Regex</comment> ' . $route->compile()->getRegex(), '<comment>Host</comment> ' . ('' !== $route->getHost() ? $route->getHost() : 'ANY'), '<comment>Host Regex</comment> ' . ('' !== $route->getHost() ? $route->compile()->getHostRegex() : ''), '<comment>Scheme</comment> ' . ($route->getSchemes() ? implode('|', $route->getSchemes()) : 'ANY'), '<comment>Method</comment> ' . ($route->getMethods() ? implode('|', $route->getMethods()) : 'ANY'), '<comment>Class</comment> ' . get_class($route), '<comment>Defaults</comment> ' . $this->formatRouterConfig($route->getDefaults()), '<comment>Requirements</comment> ' . ($route->getRequirements() ? $this->formatRouterConfig($route->getRequirements()) : 'NO CUSTOM'), '<comment>Options</comment> ' . $this->formatRouterConfig($route->getOptions())); if (isset($showControllers)) { array_unshift($description, '<comment>Controller</comment> ' . $this->convertController($route)); } return implode("\n", $description) . "\n"; }
/** * Merges the methods from $restRoute into the _method default of $optionsRoute. * * @param Route $restRoute * @param Route $optionsRoute * * @return Route $optionsRoute with the methods from $restRoute in the _methods default */ public function mergeMethodsDefault(Route $optionsRoute, Route $restRoute) { $mergedRoute = clone $optionsRoute; $mergedRoute->setDefault('allowedMethods', implode(',', array_unique(array_merge(explode(',', $optionsRoute->getDefault('allowedMethods')), $restRoute->getMethods())))); return $mergedRoute; }
/** * Sets the HTTP methods (e.g. 'POST') this route is restricted to. * So an empty array means that any method is allowed. * * This method implements a fluent interface. * * @param string|array $methods The method or an array of methods * * @return Route The current Route instance */ public function setMethods($methods) { parent::setMethods($methods); $this->methods = parent::getMethods(); return $this; }
public function testMethodIsBC() { $route = new Route('/'); $route->setRequirement('_method', 'GET|POST'); $this->assertEquals('GET|POST', $route->getRequirement('_method')); $this->assertEquals(array('GET', 'POST'), $route->getMethods()); $route->setMethods(array('gEt')); $this->assertEquals('GET', $route->getRequirement('_method')); $route->setMethods(array()); $this->assertNull($route->getRequirement('_method')); }
/** * {@inheritdoc} */ public function applies(Route $route) { return !empty($route->getMethods()); }