[symfony-users] Re: Having a web layer for the model
You can have another layer of business logic classes that you store in lib/ which interact with your models directly. gabriel On Oct 6, 7:24 am, Sebastien Armand [Pink] khe...@gmail.com wrote: Most of the times in symfony applications, we'll have a model let's say it's 'Product' and then many interactions that I don't think belong to the model part of the application still would be really convenient if you could write them as $myModel-doThis() The kind of interaction I'm thinking about are more 'application' level. For example I'll usually have a link to a page where this product is displayed, and instead of having to write the url_for ('product_route', $myProduct), it seems to me much more natural if I could write something like $myProduct-getUrl(). Same thing for removing bits of cache related to this product, it seems correct in a way to write $myProduct-removeCachedElements(); or something like this. However those interactions as I see them don't belong to the model, they are much more linked with a higher presentational or web level of interaction. Just wondering how other people do things this way or not? -- 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: Having a web layer for the model
class WebModelClass extends ModelClass { public function __toString() { return this-getUrl(); } public function getUrl() { return Whatever I decide to do to generate URL here!; } public function initialiseForm() { //Whatever I want to do to initialise the correct form class etc } } This way, all your regular model classes are still abstracted into the correct layer but you have your additional functionality as well. On Thu, Oct 7, 2010 at 8:38 AM, pghoratiu pghora...@gmail.com wrote: You can have another layer of business logic classes that you store in lib/ which interact with your models directly. gabriel On Oct 6, 7:24 am, Sebastien Armand [Pink] khe...@gmail.com wrote: Most of the times in symfony applications, we'll have a model let's say it's 'Product' and then many interactions that I don't think belong to the model part of the application still would be really convenient if you could write them as $myModel-doThis() The kind of interaction I'm thinking about are more 'application' level. For example I'll usually have a link to a page where this product is displayed, and instead of having to write the url_for ('product_route', $myProduct), it seems to me much more natural if I could write something like $myProduct-getUrl(). Same thing for removing bits of cache related to this product, it seems correct in a way to write $myProduct-removeCachedElements(); or something like this. However those interactions as I see them don't belong to the model, they are much more linked with a higher presentational or web level of interaction. Just wondering how other people do things this way or not? -- 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.comsymfony-users%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en -- Gareth McCumskey http://garethmccumskey.blogspot.com twitter: @garethmcc -- 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: Having a web layer for the model
I rather prefer to compose than to subclass here. class ProductView { public function __construct(Product $product) { $this-product = $product; } public function setSelected($selected)... public function getUrl()... etc. } Bernhard -- 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: Having a web layer for the model
Bunch of nice ideas here! Gotta find how to make my own sauce now! On Thu, Oct 7, 2010 at 9:40 PM, Bernhard Schussek bschus...@gmail.comwrote: I rather prefer to compose than to subclass here. class ProductView { public function __construct(Product $product) { $this-product = $product; } public function setSelected($selected)... public function getUrl()... etc. } Bernhard -- 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.comsymfony-users%2bunsubscr...@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
[symfony-users] Re: Having a web layer for the model
Hey Sebastien, your intuition is right, those things don't belong in the model, as they differ from application to application. There are easy ways to have the best of both worlds though. First, links to, say, a product I find pretty simple: link_to($product, product_show, $product); However, if they do get more complex, I just add a view helper: link_to_product($product, optional title here); that encapsulates the logic for the given application. With regards to cache, you can either add a custom CacheManager class to house that code: CacheManager::clearProductCache($product); or you could put those methods into the application configuration and then call sfContext::getInstance() - getConfiguration() - clearProductCache($product); Make sense? Daniel On Oct 5, 9:24 pm, Sebastien Armand [Pink] khe...@gmail.com wrote: Most of the times in symfony applications, we'll have a model let's say it's 'Product' and then many interactions that I don't think belong to the model part of the application still would be really convenient if you could write them as $myModel-doThis() The kind of interaction I'm thinking about are more 'application' level. For example I'll usually have a link to a page where this product is displayed, and instead of having to write the url_for ('product_route', $myProduct), it seems to me much more natural if I could write something like $myProduct-getUrl(). Same thing for removing bits of cache related to this product, it seems correct in a way to write $myProduct-removeCachedElements(); or something like this. However those interactions as I see them don't belong to the model, they are much more linked with a higher presentational or web level of interaction. Just wondering how other people do things this way or not? -- 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: Having a web layer for the model
It does indeed! Thanks On Thu, Oct 7, 2010 at 12:37 AM, Richtermeister nex...@gmail.com wrote: Hey Sebastien, your intuition is right, those things don't belong in the model, as they differ from application to application. There are easy ways to have the best of both worlds though. First, links to, say, a product I find pretty simple: link_to($product, product_show, $product); However, if they do get more complex, I just add a view helper: link_to_product($product, optional title here); that encapsulates the logic for the given application. With regards to cache, you can either add a custom CacheManager class to house that code: CacheManager::clearProductCache($product); or you could put those methods into the application configuration and then call sfContext::getInstance() - getConfiguration() - clearProductCache($product); Make sense? Daniel On Oct 5, 9:24 pm, Sebastien Armand [Pink] khe...@gmail.com wrote: Most of the times in symfony applications, we'll have a model let's say it's 'Product' and then many interactions that I don't think belong to the model part of the application still would be really convenient if you could write them as $myModel-doThis() The kind of interaction I'm thinking about are more 'application' level. For example I'll usually have a link to a page where this product is displayed, and instead of having to write the url_for ('product_route', $myProduct), it seems to me much more natural if I could write something like $myProduct-getUrl(). Same thing for removing bits of cache related to this product, it seems correct in a way to write $myProduct-removeCachedElements(); or something like this. However those interactions as I see them don't belong to the model, they are much more linked with a higher presentational or web level of interaction. Just wondering how other people do things this way or not? -- 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.comsymfony-users%2bunsubscr...@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