Skip to content
This repository
  • 9 commits
  • 15 files changed
  • 0 comments
  • 1 contributor
39  CHANGELOG.md
Source Rendered
... ...
@@ -1,39 +1,74 @@
1 1
 CHANGELOG
2 2
 =========
3 3
 
  4
+ * added logger into service container for command
  5
+ * optimized sfPatternRouting cache with unserialise sfRoute objects on demand, huge gain with lookup_cache_dedicated_keys
  6
+ * added sf_cli core configuration
  7
+ * added default option --no-debug for tasks (usefull for project:optimize task)
  8
+ * used is_file instead of file_exists in sfFileCache, sfAutoload, sfApplicationConfiguration, sfProjectConfiguration and sfSessionTestStorage classes
  9
+ * added sfBaseTask::isVerbose() method
  10
+ * fixed "plugin:publish-assets" task generate absolute symlinks
  11
+ * fixed "project:optimize" task: file permissions, configurable environment and module generation
4 12
  * added task doctrine:compile to package the library into an unique cached file
  13
+ * added send event "application.throw_exception" when an exception occurs in a task
  14
+ * added exceptions catch in "cache:clear" task
5 15
  * fixed task project:optimize
  16
+ * added sfServiceContainer* classes to core_compile
  17
+ * cleaned some file class names, removed some require_once
  18
+ * fixed possible warning in sfWidgetFormSelectCheckbox
  19
+ * sfLogger implements sfLoggerInterface
6 20
  * added unit tests for yaml and event classes
  21
+ * added possibility to parse yaml for value when encoding is not utf-8
7 22
  * added sfWidgetFormDoctrineArrayChoice widget
  23
+ * added unit test for sfWidgetFormDoctrineChoice
8 24
  * added sfFormObject::saveObject() method
  25
+ * fixed sfValidatorFile error message for php.ini upload_max_filesize (inspired from Symfony2)
  26
+ * added sfForm::getErrors method
  27
+ * added possibility to set integer as name for named error
  28
+ * fixed: do not clone the form on embed anymore
  29
+ * removed unused sfWidgetFormSchemaForEach and sfValidatorSchemaForEach classes
9 30
  * added skip-build option to sfDoctrineCreateModelTablesTask (patch from @estahn)
10 31
  * better code coverage for sfWebRequest class unit tests
11 32
  * added parameters proxy to sfWebRequest::getClientIp() method (default true)
12 33
  * introduced trust_proxy option on sfWebRequest (default true)
  34
+ * added call to fastcgi_finish_request() function if available on sfWebResponse::run() method
  35
+ * added possibility to launch bin/coverage task for only one class
  36
+ * added sfRequest::getOption() method
13 37
  * used SQLite 3 for php 5.3 or later, as it's required for php 5.4
14 38
  * fixed sfI18NTest for php version > 5.2
  39
+ * added possibility for preValidator to modify values
15 40
  * displayed form errors with sfTestBrowser->with(form)->hasError()
  41
+ * added sfValidatorEqual
16 42
  * added test_path option to sfLimeHarness (patch by @stephaneerard)
  43
+ * allowed '-' character in key for sfToolkit::stringToArray (patch by @eXtreme)
  44
+ * added sfValidatorChoice::isEmpty method to test if value is an array with only empty value(s) (inspired by patch of @antitoxic)
17 45
  * added sfWebRequest::getClientIp() method
18 46
  * added sf_upload_dir_name to config
  47
+ * added sfValidatorIp (extracted from symfony2)
  48
+ * removed usage of array_unique in getStylesheets and getJavascripts methods of sfWidgetFormDateRange
19 49
  * fixed sfDoctrineRecordI18nFilter::filterGet() do not return empty translation (patch from @mahono)
20 50
  * fixed possible warning in sfDoctrineConnectionProfiler (patch from @mahono)
  51
+ * added sfWidgetFormInputRead
21 52
  * added sfWebResponse::prependTitle() method
22 53
  * added options truncate_pattern and max_lenght arguments to truncate_text function in TextHelper
23 54
  * added sfBaseTask::withTrace() and sfBaseTask::showStatus() methods
  55
+ * removed usage of array_map in widget
24 56
  * fixed sfValidatorFileTest for PHP >= 5.3.7
25  
- * added a dic with sf_event_dispatcher, sf_formatter and sf_logger injected in core
  57
+ * injected sf_event_dispatcher, sf_formatter and sf_logger to core service container
  58
+ * introduced recursive form embed (fix many embed form issues)
26 59
  * formatted sfValidatorFile error with KB instead of Bytes for readability
27 60
  * added sfComponent::renderJson() method
28 61
  * added foreign field name for column in foreign key field form definition
29 62
  * removed first choice only if it's strictly an empty string in sfValidatorDoctrineChoice
30 63
  * added sfValidatedFile::resetType() method
31  
- * enable trim option by default on sfValidatorBase
  64
+ * enabled trim option by default on sfValidatorBase
32 65
  * throw real exception on sfValidatorSchema and sfValidatorSchemaFilter
33 66
  * return php result for copy and rename methods of sfFilesystem
34 67
  * added clearJavascripts() and clearStylesheets() methods to sfWebResponse
35 68
  * added clear_javascripts and clear_stylesheets functions to AssetHelper
36 69
  * fixed sfAction::setTemplate() to allow view exists only in plugin dir when the module action is extended in application
  70
+ * added sfServiceConfigHandler
  71
+ * imported sfServiceContainer component
37 72
  * replaced embedded swiftmailer by upstream submodule of swiftmailer 4.1
38 73
  * removed sfPropelPlugin
39 74
 
2  lib/autoload/sfAutoload.class.php
@@ -124,7 +124,7 @@ public function reloadClasses($force = false)
124 124
     }
125 125
 
126 126
     self::$freshCache = true;
127  
-    if (file_exists($configuration->getConfigCache()->getCacheName('config/autoload.yml')))
  127
+    if (is_file($configuration->getConfigCache()->getCacheName('config/autoload.yml')))
128 128
     {
129 129
       self::$freshCache = false;
130 130
       if ($force)
13  lib/cache/sfFileCache.class.php
@@ -3,7 +3,7 @@
3 3
 /*
4 4
  * This file is part of the symfony package.
5 5
  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  
- * 
  6
+ *
7 7
  * For the full copyright and license information, please view the LICENSE
8 8
  * file that was distributed with this source code.
9 9
  */
@@ -53,7 +53,7 @@ public function initialize($options = array())
53 53
   public function get($key, $default = null)
54 54
   {
55 55
     $file_path = $this->getFilePath($key);
56  
-    if (!file_exists($file_path))
  56
+    if (!is_file($file_path))
57 57
     {
58 58
       return $default;
59 59
     }
@@ -74,7 +74,8 @@ public function get($key, $default = null)
74 74
   public function has($key)
75 75
   {
76 76
     $path = $this->getFilePath($key);
77  
-    return file_exists($path) && $this->isValid($path);
  77
+
  78
+    return is_file($path) && $this->isValid($path);
78 79
   }
79 80
 
80 81
   /**
@@ -164,7 +165,7 @@ public function getTimeout($key)
164 165
   {
165 166
     $path = $this->getFilePath($key);
166 167
 
167  
-    if (!file_exists($path))
  168
+    if (!is_file($path))
168 169
     {
169 170
       return 0;
170 171
     }
@@ -181,11 +182,11 @@ public function getLastModified($key)
181 182
   {
182 183
     $path = $this->getFilePath($key);
183 184
 
184  
-    if (!file_exists($path))
  185
+    if (!is_file($path))
185 186
     {
186 187
       return 0;
187 188
     }
188  
-    
  189
+
189 190
     $data = $this->read($path, self::READ_TIMEOUT | self::READ_LAST_MODIFIED);
190 191
 
191 192
     if ($data[self::READ_TIMEOUT] < time())
19  lib/command/sfCommandApplication.class.php
@@ -3,7 +3,7 @@
3 3
 /*
4 4
  * This file is part of the symfony package.
5 5
  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  
- * 
  6
+ *
7 7
  * For the full copyright and license information, please view the LICENSE
8 8
  * file that was distributed with this source code.
9 9
  */
@@ -22,6 +22,7 @@
22 22
     $commandManager = null,
23 23
     $trace          = false,
24 24
     $verbose        = true,
  25
+    $debug          = true,
25 26
     $nowrite        = false,
26 27
     $name           = 'UNKNOWN',
27 28
     $version        = 'UNKNOWN',
@@ -55,6 +56,7 @@ public function __construct(sfEventDispatcher $dispatcher, sfFormatter $formatte
55 56
       new sfCommandOption('--trace',   '-t', sfCommandOption::PARAMETER_NONE, 'Turn on invoke/execute tracing, enable full backtrace.'),
56 57
       new sfCommandOption('--version', '-V', sfCommandOption::PARAMETER_NONE, 'Display the program version.'),
57 58
       new sfCommandOption('--color',   '',   sfCommandOption::PARAMETER_NONE, 'Forces ANSI color output.'),
  59
+      new sfCommandOption('--no-debug','',   sfCommandOption::PARAMETER_NONE, 'Disable debug'),
58 60
     ));
59 61
     $this->commandManager = new sfCommandManager($argumentSet, $optionSet);
60 62
 
@@ -295,6 +297,16 @@ public function withTrace()
295 297
   }
296 298
 
297 299
   /**
  300
+   * Returns whether the application must be verbose.
  301
+   *
  302
+   * @return Boolean true if the application is in debug mode, false otherwise
  303
+   */
  304
+  public function isDebug()
  305
+  {
  306
+    return $this->debug;
  307
+  }
  308
+
  309
+  /**
298 310
    * Outputs a help message for the current application.
299 311
    */
300 312
   public function help()
@@ -339,6 +351,11 @@ protected function handleOptions($options = null)
339 351
       $this->verbose = false;
340 352
     }
341 353
 
  354
+    if ($this->commandManager->getOptionSet()->hasOption('no-debug') && false !== $this->commandManager->getOptionValue('no-debug'))
  355
+    {
  356
+      $this->debug = false;
  357
+    }
  358
+
342 359
     if ($this->commandManager->getOptionSet()->hasOption('trace') && false !== $this->commandManager->getOptionValue('trace'))
343 360
     {
344 361
       $this->verbose = true;
13  lib/config/sfApplicationConfiguration.class.php
@@ -55,7 +55,7 @@ public function __construct($environment, $debug, $rootDir = null, sfEventDispat
55 55
       $this->checkLock();
56 56
     }
57 57
 
58  
-    if (file_exists($file = sfConfig::get('sf_app_cache_dir').'/config/configuration.php'))
  58
+    if (is_file($file = sfConfig::get('sf_app_cache_dir').'/config/configuration.php'))
59 59
     {
60 60
       $this->cache = require $file;
61 61
     }
@@ -98,13 +98,13 @@ public function initConfiguration()
98 98
     $configCache = $this->getConfigCache();
99 99
 
100 100
     // in debug mode, start global timer
101  
-    if ($this->isDebug() && !sfWebDebugPanelTimer::isStarted())
  101
+    if ($this->isDebug() && !sfConfig::get('sf_cli') && !sfWebDebugPanelTimer::isStarted())
102 102
     {
103 103
       sfWebDebugPanelTimer::startTime();
104 104
     }
105 105
 
106 106
     // required core classes for the framework
107  
-    if (!$this->isDebug() && !sfConfig::get('sf_test') && !self::$coreLoaded)
  107
+    if (!$this->isDebug() && !sfConfig::get('sf_test') && !sfConfig::get('sf_cli') && !self::$coreLoaded)
108 108
     {
109 109
       $configCache->import('config/core_compile.yml', false);
110 110
     }
@@ -124,7 +124,7 @@ public function initConfiguration()
124 124
       include($file);
125 125
     }
126 126
 
127  
-    if (false !== sfConfig::get('sf_csrf_secret'))
  127
+    if (!sfConfig::get('sf_cli') && false !== sfConfig::get('sf_csrf_secret'))
128 128
     {
129 129
       sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret'));
130 130
     }
@@ -178,10 +178,10 @@ protected function initializePlugins()
178 178
 
179 179
   /**
180 180
    * Adds enabled plugins to autoload config.
181  
-   * 
  181
+   *
182 182
    * @param   sfEvent $event
183 183
    * @param   array   $config
184  
-   * 
  184
+   *
185 185
    * @return  array
186 186
    */
187 187
   public function filterAutoloadConfig(sfEvent $event, array $config)
@@ -288,6 +288,7 @@ public function setRootDir($rootDir)
288 288
       'sf_app'         => $this->getApplication(),
289 289
       'sf_environment' => $this->getEnvironment(),
290 290
       'sf_debug'       => $this->isDebug(),
  291
+      'sf_cli'         => 0 === strncasecmp(PHP_SAPI, 'cli', 3)
291 292
     ));
292 293
 
293 294
     $this->setAppDir(sfConfig::get('sf_apps_dir').DIRECTORY_SEPARATOR.$this->getApplication());
2  lib/config/sfProjectConfiguration.class.php
@@ -605,7 +605,7 @@ static public function getApplicationConfiguration($application, $environment, $
605 605
       $rootDir = self::guessRootDir();
606 606
     }
607 607
 
608  
-    if (!file_exists($file = $rootDir.'/apps/'.$application.'/config/'.$class.'.class.php'))
  608
+    if (!is_file($file = $rootDir.'/apps/'.$application.'/config/'.$class.'.class.php'))
609 609
     {
610 610
       throw new InvalidArgumentException(sprintf('The application "%s" does not exist.', $application));
611 611
     }
2  lib/config/sfRoutingConfigHandler.class.php
@@ -41,7 +41,7 @@ public function execute($configFiles)
41 41
       foreach (sfPatternRouting::flattenRoutes($routes) as $name => $route)
42 42
       {
43 43
         $route->setDefaultOptions($options);
44  
-        $data[] = sprintf('$this->routes[\'%s\'] = unserialize(%s);', $name, var_export(serialize($route), true));
  44
+        $data[] = sprintf('$this->routes[\'%s\'] = %s;', $name, var_export(serialize($route), true));
45 45
       }
46 46
     }
47 47
 
78  lib/routing/sfPatternRouting.class.php
@@ -24,7 +24,6 @@ class sfPatternRouting extends sfRouting
24 24
     $currentRouteName   = null,
25 25
     $currentInternalUri = array(),
26 26
     $routes             = array(),
27  
-    $defaultParamsDirty = false,
28 27
     $cacheData          = array(),
29 28
     $cacheChanged       = false;
30 29
 
@@ -85,40 +84,6 @@ public function loadConfiguration()
85 84
     parent::loadConfiguration();
86 85
   }
87 86
 
88  
-  /**
89  
-   * Added for better performance. We need to ensure that changed default parameters
90  
-   * are set, but resetting them everytime wastes many cpu cycles
91  
-   */
92  
-  protected function ensureDefaultParametersAreSet()
93  
-  {
94  
-    if ($this->defaultParamsDirty)
95  
-    {
96  
-      foreach ($this->routes as $route)
97  
-      {
98  
-        $route->setDefaultParameters($this->defaultParameters);
99  
-      }
100  
-      $this->defaultParamsDirty = false;
101  
-    }
102  
-  }
103  
-
104  
-  /**
105  
-   * @see sfRouting
106  
-   */
107  
-  public function setDefaultParameter($key, $value)
108  
-  {
109  
-    parent::setDefaultParameter($key, $value);
110  
-    $this->defaultParamsDirty = true;
111  
-  }
112  
-
113  
-  /**
114  
-   * @see sfRouting
115  
-   */
116  
-  public function setDefaultParameters($parameters)
117  
-  {
118  
-    parent::setDefaultParameters($parameters);
119  
-    $this->defaultParamsDirty = true;
120  
-  }
121  
-
122 87
   protected function getConfigFileName()
123 88
   {
124 89
     return sfContext::getInstance()->getConfigCache()->checkConfig('config/routing.yml', true);
@@ -151,6 +116,27 @@ public function getRoutes()
151 116
   }
152 117
 
153 118
   /**
  119
+   * @see  sfRouting
  120
+   */
  121
+  public function getRoute($name)
  122
+  {
  123
+    if (!array_key_exists($name, $this->routes))
  124
+    {
  125
+      throw new sfException(sprintf('Route "%s" is not defined.', $name));
  126
+    }
  127
+
  128
+    $route = $this->routes[$name];
  129
+
  130
+    if (is_string($route))
  131
+    {
  132
+      $this->routes[$name] = $route = unserialize($route);
  133
+      $route->setDefaultParameters($this->defaultParameters);
  134
+    }
  135
+
  136
+    return $route;
  137
+  }
  138
+
  139
+  /**
154 140
    * @see sfRouting
155 141
    */
156 142
   public function setRoutes($routes)
@@ -191,7 +177,7 @@ public function clearRoutes()
191 177
    */
192 178
   public function hasRouteName($name)
193 179
   {
194  
-    return isset($this->routes[$name]) ? true : false;
  180
+    return array_key_exists($name, $this->routes);
195 181
   }
196 182
 
197 183
   /**
@@ -307,13 +293,7 @@ public function generate($name, $params = array(), $absolute = false)
307 293
 
308 294
     if ($name)
309 295
     {
310  
-      // named route
311  
-      if (!isset($this->routes[$name]))
312  
-      {
313  
-        throw new sfConfigurationException(sprintf('The route "%s" does not exist.', $name));
314  
-      }
315  
-      $route = $this->routes[$name];
316  
-      $this->ensureDefaultParametersAreSet();
  296
+      $route = $this->getRoute($name);
317 297
     }
318 298
     else
319 299
     {
@@ -364,9 +344,7 @@ public function parse($url)
364 344
     // store the current internal URI
365 345
     $this->updateCurrentInternalUri($info['name'], $info['parameters']);
366 346
 
367  
-    $route = $this->routes[$info['name']];
368  
-
369  
-    $this->ensureDefaultParametersAreSet();
  347
+    $route = $this->getRoute($info['name']);
370 348
 
371 349
     $route->bind($this->options['context'], $info['parameters']);
372 350
     $info['parameters']['_sf_route'] = $route;
@@ -468,9 +446,10 @@ static public function flattenRoutes($routes)
468 446
 
469 447
   protected function getRouteThatMatchesUrl($url)
470 448
   {
471  
-    $this->ensureDefaultParametersAreSet();
472 449
     foreach ($this->routes as $name => $route)
473 450
     {
  451
+      $route = $this->getRoute($name);
  452
+
474 453
       if (false === $parameters = $route->matchesUrl($url, $this->options['context']))
475 454
       {
476 455
         continue;
@@ -484,9 +463,10 @@ protected function getRouteThatMatchesUrl($url)
484 463
 
485 464
   protected function getRouteThatMatchesParameters($parameters)
486 465
   {
487  
-    $this->ensureDefaultParametersAreSet();
488  
-    foreach ($this->routes as $route)
  466
+    foreach ($this->routes as $name => $route)
489 467
     {
  468
+      $route = $this->getRoute($name);
  469
+
490 470
       if ($route->matchesParameters($parameters, $this->options['context']))
491 471
       {
492 472
         return $route;
9  lib/routing/sfRouting.class.php
@@ -132,6 +132,15 @@ public function loadConfiguration()
132 132
   abstract public function getRoutes();
133 133
 
134 134
   /**
  135
+   * Gets route from given name
  136
+   *
  137
+   * @param  string $name The route name
  138
+   *
  139
+   * @return sfRoute
  140
+   */
  141
+  abstract public function getRoute($name);
  142
+
  143
+  /**
135 144
    * Sets the compiled route array.
136 145
    *
137 146
    * @param  array $routes  The route array
2  lib/storage/sfSessionTestStorage.class.php
@@ -52,7 +52,7 @@ public function initialize($options = null)
52 52
     {
53 53
       // we read session data from temp file
54 54
       $file = $this->options['session_path'].DIRECTORY_SEPARATOR.$this->sessionId.'.session';
55  
-      $this->sessionData = file_exists($file) ? unserialize(file_get_contents($file)) : array();
  55
+      $this->sessionData = is_file($file) ? unserialize(file_get_contents($file)) : array();
56 56
     }
57 57
     else
58 58
     {
44  lib/task/sfBaseTask.class.php
@@ -61,7 +61,7 @@ protected function doRun(sfCommandManager $commandManager, $options)
61 61
       $this->configuration = $this->createConfiguration($application, $env);
62 62
     }
63 63
 
64  
-    if (null !== $this->commandApplication && !$this->commandApplication->withTrace())
  64
+    if (!$this->withTrace())
65 65
     {
66 66
       sfConfig::set('sf_logging_enabled', false);
67 67
     }
@@ -92,7 +92,7 @@ public function getFilesystem()
92 92
   {
93 93
     if (!isset($this->filesystem))
94 94
     {
95  
-      if (null === $this->commandApplication || $this->commandApplication->isVerbose())
  95
+      if ($this->isVerbose())
96 96
       {
97 97
         $this->filesystem = new sfFilesystem($this->dispatcher, $this->formatter);
98 98
       }
@@ -150,18 +150,48 @@ public function checkModuleExists($app, $module)
150 150
   }
151 151
 
152 152
   /**
153  
-   * Checks if trace mode is enable
  153
+   * Checks if trace mode is enabled
154 154
    *
155 155
    * @return boolean
156 156
    */
157 157
   protected function withTrace()
158 158
   {
159  
-    if (is_null($this->commandApplication) || $this->commandApplication->withTrace())
  159
+    if (null !== $this->commandApplication && !$this->commandApplication->withTrace())
  160
+    {
  161
+      return false;
  162
+    }
  163
+
  164
+    return true;
  165
+  }
  166
+
  167
+  /**
  168
+   * Checks if verbose mode is enabled
  169
+   *
  170
+   * @return boolean
  171
+   */
  172
+  protected function isVerbose()
  173
+  {
  174
+    if (null !== $this->commandApplication && !$this->commandApplication->isVerbose())
  175
+    {
  176
+      return false;
  177
+    }
  178
+
  179
+    return true;
  180
+  }
  181
+
  182
+  /**
  183
+   * Checks if debug mode is enabled
  184
+   *
  185
+   * @return boolean
  186
+   */
  187
+  protected function isDebug()
  188
+  {
  189
+    if (null !== $this->commandApplication && !$this->commandApplication->isDebug())
160 190
     {
161  
-      return true;
  191
+      return false;
162 192
     }
163 193
 
164  
-    return false;
  194
+    return true;
165 195
   }
166 196
 
167 197
   /**
@@ -180,7 +210,7 @@ protected function createConfiguration($application, $env)
180 210
 
181 211
       require_once sfConfig::get('sf_config_dir').'/ProjectConfiguration.class.php';
182 212
 
183  
-      $configuration = ProjectConfiguration::getApplicationConfiguration($application, $env, true, null, $this->dispatcher);
  213
+      $configuration = ProjectConfiguration::getApplicationConfiguration($application, $env, $this->isDebug(), null, $this->dispatcher);
184 214
     }
185 215
     else
186 216
     {
16  lib/task/sfCommandApplicationTask.class.php
@@ -121,6 +121,11 @@ protected function getMailer()
121 121
     return $this->mailer;
122 122
   }
123 123
 
  124
+  /**
  125
+   * Initialize mailer
  126
+   *
  127
+   * @return sfMailer A sfMailer instance
  128
+   */
124 129
   protected function initializeMailer()
125 130
   {
126 131
     $swift_dir = sfConfig::get('sf_symfony_lib_dir').'/vendor/swiftmailer/lib';
@@ -152,6 +157,11 @@ protected function getRouting()
152 157
     return $this->routing;
153 158
   }
154 159
 
  160
+  /**
  161
+   * Initialize routing
  162
+   *
  163
+   * @return sfRouting A sfRouting instance
  164
+   */
155 165
   protected function initializeRouting()
156 166
   {
157 167
     $config = $this->getFactoryConfiguration();
@@ -187,6 +197,7 @@ protected function getServiceContainer()
187 197
       $this->serviceContainer = new $class();
188 198
       $this->serviceContainer->setService('sf_event_dispatcher', $this->dispatcher);
189 199
       $this->serviceContainer->setService('sf_formatter', $this->formatter);
  200
+      $this->serviceContainer->setService('sf_logger', new sfCommandLogger($this->dispatcher));
190 201
     }
191 202
 
192 203
     return $this->serviceContainer;
@@ -204,6 +215,11 @@ public function getService($id)
204 215
     return $this->getServiceContainer()->getService($id);
205 216
   }
206 217
 
  218
+  /**
  219
+   * Gets the factory configuration
  220
+   *
  221
+   * @return array
  222
+   */
207 223
   protected function getFactoryConfiguration()
208 224
   {
209 225
     if (null === $this->factoryConfiguration)
3  test/unit/routing/fixtures/config_routing.yml.php
... ...
@@ -0,0 +1,3 @@
  1
+<?php
  2
+// auto-generated by sfRoutingConfigHandler
  3
+$this->routes['test1'] = 'C:7:"sfRoute":1143:{a:11:{i:0;a:2:{i:0;a:4:{i:0;s:9:"separator";i:1;s:0:"";i:2;s:1:"/";i:3;N;}i:1;a:3:{i:0;s:9:"separator";i:1;s:1:"/";i:2;s:1:"/";}}i:1;a:9:{s:18:"load_configuration";b:1;s:6:"suffix";s:0:"";s:14:"default_module";s:7:"default";s:14:"default_action";s:5:"index";s:5:"debug";s:0:"";s:7:"logging";s:0:"";s:21:"generate_shortest_url";b:1;s:32:"extra_parameters_as_query_string";b:1;s:27:"lookup_cache_dedicated_keys";b:1;}i:2;a:16:{s:6:"suffix";s:0:"";s:17:"variable_prefixes";a:1:{i:0;s:1:":";}s:18:"segment_separators";a:2:{i:0;s:1:"/";i:1;s:1:".";}s:14:"variable_regex";s:8:"[\\w\\d_]+";s:10:"text_regex";s:3:".+?";s:21:"generate_shortest_url";b:1;s:32:"extra_parameters_as_query_string";b:1;s:18:"load_configuration";b:1;s:14:"default_module";s:7:"default";s:14:"default_action";s:5:"index";s:5:"debug";s:0:"";s:7:"logging";s:0:"";s:27:"lookup_cache_dedicated_keys";b:1;s:21:"variable_prefix_regex";s:6:"(?:\\:)";s:24:"segment_separators_regex";s:8:"(?:/|\\.)";s:22:"variable_content_regex";s:7:"[^/\\.]+";}i:3;s:1:"/";i:4;s:0:"";i:5;s:6:"#^/$#x";i:6;a:0:{}i:7;a:2:{s:6:"module";s:7:"default";s:6:"action";s:5:"index";}i:8;a:0:{}i:9;s:1:"/";i:10;b:0;}}';
19  test/unit/routing/sfPatternRoutingTest.php
@@ -10,7 +10,7 @@
10 10
 
11 11
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
12 12
 
13  
-$t = new lime_test(145);
  13
+$t = new lime_test(149);
14 14
 
15 15
 class sfPatternRoutingTest extends sfPatternRouting
16 16
 {
@@ -38,6 +38,11 @@ public function isRouteLoaded($name)
38 38
   {
39 39
     return isset($this->routes[$name]) && is_object($this->routes[$name]);
40 40
   }
  41
+
  42
+  protected function getConfigFileName()
  43
+  {
  44
+    return dirname(__FILE__).'/fixtures/config_routing.yml.php';
  45
+  }
41 46
 }
42 47
 
43 48
 class sfAlwaysAbsoluteRoute extends sfRoute
@@ -627,3 +632,15 @@ function configureRouting($event)
627 632
 $t->is($r->generate('', array('module' => 'posts', 'action' => 'index')), '/posts.html', '->generate() creates URL when using suffix and generate_shortest_url');
628 633
 $t->is($r->generate('', array('module' => 'posts', 'action' => 'index', 'page' => '1')), '/posts.html', '->generate() creates URL when using suffix and generate_shortest_url');
629 634
 $t->is($r->generate('', array('module' => 'posts', 'action' => 'index', 'page' => '2')), '/posts/2.html', '->generate() creates URL when using suffix and generate_shortest_url');
  635
+
  636
+
  637
+$t->diag('load_configuration with serialized routes');
  638
+
  639
+// see fixtures/config_routing.yml.php
  640
+$r = new sfPatternRoutingTest(new sfEventDispatcher(), new sfNoCache(), array('load_configuration' => true));
  641
+$t->ok($r->hasRouteName('test1'), '->loadConfiguration() Config file is loaded');
  642
+$routes = $r->getRoutes();
  643
+$t->ok(is_string($routes['test1']), '->loadConfiguration() Route objects are not serialized in cache');
  644
+$route = $r->getRoute('test1');
  645
+$t->ok(is_object($route), '->loadConfiguration() Route objects are unserialized on demand');
  646
+$t->is_deeply($r->parse('/'), array('module' => 'default', 'action' => 'index'), '->parse() Default parameters are applied to serialized routes');
8  test/unit/sfNoRouting.class.php
@@ -73,6 +73,14 @@ public function getRoutes()
73 73
   /**
74 74
    * @see sfRouting
75 75
    */
  76
+  public function getRoute()
  77
+  {
  78
+    return null;
  79
+  }
  80
+
  81
+  /**
  82
+   * @see sfRouting
  83
+   */
76 84
   public function setRoutes($routes)
77 85
   {
78 86
     return array();

No commit comments for this range

Something went wrong with that request. Please try again.