Sometimes you need to access some resources created inside your bootstrap somewhere deep inside your application. There are two ways to achieve this. First is to use Zend_Registry, and second is to use resources of your bootstrap directly. Before we’ll follow, please ask your self: “Am I really need this?”, because in most cases you don’t need it, so this is a useless post.
(more…)
Posts Tagged ‘php’
Get Bootstrap Resource everywhere across your Zend_Application
Tuesday, March 2nd, 2010Bind model to the Zend_Form…
Wednesday, February 3rd, 2010In my previous post I have described how to fill model with values from the Zend_Form. But reverse process is also very important. If you are using Zend_Db_Table you probably will not need any special methods as you can use Zend_Form::setDefault($array) built-in method. But if you are working with Doctrine ORM or something similar you’ll need to use your own method to read model’s data and put it into the form. So today I’m going to show how to populate field values of Zend_Form from model. With traditional example application :))
(more…)
Test if request is really dispatchable in Zend Framework
Tuesday, February 2nd, 2010Sometimes you need to check if request is dispatchable. The most common place where you can meet this need is in controller plug-in. I have met that I need to test if request is dispatchable when I have implemented my App_Controller_Plugin_Acl for ACL checking based on ZF proposal. So ACL test is run before request will be dispatched. Of course I don’t want to run ACL checks for requests that are not dispatchable. I relay on standard dispatcher’s Zend_Controller_Disptcher_Interface::isDispatchable() and that was my mistake — as I spent hours trying to understand what I’m doing wrong. Yes! The problem was that isDispatchable() doesn’t care about actions — it tests controller existence only. But fortunately it still can be easily tested…
(more…)
Bind Zend_Form values to the model. Part 2 (Array-type properties)
Thursday, January 7th, 2010In my previous post I’ve added a simple binding functionality to Zend_Form. But once I’ve implemented it in real world with Doctrine PHP ORM as my BLL, I found that it can’t work seamlessly with my model’s properties of array type. In fact you’ll feel the same problem with Zend_Db_Table based models if you have fields representing arrays. The simplest solution, as I had only one such-typed property in my model, was to override My_Form::fill() method in concrete form. But as we speak about reusable code I implemented it in My_Form directly…
(more…)
Bind Zend_Form to the model
Friday, January 1st, 2010Zend Framework has great component — Zend_Form which can be used to create a reusable form. So you can create a common form, for example, for both new user registration and user profile editor. In most cases such form will represent your model. So you’ll create a lot of repetitive code for filling model’s properties with form values. Instead of this you can write a binding methods so your form will know how to bind itself to your model…
(more…)