Skip to content

Commit

Permalink
[Routing] moved protected to private
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 23, 2011
1 parent 9595963 commit b585752
Show file tree
Hide file tree
Showing 21 changed files with 88 additions and 87 deletions.
10 changes: 5 additions & 5 deletions src/Symfony/Component/Routing/Annotation/Route.php
Expand Up @@ -18,11 +18,11 @@
*/
class Route
{
protected $pattern;
protected $name;
protected $requirements;
protected $options;
protected $defaults;
private $pattern;
private $name;
private $requirements;
private $options;
private $defaults;

/**
* Constructor.
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Annotation/Routes.php
Expand Up @@ -18,7 +18,7 @@
*/
class Routes
{
protected $routes;
private $routes;

/**
* Constructor.
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Routing/CompiledRoute.php
Expand Up @@ -18,11 +18,11 @@
*/
class CompiledRoute
{
protected $route;
protected $variables;
protected $tokens;
protected $staticPrefix;
protected $regex;
private $route;
private $variables;
private $tokens;
private $staticPrefix;
private $regex;

/**
* Constructor.
Expand Down
Expand Up @@ -21,7 +21,7 @@
*/
abstract class GeneratorDumper implements GeneratorDumperInterface
{
protected $routes;
private $routes;

/**
* Constructor.
Expand All @@ -32,4 +32,9 @@ public function __construct(RouteCollection $routes)
{
$this->routes = $routes;
}

public function getRoutes()
{
return $this->routes;
}
}
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\Routing\Generator\Dumper;

use Symfony\Component\Routing\RouteCollection;

/**
* GeneratorDumperInterface is the interface that all generator dumper classes must implement.
*
Expand All @@ -31,4 +33,11 @@ interface GeneratorDumperInterface
* @return string A PHP class representing the generator class
*/
function dump(array $options = array());

/**
* Gets the routes to dump.
*
* @return RouteCollection A RouteCollection instance
*/
function getRoutes();
}
Expand Up @@ -47,10 +47,10 @@ public function dump(array $options = array())
;
}

protected function addGenerator()
private function addGenerator()
{
$methods = array();
foreach ($this->routes->all() as $name => $route) {
foreach ($this->getRoutes()->all() as $name => $route) {
$compiledRoute = $route->compile();

$variables = str_replace("\n", '', var_export($compiledRoute->getVariables(), true));
Expand All @@ -64,7 +64,7 @@ protected function addGenerator()
$escapedName = str_replace('.', '__', $name);

$methods[] = <<<EOF
protected function get{$escapedName}RouteInfo()
private function get{$escapedName}RouteInfo()
{
\$defaults = \$this->defaults;
$defaultsMerge
Expand Down Expand Up @@ -96,10 +96,10 @@ public function generate(\$name, array \$parameters, \$absolute = false)
EOF;
}

protected function startClass($class, $baseClass)
private function startClass($class, $baseClass)
{
$routes = array();
foreach ($this->routes->all() as $name => $route) {
foreach ($this->getRoutes()->all() as $name => $route) {
$routes[] = " '$name' => true,";
}
$routes = implode("\n", $routes);
Expand All @@ -115,15 +115,15 @@ protected function startClass($class, $baseClass)
*/
class $class extends $baseClass
{
static protected \$declaredRouteNames = array(
static private \$declaredRouteNames = array(
$routes
);
EOF;
}

protected function addConstructor()
private function addConstructor()
{
return <<<EOF
/**
Expand All @@ -138,7 +138,7 @@ public function __construct(array \$context = array(), array \$defaults = array(
EOF;
}

protected function endClass()
private function endClass()
{
return <<<EOF
}
Expand Down
5 changes: 3 additions & 2 deletions src/Symfony/Component/Routing/Generator/UrlGenerator.php
Expand Up @@ -21,10 +21,11 @@
*/
class UrlGenerator implements UrlGeneratorInterface
{
protected $routes;
protected $defaults;
protected $context;
protected $cache;

private $routes;
private $cache;

/**
* Constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php
Expand Up @@ -24,7 +24,7 @@
*/
class AnnotationFileLoader extends FileLoader
{
protected $loader;
private $loader;

/**
* Constructor.
Expand Down Expand Up @@ -86,7 +86,7 @@ public function supports($resource, $type = null)
*
* @return string|false Full class name if found, false otherwise
*/
protected function findClass($file)
private function findClass($file)
{
$class = false;
$namespace = false;
Expand Down
Expand Up @@ -62,7 +62,7 @@ public function supports($resource, $type = null)
*
* @return array An array of paths matching the glob pattern
*/
protected function getAbsolutePaths($glob)
private function getAbsolutePaths($glob)
{
$dirs = array();
foreach ($this->paths as $path) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Loader/XmlFileLoader.php
Expand Up @@ -167,7 +167,7 @@ protected function validate(\DOMDocument $dom)
*
* @return array An array of libxml error strings
*/
protected function getXmlErrors()
private function getXmlErrors()
{
$errors = array();
foreach (libxml_get_errors() as $error) {
Expand Down
14 changes: 1 addition & 13 deletions src/Symfony/Component/Routing/Loader/YamlFileLoader.php
Expand Up @@ -42,7 +42,7 @@ public function load($file, $type = null)
{
$path = $this->locator->locate($file);

$config = $this->loadFile($path);
$config = Yaml::load($path);

$collection = new RouteCollection();
$collection->addResource(new FileResource($path));
Expand Down Expand Up @@ -113,18 +113,6 @@ protected function parseRoute(RouteCollection $collection, $name, $config, $file
$collection->add($name, $route);
}

/**
* Loads a Yaml file.
*
* @param string $file A Yaml file path
*
* @return array
*/
protected function loadFile($file)
{
return Yaml::load($file);
}

/**
* Normalize route configuration.
*
Expand Down
Expand Up @@ -43,7 +43,7 @@ public function dump(array $options = array())
$rules = array("# skip \"real\" requests\nRewriteCond %{REQUEST_FILENAME} -f\nRewriteRule .* - [QSA,L]");
$methodVars = array();

foreach ($this->routes->all() as $name => $route) {
foreach ($this->getRoutes()->all() as $name => $route) {
$compiledRoute = $route->compile();

// prepare the apache regex
Expand Down
12 changes: 11 additions & 1 deletion src/Symfony/Component/Routing/Matcher/Dumper/MatcherDumper.php
Expand Up @@ -21,7 +21,7 @@
*/
abstract class MatcherDumper implements MatcherDumperInterface
{
protected $routes;
private $routes;

/**
* Constructor.
Expand All @@ -32,4 +32,14 @@ public function __construct(RouteCollection $routes)
{
$this->routes = $routes;
}

/**
* Gets the routes to dump.
*
* @return RouteCollection A RouteCollection instance
*/
public function getRoutes()
{
return $this->routes;
}
}
Expand Up @@ -31,4 +31,11 @@ interface MatcherDumperInterface
* @return string A PHP class representing the matcher class
*/
function dump(array $options = array());

/**
* Gets the routes to match.
*
* @return RouteCollection A RouteCollection instance
*/
function getRoutes();
}
Expand Up @@ -47,11 +47,11 @@ public function dump(array $options = array())
;
}

protected function addMatcher()
private function addMatcher()
{
$code = array();

foreach ($this->routes->all() as $name => $route) {
foreach ($this->getRoutes()->all() as $name => $route) {
$compiledRoute = $route->compile();

$conditions = array();
Expand Down Expand Up @@ -139,7 +139,7 @@ public function match(\$pathinfo)
EOF;
}

protected function startClass($class, $baseClass)
private function startClass($class, $baseClass)
{
return <<<EOF
<?php
Expand All @@ -159,7 +159,7 @@ class $class extends $baseClass
EOF;
}

protected function addConstructor()
private function addConstructor()
{
return <<<EOF
/**
Expand All @@ -174,7 +174,7 @@ public function __construct(array \$context = array(), array \$defaults = array(
EOF;
}

protected function endClass()
private function endClass()
{
return <<<EOF
}
Expand Down
3 changes: 2 additions & 1 deletion src/Symfony/Component/Routing/Matcher/UrlMatcher.php
Expand Up @@ -23,10 +23,11 @@
*/
class UrlMatcher implements UrlMatcherInterface
{
protected $routes;
protected $defaults;
protected $context;

private $routes;

/**
* Constructor.
*
Expand Down
14 changes: 7 additions & 7 deletions src/Symfony/Component/Routing/Route.php
Expand Up @@ -18,13 +18,13 @@
*/
class Route
{
protected $pattern;
protected $defaults;
protected $requirements;
protected $options;
protected $compiled;
private $pattern;
private $defaults;
private $requirements;
private $options;
private $compiled;

static protected $compilers = array();
static private $compilers = array();

/**
* Constructor.
Expand Down Expand Up @@ -240,7 +240,7 @@ public function compile()
return $this->compiled = static::$compilers[$class]->compile($this);
}

protected function sanitizeRequirement($key, $regex)
private function sanitizeRequirement($key, $regex)
{
if (is_array($regex)) {
throw new \InvalidArgumentException(sprintf('Routing requirements must be a string, array given for "%s"', $key));
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Routing/RouteCollection.php
Expand Up @@ -20,8 +20,8 @@
*/
class RouteCollection
{
protected $routes;
protected $resources;
private $routes;
private $resources;

/**
* Constructor.
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Routing/RouteCompiler.php
Expand Up @@ -119,7 +119,7 @@ protected function postCompile()
*
* @throws \InvalidArgumentException When route can't be parsed
*/
protected function tokenize()
private function tokenize()
{
$this->tokens = array();
$buffer = $this->route->getPattern();
Expand Down Expand Up @@ -221,7 +221,7 @@ protected function compileForSeparator($separator, $regexSeparator)
{
}

protected function getOptions()
private function getOptions()
{
$options = $this->route->getOptions();

Expand Down

0 comments on commit b585752

Please sign in to comment.