Would you make your global functions dynamic Drupal?

mindre end 1 minutters læsning

I am porting a legacy website to Drupal 7. The old website has a lot of functionality, and it works fairly well already, and it is written in konstrukt framework (which I really enjoy using). However, I want to leverage the CMS power of Drupal 7. Eventually I want to convert the entire site to Drupal, but time is limited at the moment (isn’t it always). Therefore I wanted to embed my legacy application into Drupal 7.

It should not be to hard (even though I still got some open issues). However, the showstopper at the moment are clashing free floating global functions, e.g. t() and url(). Since I do not want to replace the functions in my entire legacy application, it seems that I am not able to embed the application as I was hoping for.

Dynamic global functions in PHP would be great. Would you do that for me and the community Drupal? It is only a few lines of code!

Kommentarer

Steven Jones

With extra flexibility comes a hit in performance. Larry Garfield did a write up a while ago about the cost of using call_user_func_array etc: http://www.garfieldtech.com/blog/benchmarking-magic that’s well worth a read. Other than the performance issues, are you suggesting that before every call to l I’d need to do: <?php $GLOBALS["_global_function_handler_l"] = "drupal_function_handler_l"; $string = l("some text"); ?> Because that seems to be what that article is saying. A great idea, but needs a better implementation, maybe using PHP namespaces?

lsolesen

The article says that you have to define the $GLOBALS once. Not every time you use the function. The benefit is that you are able to redefine your function later in your application, so it is possible to include other systems into Drupal. I will have a look through the article you specified.

Skriv en kommentar

Din e-mail bliver ikke offentliggjort. Obligatoriske felter er markeret *

Indlæser...