I've created a scaffolding library that I've been using quite successfully.
For now, I have only set it up to work with models that extend
Zend_Db_Table_Abstract because I can easily analyze the model using
info(Zend_Db_Table_Abstract::METADATA). Eventually I plan to release it
along with a bunch of other useful classes, but I'm super busy with client
work and don't have the time to piece together a proper release at the
moment. In any case, it was super easy to set up and is very handy.
I won't post the class here, but I'll let you in on the basics. First, I
created a class that extends Zend_Controller_Action which any action
controller that wants scaffolding will need to inherit from. I added the
protected properties $_isScaffold and $_scaffoldModel. I then created a
protected method _scaffold(string model) to handle initialization. Let's
say I have a model class User. I can easily activate scaffold by calling
_scaffold('User') which sets _isScaffold to true and saves the model class
name to $_scaffoldModel. I then have four private methods named
_scaffoldCreate(), _scaffoldRead(), _scaffoldUpdate(), _scaffoldDelete()
which are set up to act like regular action methods. All of these methods
return false immediately if _isScaffold is false. Now, to hook everything
into the router, I use __call(). Within __call, if $_isScaffold is true,
__call performs a switch on the action name and will call the appropriate
scaffolding method. The scaffolding methods handle business like a regular
action method and render generic view scripts that I have set up to
dynamically create form fields based on METADATA. There is no code
generation, but I like this dynamic scaffolding (I believe early rails had
this but no more). Using __call is great too, and offers flexibility. As
an example, if I have scaffolding enabled, I can still define a method named
createAction on my action controller to define custom behavior while
allowing the read, update, and delete methods to be handled by __call and
generate a working interface on the fly. This setup will create basic
scaffolding that works well. I've integrated a bunch of other
functionality, but the above outline the core to get scaffolding working.
Ralf Eggert wrote:
>
> Hi Keith,
>
> thanks for the links. I was looking at Zend_Tool the other day and got
> lost somehow while reading it. So I will need to take a much closer look
> soon. I will also keep an eye on the development list.
>
> Thanks and best regards,
>
> Ralf
>
>
>
--
View this message in context:
http://www.nabble.com/Status-of-Zend_Build---scaffolding-tp18977220p19231210.html
Sent from the Zend Framework mailing list archive at Nabble.com.