/** * */ public function compile() { $generators = static::$resources_map; if ($this->except) { $generators = array_diff_key($generators, array_fill_keys($this->except, true)); } elseif ($this->only) { $generators = array_intersect_key($generators, array_fill_keys($this->only, true)); } if (is_array($this->path_names)) { $this->path_names += static::$resource_names; } else { $this->path_names = static::$resource_names; } $routes = array(); foreach ($generators as $action => $parts) { $path = $parts['url']; if (strpos($path, ':action') !== false) { $path = str_replace(':action', $this->path_names[$action], $path); } $r = new Route('/' . $this->resource . $path, $this->controller . '#' . $action); $r->methods(array($parts['verb'])); $single = isset($this->name[0]) ? $this->name[0] : Inflector::singularize($this->resource); $plural = isset($this->name[1]) ? $this->name[1] : Inflector::pluralize($this->resource); $name = str_replace('%s', $single, $parts['name']); $name = str_replace('%p', $plural, $name); $r->name($name); if ($this->constraints) { $r->constraints($this->constraints); } if ($this->namespace) { $r->namespaced($this->namespace); } $routes[] = $r->compile(); } return $routes; }
public function testUnderscoreToLowerCamel() { foreach (self::$underscores_to_lower_camel as $underscored => $lower_camel) { $this->assertEquals($lower_camel, Inflector::camelize($underscored, false)); } }