iOS developer, php developer, runner I write, edit, and code stuff. I also raise children and sometimes clean things
http://www.corywiles.com
Lately in the PHP/Zend Framework blog world there has been much discussion concerning what constitutes a model in an MVC app. In the current implementation of the MVC apps at work our ZF Form implementations are processed in a corresponding model class as well as a 'notify' method which handles emailing a response after successful submission. I was able to abstract all aspects of the email properties except for the message body.
Most of the time the requirement is to have, basically, the same form view but with the values populate. That usually means creating some long and kludgy looking heredoc or worse a huge string of crazy html intermingled with escapes. Neither solution was very appealing to me. I kept thinking more and more that the email body was really a view. So I treated as such. So my solution was to create a global views directory and a view script that was the email body template and passed it's render method to Zend_Mail instance. This allows for further separation of models and views. I know that technically the email body should be apart of the model, but far too many times I have to change how the body of the mail looks, not the data, so it lends itself to more of a view. Please feel free to comment. ::NOTE::I was presented with a project where the client wanted a form that would accept credit card payments via paypal. I could either write it in PHP or Java. While I am a big fan of both languages I felt in this instance that PHP was the most time efficient route. However, PayPal doesn't offer an API for PHP. Only Java and .NET. As to not be discouraged I decided to spend a little time trying to come with a custom validator that would handle the validation of the credit card validation.
::Warning::One of the many growing requirements that I am experiencing at work is for internalization of our forms. In this particular use case the languages available are limited to English and Spanish so I am not able to use Zend_Locale::BROWSER exclusively. To make sure that correct form displays, in my form model class I created an array of allowed locales. Before the form instantiated in the controller the language param is set the registry, and then that locale is checked against allowed locales.
References:Translations - located in my models directory: Models/Languages/En.php and Es.php
Back in April I wrote a blog post discussing my concept of having a dynamic site using the Zend Framework. In addition, I posted an some example code of how everything works. I am a firm believer that one should practice what they preach and two different sites are now in production using the framework that I wrote and so far it works beautifully. I had to make a few changes to the route to allow for module exceptions.
Towards the end of the project there was a request to have a search functionality and also custom forms. Normally this wouldn't be an issue what so ever, but the way that the custom route is setup all requests are send to the default module/index controller/index action. I modified the route to ignore any request that started with search or forms and route those requests to the search or forms module. The regex is easily modified to allow for other exceptions. Custom Regex:Adding followers to a user one at a time is sometimes a VERY lengthy process. Last night the question was posed to me if there was a way to automate adding followers from users who follow someone else.
Example scenario: