[symfony-users] dynamically extending classes
Hi, I want to extend base classes dynamically. Following explains my requirements. I have a table 'Property'. Columns are 'property_id', 'owner_id', 'name' and many more. So default there will be BaseProperty class, Property class extending BaseProperty class. I want to use mysql views. views will be ctreated like following: vwProperty1 : SELECT * FROM Property WHERE owner_id = 1 vwProperty2 : SELECT * FROM Property WHERE owner_id = 2 I want to extend BaseVwProperty1, BaseVwProperty2 class dynamically. Based on login of Owner, I want either class Property extends BaseVwProperty1 or class Property extends BaseVwProperty2 And not following, which is default class Property extends BaseProperty. The usage of views can give performance boost and many thing you need not set every time, it eliminates lot of physical where conditions. This is an example and can be used in complex conditions. Any help will be appreciated. A solution or a suggestion of using any design pattern to achieve above. Himanshu -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: [Symfony 2] Adding custom labels to form fields
Hi, thanks for your help. Thats actually helps a lot. Greets Jan -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: How to set up a situation where a comments table is used for multiple entities
Michal's idea is one way, although personally wouldn't add that many fk's into Comment model. Each new model that will get commented, will result in modifying Comment table. If it'll grow up, ALTER TABLE might take long time. Second idea is to create association tables for each commented model (i'd prefer that), - Each new model will result ony in new association table, without the need to alter comment table Third idea is used in vjCommentPlugin: http://www.symfony-project.org/plugins/vjCommentPlugin There are no foreign keys, instead there is field which indicates commented object's model, and it's id. On 25 Lut, 16:51, Alex Pilon alex.pi...@gmail.com wrote: Hello Everyone, I have a schema in which I have several entities, lets call them Shows, Broadcasters and Pitches. A Show is essentially pitched to a Broadcaster which creates the Pitch which is an entity that sits between Show and Broadcaster and creates a many to many relationship. This is all fine and good, however there is a Note model which is meant to be attached to Show and Broadcaster (and potentially Pitch in the future). It seems to me that this sort of multi use comments table won't work quite right unless Show and Broadcaster have a common primary key, as there wouldn't be anyway to guarentee unique ids between the Show and Broadcaster and therefore Note would have an invalid foreign key. The idea I had to solve this was to create an entity table in which the other Models inherit from, but the types of inheritance don't seem to solve this problem, as simple puts everything in one table, which is rather undesirable, and concrete doesn't seem to allow shared ids with a base table. Anyone ever have a similar set up? -- Alex Pilon (613) 608-1480 -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: sfWidgetFormJQueryAutocompleter: how to retrieve the keys of the selected elements?
Ok, now I understand how this widget works..When you create this kind of widget, it actually creates two fields: autocomplete_my_field (the field that is showed and where you insert the data (values of the array elements) and my_field (a hidden field, where the keys are inserted). This widget works ok when you insert only an element but when you insert more than an element the key of the elements are overwritten (the id of the second element overwrites the id of the the first one, the id of the third element overwrites the id of the second one, ), so you can not retrieve all them. So it's a bug I think.. Javier On Feb 24, 4:27 pm, Javier Garcia tirengar...@gmail.com wrote: Hi, i have this widget : $this-widgetSchema['user'] = new sfWidgetFormChoice(array( 'choices' = array(), 'renderer_class' = 'sfWidgetFormJQueryAutocompleter', 'renderer_options' = array('url' = 'autocomplete', 'config' = '{ multiple:true }'), )); And this is the autocomplete function: public function executeAutocomplete($request) { $this-getResponse()-setContentType('application/json'); $q = % . $request-getParameter('q') . %; $limit = $request-getParameter('limit'); //Criteria code return $this-renderText(json_encode($cli)); } that returns this (Response tab in Firebug): {17:John,18:Ann} //the numbers are the values in the id field. Then i choose both names in the autocomplete input this way: [John, Peter] When i submit the form, the getPostParameters() method returns this: array 'example' = array 'id' = string '' (length=0) '_csrf_token' = string '388774046d0f5c8b4a3f114ddb15af7b' (length=32) 'user' = string '18' (length=2) 'autocomplete_example' = array 'user' = string 'John, Ann, ' So what should i do to retrieve the id's of the users? sf 1.4. Javier -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: [Symfony2] Responding with a template at core.exception
The config has changed since PR6, so if you are using PR6, it would be app.config: instead of framework:. On Feb 26, 10:13 am, Alexander Kachkaev alex.kachk...@gmail.com wrote: Thank you, Christophe. The idea is rather clear. Unfortunately, when I write framework: exception_controller: MyController\Controller\ExceptionController I get the InvalidArgumentException with message “The framework tag is not valid”. It seems that I should define this Controller somehow else. By the way, what is the difference then between having custom exception controller and listening to “core.exception”? If I have a controller that handles all exceptions, then how can the custom event listener be useful for me? -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Re: How to set up a situation where a comments table is used for multiple entities
W dniu 26 lutego 2011 16:36 użytkownik Grzegorz Śliwiński fi...@fizyk.net.pl napisał: Michal's idea is one way, although personally wouldn't add that many fk's into Comment model. Each new model that will get commented, will result in modifying Comment table. If it'll grow up, ALTER TABLE might take long time. Second idea is to create association tables for each commented model (i'd prefer that), - Each new model will result ony in new association table, without the need to alter comment table Third idea is used in vjCommentPlugin: http://www.symfony-project.org/plugins/vjCommentPlugin There are no foreign keys, instead there is field which indicates commented object's model, and it's id. That I had in mind, just expressed it the wrong way but you can use just table_name and one fk for object id. Seems to me that this is a good way. You just have to remember to delete comments when you remove related content. On 25 Lut, 16:51, Alex Pilon alex.pi...@gmail.com wrote: Hello Everyone, I have a schema in which I have several entities, lets call them Shows, Broadcasters and Pitches. A Show is essentially pitched to a Broadcaster which creates the Pitch which is an entity that sits between Show and Broadcaster and creates a many to many relationship. This is all fine and good, however there is a Note model which is meant to be attached to Show and Broadcaster (and potentially Pitch in the future). It seems to me that this sort of multi use comments table won't work quite right unless Show and Broadcaster have a common primary key, as there wouldn't be anyway to guarentee unique ids between the Show and Broadcaster and therefore Note would have an invalid foreign key. The idea I had to solve this was to create an entity table in which the other Models inherit from, but the types of inheritance don't seem to solve this problem, as simple puts everything in one table, which is rather undesirable, and concrete doesn't seem to allow shared ids with a base table. Anyone ever have a similar set up? -- Alex Pilon (613) 608-1480 -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- Best regards, Michal http://eventhorizon.pl/ -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
[symfony-users] Re: dynamically extending classes
Hi Himanshu, this seems overly complicated. Since you're getting the same fields from the database regardless of which user is logged in, you should be fine using the same class to access those fields. The model shouldn't change depending on which user uses it, only different data should be accessed. This is simple enough to do: ProperyQuery::create() - filterByOwnerId(1) - find(); //Propel example Secondly, views give no performance boost, because underneath it pre- executes the query that defines the view every time you access it, so you may not have to write the WHERE clause, but it's still being executed. In symfony land, by using ORMs, we derive similar flexibility just in code. For example, if you find it too tedious to filter the Property entity for the current user every time you access it, just add a getPropertyQuery() method to your session user (myUser) so that does this filtering for you in one spot. The reason this is the recommended approach is because you're not spreading your business logic across multiple layers (application, storage, etc). It's all in one place - the application. Imagine you want to switch to a database that doesn't support views, then you'd have a big problem. Using Propel/Doctrine logic instead - no problem. Of course you're free to do whatever you like, this is just my opinion. :) Daniel On Feb 26, 5:11 am, himanshu hisupa...@yahoo.com wrote: Hi, I want to extend base classes dynamically. Following explains my requirements. I have a table 'Property'. Columns are 'property_id', 'owner_id', 'name' and many more. So default there will be BaseProperty class, Property class extending BaseProperty class. I want to use mysql views. views will be ctreated like following: vwProperty1 : SELECT * FROM Property WHERE owner_id = 1 vwProperty2 : SELECT * FROM Property WHERE owner_id = 2 I want to extend BaseVwProperty1, BaseVwProperty2 class dynamically. Based on login of Owner, I want either class Property extends BaseVwProperty1 or class Property extends BaseVwProperty2 And not following, which is default class Property extends BaseProperty. The usage of views can give performance boost and many thing you need not set every time, it eliminates lot of physical where conditions. This is an example and can be used in complex conditions. Any help will be appreciated. A solution or a suggestion of using any design pattern to achieve above. Himanshu -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Re: [Symfony 2] Adding custom labels to form fields
It was actually easy. I also wanted to create custom labels from inside the Form Class. Lol Thanks for tha' tip. 2011/2/26 Jan Eichhorn j...@pixel-web.org Hi, thanks for your help. Thats actually helps a lot. Greets Jan -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Re: sfWidgetFormJQueryAutocompleter: how to retrieve the keys of the selected elements?
I don't think its a bug. It's maybe more along the lines of a feature that would be nice to have. Maybe try this http://www.symfony-project.org/plugins/sfDoctrineFBAutocompletePlugin On Sat, Feb 26, 2011 at 11:23, Javier Garcia tirengar...@gmail.com wrote: Ok, now I understand how this widget works..When you create this kind of widget, it actually creates two fields: autocomplete_my_field (the field that is showed and where you insert the data (values of the array elements) and my_field (a hidden field, where the keys are inserted). This widget works ok when you insert only an element but when you insert more than an element the key of the elements are overwritten (the id of the second element overwrites the id of the the first one, the id of the third element overwrites the id of the second one, ), so you can not retrieve all them. So it's a bug I think.. Javier On Feb 24, 4:27 pm, Javier Garcia tirengar...@gmail.com wrote: Hi, i have this widget : $this-widgetSchema['user'] = new sfWidgetFormChoice(array( 'choices' = array(), 'renderer_class' = 'sfWidgetFormJQueryAutocompleter', 'renderer_options' = array('url' = 'autocomplete', 'config' = '{ multiple:true }'), )); And this is the autocomplete function: public function executeAutocomplete($request) { $this-getResponse()-setContentType('application/json'); $q = % . $request-getParameter('q') . %; $limit = $request-getParameter('limit'); //Criteria code return $this-renderText(json_encode($cli)); } that returns this (Response tab in Firebug): {17:John,18:Ann} //the numbers are the values in the id field. Then i choose both names in the autocomplete input this way: [John, Peter] When i submit the form, the getPostParameters() method returns this: array 'example' = array 'id' = string '' (length=0) '_csrf_token' = string '388774046d0f5c8b4a3f114ddb15af7b' (length=32) 'user' = string '18' (length=2) 'autocomplete_example' = array 'user' = string 'John, Ann, ' So what should i do to retrieve the id's of the users? sf 1.4. Javier -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- Alex Pilon (613) 608-1480 -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Re: How to set up a situation where a comments table is used for multiple entities
Thanks for that plug in link and the ideas. 2011/2/26 Grzegorz Śliwiński fi...@fizyk.net.pl Michal's idea is one way, although personally wouldn't add that many fk's into Comment model. Each new model that will get commented, will result in modifying Comment table. If it'll grow up, ALTER TABLE might take long time. Second idea is to create association tables for each commented model (i'd prefer that), - Each new model will result ony in new association table, without the need to alter comment table Third idea is used in vjCommentPlugin: http://www.symfony-project.org/plugins/vjCommentPlugin There are no foreign keys, instead there is field which indicates commented object's model, and it's id. On 25 Lut, 16:51, Alex Pilon alex.pi...@gmail.com wrote: Hello Everyone, I have a schema in which I have several entities, lets call them Shows, Broadcasters and Pitches. A Show is essentially pitched to a Broadcaster which creates the Pitch which is an entity that sits between Show and Broadcaster and creates a many to many relationship. This is all fine and good, however there is a Note model which is meant to be attached to Show and Broadcaster (and potentially Pitch in the future). It seems to me that this sort of multi use comments table won't work quite right unless Show and Broadcaster have a common primary key, as there wouldn't be anyway to guarentee unique ids between the Show and Broadcaster and therefore Note would have an invalid foreign key. The idea I had to solve this was to create an entity table in which the other Models inherit from, but the types of inheritance don't seem to solve this problem, as simple puts everything in one table, which is rather undesirable, and concrete doesn't seem to allow shared ids with a base table. Anyone ever have a similar set up? -- Alex Pilon (613) 608-1480 -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- Alex Pilon (613) 608-1480 -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Re: dynamically extending classes
Thank you for your suggestion. I will rethink my design. Himanshu From: Richtermeister nex...@gmail.com To: Symfony users symfony-users@googlegroups.com Sent: Sat, 26 February, 2011 10:57:44 PM Subject: [symfony-users] Re: dynamically extending classes Hi Himanshu, this seems overly complicated. Since you're getting the same fields from the database regardless of which user is logged in, you should be fine using the same class to access those fields. The model shouldn't change depending on which user uses it, only different data should be accessed. This is simple enough to do: ProperyQuery::create() - filterByOwnerId(1) - find(); //Propel example Secondly, views give no performance boost, because underneath it pre- executes the query that defines the view every time you access it, so you may not have to write the WHERE clause, but it's still being executed. In symfony land, by using ORMs, we derive similar flexibility just in code. For example, if you find it too tedious to filter the Property entity for the current user every time you access it, just add a getPropertyQuery() method to your session user (myUser) so that does this filtering for you in one spot. The reason this is the recommended approach is because you're not spreading your business logic across multiple layers (application, storage, etc). It's all in one place - the application. Imagine you want to switch to a database that doesn't support views, then you'd have a big problem. Using Propel/Doctrine logic instead - no problem. Of course you're free to do whatever you like, this is just my opinion. :) Daniel On Feb 26, 5:11 am, himanshu hisupa...@yahoo.com wrote: Hi, I want to extend base classes dynamically. Following explains my requirements. I have a table 'Property'. Columns are 'property_id', 'owner_id', 'name' and many more. So default there will be BaseProperty class, Property class extending BaseProperty class. I want to use mysql views. views will be ctreated like following: vwProperty1 : SELECT * FROM Property WHERE owner_id = 1 vwProperty2 : SELECT * FROM Property WHERE owner_id = 2 I want to extend BaseVwProperty1, BaseVwProperty2 class dynamically. Based on login of Owner, I want either class Property extends BaseVwProperty1 or class Property extends BaseVwProperty2 And not following, which is default class Property extends BaseProperty. The usage of views can give performance boost and many thing you need not set every time, it eliminates lot of physical where conditions. This is an example and can be used in complex conditions. Any help will be appreciated. A solution or a suggestion of using any design pattern to achieve above. Himanshu -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en
Re: [symfony-users] Re: dynamically extending classes
I will concur with Richter here. It is far better maintenance-wise to keep all your application logic in the app and not distribute that around into the database. The only time a view is of use is when an outside batch-script or cron job might use it as that is not directly related to your application logic, and even then I'd not rush into that. Imagine a year from now, another developer needs to take over maintaining the application. If he needs to start looking outside the application for code it will make his job that much harder. Thats just one example. Debugging becomes a bit tougher too with database-located logic as you need to determine if its DB or app. On 26/02/2011 19:27, Richtermeister wrote: Hi Himanshu, this seems overly complicated. Since you're getting the same fields from the database regardless of which user is logged in, you should be fine using the same class to access those fields. The model shouldn't change depending on which user uses it, only different data should be accessed. This is simple enough to do: ProperyQuery::create() - filterByOwnerId(1) - find(); //Propel example Secondly, views give no performance boost, because underneath it pre- executes the query that defines the view every time you access it, so you may not have to write the WHERE clause, but it's still being executed. In symfony land, by using ORMs, we derive similar flexibility just in code. For example, if you find it too tedious to filter the Property entity for the current user every time you access it, just add a getPropertyQuery() method to your session user (myUser) so that does this filtering for you in one spot. The reason this is the recommended approach is because you're not spreading your business logic across multiple layers (application, storage, etc). It's all in one place - the application. Imagine you want to switch to a database that doesn't support views, then you'd have a big problem. Using Propel/Doctrine logic instead - no problem. Of course you're free to do whatever you like, this is just my opinion. :) Daniel On Feb 26, 5:11 am, himanshuhisupa...@yahoo.com wrote: Hi, I want to extend base classes dynamically. Following explains my requirements. I have a table 'Property'. Columns are 'property_id', 'owner_id', 'name' and many more. So default there will be BaseProperty class, Property class extending BaseProperty class. I want to use mysql views. views will be ctreated like following: vwProperty1 : SELECT * FROM Property WHERE owner_id = 1 vwProperty2 : SELECT * FROM Property WHERE owner_id = 2 I want to extend BaseVwProperty1, BaseVwProperty2 class dynamically. Based on login of Owner, I want either class Property extends BaseVwProperty1 or class Property extends BaseVwProperty2 And not following, which is default class Property extends BaseProperty. The usage of views can give performance boost and many thing you need not set every time, it eliminates lot of physical where conditions. This is an example and can be used in complex conditions. Any help will be appreciated. A solution or a suggestion of using any design pattern to achieve above. Himanshu -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups symfony users group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en