News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Matthew Weier O'Phinney's Blog:
From the inside-out How to layer decorators
April 07, 2009 @ 09:35:53

Matthew Weier O'Phinney has posted the second part of his look at decorators in Zend Framework applications. This time he shows the process behind using multiple decorators to alter the same content pushed through each, one after the other.

You may have noticed in the previous installment that the decorator's render() method takes a single argument, $content. This is expected to be a string. render() will then take this string and decide to either replace it, append to it, or prepend it. This allows you to have a chain of decorators -- which allows you to create decorators that render only a subset of the element's metadata, and then layer these decorators to build the full markup for the element.

He gives the example of a custom form element (as was created in the previous part) and how to split it out into two different parts - one object for the main input element and the other to alter the object and add a label. He mentions overcoming a few issues like appending content instead of overwriting, controlling the order they run in and marking where to add the new content to the content of the object.

0 comments voice your opinion now!
form decorator tutorial zendframework append content designpattern


blog comments powered by Disqus

Similar Posts

PHPRiot.com: Zend Framework 101: Zend_Gdata_YouTube

DevShed: Developing a Form Validation System with the Observer Pattern in PHP

ONLamp.com: Introduction to Flex Using PHP

7PHP.com: Interview with Matthew Weier O'Phinney - Project Lead of Zend Framework

Zend: Zend Framework Database Access Webinar (Oct 31st, 2007)


Community Events





Don't see your event here?
Let us know!


framework interview project language introduction developer configure release series podcast threedevsandamaybe bugfix library application wordpress laravel community list code api

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework