Skip to content
This repository

added "connection" option to sfPropelORMRouteCollection #178

Merged
merged 1 commit into from over 1 year ago

2 participants

Massimiliano Arione William Durand
Massimiliano Arione

This is related to #177 (btw, sorry for double PR)
Adds the "connection" option also to RouteCollection, of course leveraging the same option in Route.
As usual, docs were updated too.

William Durand willdurand merged commit 2d55d56 into from December 22, 2012
William Durand willdurand closed this December 22, 2012
William Durand
Owner

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 05, 2012
Massimiliano Arione added "connection" option to sfPropelORMRouteCollection cd2580b
This page is out of date. Refresh to see the latest.
18  README.md
Source Rendered
@@ -291,13 +291,25 @@ public function executeShow(sfWebRequest $request)
291 291
 }
292 292
 ```
293 293
 
294  
-A new option has been added to `sfPropelORMRoute`: the `connection` option allows to set a specific Propel connection to use.
295  
-Example:
  294
+A new option has been added to both `sfPropelORMRoute` and `sfPropelORMRouteCollection`, the `connection` option allows to set a specific Propel connection to use.
  295
+Examples:
296 296
 
297 297
 ``` yaml
298 298
 author_show:
299 299
   url:     /author/:id
300  
-  class:   Author
  300
+  class:   sfPropelORMRoute
301 301
   param:   { module: myModule, action: show }
302 302
   options: { model: Author, type: object, connection: my_connection }
303 303
 ```
  304
+
  305
+``` yaml
  306
+author:
  307
+    class: sfPropelORMRouteCollection
  308
+    options:
  309
+    model:                Author
  310
+    module:               author
  311
+    prefix_path:          /author
  312
+    column:               id
  313
+    connection:           my_connection
  314
+    with_wildcard_routes: true
  315
+```
19  lib/routing/sfPropelORMRouteCollection.class.php
@@ -30,6 +30,7 @@ public function __construct(array $options)
30 30
   {
31 31
     $options = array_merge(array(
32 32
       'query_methods'        => array('list' => null, 'object' => null),
  33
+      'connection'           => null,
33 34
     ), $options);
34 35
 
35 36
     parent::__construct($options);
@@ -84,7 +85,7 @@ protected function getRouteForCollection($action, $methods)
84 85
       sprintf('%s/%s.:sf_format', $this->options['prefix_path'], $action),
85 86
       array_merge(array('module' => $this->options['module'], 'action' => $action, 'sf_format' => 'html'), $this->options['default_params']),
86 87
       array_merge($this->options['requirements'], array('sf_method' => $methods)),
87  
-      array('model' => $this->options['model'], 'type' => 'list', 'query_methods' => $this->options['query_methods']['list'])
  88
+      array('model' => $this->options['model'], 'type' => 'list', 'query_methods' => $this->options['query_methods']['list'], 'connection' => $this->options['connection'])
88 89
     );
89 90
   }
90 91
 
@@ -94,7 +95,7 @@ protected function getRouteForObject($action, $methods)
94 95
       sprintf('%s/:%s/%s.:sf_format', $this->options['prefix_path'], $this->options['column'], $action),
95 96
       array_merge(array('module' => $this->options['module'], 'action' => $action, 'sf_format' => 'html'), $this->options['default_params']),
96 97
       array_merge($this->options['requirements'], array('sf_method' => $methods)),
97  
-      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'])
  98
+      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'], 'connection' => $this->options['connection'])
98 99
     );
99 100
   }
100 101
 
@@ -104,7 +105,7 @@ protected function getWildcardRouteForCollection()
104 105
       sprintf('%s/:action/action.:sf_format', $this->options['prefix_path']),
105 106
       array_merge(array('module' => $this->options['module'], 'sf_format' => 'html'), $this->options['default_params']),
106 107
       array_merge($this->options['requirements'], array('sf_method' => array('get', 'head', 'post'))),
107  
-      array('model' => $this->options['model'], 'type' => 'list', 'query_methods' => $this->options['query_methods']['list'])
  108
+      array('model' => $this->options['model'], 'type' => 'list', 'query_methods' => $this->options['query_methods']['list'], 'connection' => $this->options['connection'])
108 109
     );
109 110
   }
110 111
 
@@ -114,7 +115,7 @@ protected function getWildcardRouteForObject()
114 115
       sprintf('%s/:%s/:action.:sf_format', $this->options['prefix_path'], $this->options['column']),
115 116
       array_merge(array('module' => $this->options['module'], 'sf_format' => 'html'), $this->options['default_params']),
116 117
       array_merge($this->options['requirements'], array('sf_method' => 'get')),
117  
-      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'])
  118
+      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'], 'connection' => $this->options['connection'])
118 119
     );
119 120
   }
120 121
 
@@ -124,7 +125,7 @@ protected function getRouteForList()
124 125
       sprintf('%s.:sf_format', $this->options['prefix_path']),
125 126
       array_merge(array('module' => $this->options['module'], 'action' => $this->getActionMethod('list'), 'sf_format' => 'html'), $this->options['default_params']),
126 127
       array_merge($this->options['requirements'], array('sf_method' => 'get')),
127  
-      array('model' => $this->options['model'], 'type' => 'list', 'query_methods' => $this->options['query_methods']['list'])
  128
+      array('model' => $this->options['model'], 'type' => 'list', 'query_methods' => $this->options['query_methods']['list'], 'connection' => $this->options['connection'])
128 129
     );
129 130
   }
130 131
 
@@ -134,7 +135,7 @@ protected function getRouteForShow()
134 135
       sprintf('%s/:%s.:sf_format', $this->options['prefix_path'], $this->options['column']),
135 136
       array_merge(array('module' => $this->options['module'], 'action' => $this->getActionMethod('show'), 'sf_format' => 'html'), $this->options['default_params']),
136 137
       array_merge($this->options['requirements'], array('sf_method' => 'get')),
137  
-      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'])
  138
+      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'], 'connection' => $this->options['connection'])
138 139
     );
139 140
   }
140 141
 
@@ -144,7 +145,7 @@ protected function getRouteForEdit()
144 145
       sprintf('%s/:%s/%s.:sf_format', $this->options['prefix_path'], $this->options['column'], $this->options['segment_names']['edit']),
145 146
       array_merge(array('module' => $this->options['module'], 'action' => $this->getActionMethod('edit'), 'sf_format' => 'html'), $this->options['default_params']),
146 147
       array_merge($this->options['requirements'], array('sf_method' => 'get')),
147  
-      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'])
  148
+      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'], 'connection' => $this->options['connection'])
148 149
     );
149 150
   }
150 151
 
@@ -154,7 +155,7 @@ protected function getRouteForUpdate()
154 155
       sprintf('%s/:%s.:sf_format', $this->options['prefix_path'], $this->options['column']),
155 156
       array_merge(array('module' => $this->options['module'], 'action' => $this->getActionMethod('update'), 'sf_format' => 'html'), $this->options['default_params']),
156 157
       array_merge($this->options['requirements'], array('sf_method' => 'put')),
157  
-      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'])
  158
+      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'], 'connection' => $this->options['connection'])
158 159
     );
159 160
   }
160 161
 
@@ -164,7 +165,7 @@ protected function getRouteForDelete()
164 165
       sprintf('%s/:%s.:sf_format', $this->options['prefix_path'], $this->options['column']),
165 166
       array_merge(array('module' => $this->options['module'], 'action' => $this->getActionMethod('delete'), 'sf_format' => 'html'), $this->options['default_params']),
166 167
       array_merge($this->options['requirements'], array('sf_method' => 'delete')),
167  
-      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'])
  168
+      array('model' => $this->options['model'], 'type' => 'object', 'query_methods' => $this->options['query_methods']['object'], 'connection' => $this->options['connection'])
168 169
     );
169 170
   }
170 171
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.