My scenario: I am creating an application that will allow me to create a mapping of redirect url's that will point from the request url (the url in the old ecommerce solution) to the target url. There will be multiple implementations as we have multiple ecommerce solutions that were moving to our new one.
I am working in Laravel and have created a controller action that currently returns in JSON the redirect url's for ONE of our current ecommerce solutions. The implementation of this method is going to differ greatly from one solution to the next.
I could be "dirty" and create an abstract class like storeAbstract and each store extends it and I just look at the store_type sent in to the controller and use the correct class.
This is how I have always done it but I am looking to expand my horizons and have deigned to find a design pattern that fits this situation. If anyone has any suggestions on which design pattern I should use and how I would implement it in laravel it would be greatly appreciated.
Example of how i would do it now:
Abstract class AbstractStore {
public function getRedirectUrls() {}
}
class StorefrontStore extends AbstractStore {
public function getRedirectUrls(){
// code to get the redirect urls
}
}
class <ecommstore>Store extends AbstractStore {
public function getRedirectUrls(){
// code to get the redirect urls
}
}
This just seems very basic and there has to be a better way.
Aucun commentaire:
Enregistrer un commentaire